Merge pull request #376 from fkautz/pr_out_iodine_traces_only_print_with_debug_flag_fixes_283

This commit is contained in:
Frederick F. Kautz IV
2015-04-14 18:25:29 -07:00
4 changed files with 17 additions and 19 deletions
+2 -2
View File
@@ -79,7 +79,7 @@ func doCopyCmd(ctx *cli.Context) {
urlParsers, err := parseURLs(ctx)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Fatalln(err)
console.Fatalln("Unable to parse URL")
}
sourceURLParser := urlParsers[0] // First arg is source
targetURLsParser := urlParsers[1:] // 1 or more targets
@@ -115,7 +115,7 @@ func doCopyCmd(ctx *cli.Context) {
err := writer.Close()
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Errorln(err)
console.Errorln("Unable to close writer, object may not of written properly.")
}
}
if err != nil {
+4 -5
View File
@@ -69,26 +69,25 @@ func doListCmd(ctx *cli.Context) {
urlp, err := parseURL(arg, config.Aliases)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Fatalln(err)
console.Fatalln("Unable to parse URL")
}
client, err := getNewClient(urlp, globalDebugFlag)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Fatalln(err)
console.Fatalln("Unable to initiate new client")
}
log.Println(urlp.urlType)
if urlp.bucketName == "" && urlp.urlType != urlFile { // List all buckets
buckets, err := client.ListBuckets()
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Fatalln(err)
console.Fatalln("Unable to list buckets for", urlp.String())
}
printBuckets(buckets)
} else {
items, err = client.ListObjects(urlp.bucketName, urlp.objectName)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Fatalln(err)
console.Fatalln("Unable to list objects for", urlp.String())
}
printObjects(items)
}
+5 -4
View File
@@ -38,23 +38,24 @@ func doMakeBucketCmd(ctx *cli.Context) {
urlp, err := parseURL(arg, config.Aliases)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Errorln(err)
console.Fatalln("Unable to parse URL:", arg)
}
clnt, err := getNewClient(urlp, globalDebugFlag)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Errorln(err)
console.Fatalln("Unable to create new client to:", urlp.String())
}
if urlp.urlType != urlFile {
if !client.IsValidBucketName(urlp.bucketName) {
log.Debug.Println(iodine.New(err, nil))
console.Errorln(errInvalidBucket{bucket: urlp.bucketName})
console.Fatalln("Invalid bucket name:", urlp.bucketName)
}
}
err = clnt.PutBucket(urlp.bucketName)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Errorln(err)
// TODO switch on error, print more accurate error, e.g. server down, bucket name exists, etc...
console.Fatalln("Unable to create bucket")
}
}
}
+6 -8
View File
@@ -19,11 +19,9 @@ package main
import (
"errors"
"fmt"
"io"
"time"
"encoding/json"
"io/ioutil"
"net/http"
"github.com/minio-io/cli"
@@ -56,28 +54,28 @@ func doUpdateCmd(ctx *cli.Context) {
req, err := getReq(mcUpdateURL)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Fatalln(err)
console.Fatalln("Unable to update:", mcUpdateURL)
}
res, err := http.DefaultTransport.RoundTrip(req)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Fatalln(err)
console.Fatalln("Unable to retrieve:", mcUpdateURL)
}
if res.StatusCode != http.StatusOK {
msg := fmt.Sprintf("received invalid http status: %v", res.StatusCode)
msg := fmt.Sprint("Received invalid HTTP status: ", res.StatusCode)
log.Debug.Println(iodine.New(errors.New(msg), nil))
console.Fatalln(msg)
}
ures := updateResults{}
err = json.NewDecoder(io.TeeReader(res.Body, ioutil.Discard)).Decode(&ures)
err = json.NewDecoder(res.Body).Decode(&ures)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Fatalln(err)
console.Fatalln("Unable to parse JSON:", mcUpdateURL)
}
latest, err := time.Parse(time.RFC3339Nano, ures.LatestBuild)
if err != nil {
log.Debug.Println(iodine.New(err, nil))
console.Fatalln(err)
console.Fatalln("Unable to parse update time:", ures.LatestBuild)
}
if latest.After(ctx.App.Compiled) {
// FIXME : find some proper versioning scheme here