From edb8381400efedfdf56daabd4654c5b2e30b5831 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 21 May 2015 21:55:04 -0700 Subject: [PATCH] Refactor debugging output, implement --json output currently only supported on 'ls' --- cat_test.go | 2 +- cmd-access.go | 12 +++-------- cmd-cat.go | 11 +++------- cmd-config.go | 2 -- cmd-ls.go | 11 +++------- cmd-mb.go | 11 +++------- cmd-options.go | 7 +++++- cmd-update.go | 4 +--- cmd_test.go | 8 +++---- common-methods.go | 10 ++++----- cp-url.go | 6 +++--- errors.go | 8 ------- globals.go | 1 + ls.go | 48 +++++++++++++++++++++++++++++++++++------- ls_test.go | 8 +++---- main.go | 10 ++++----- mb_access_test.go | 12 +++++------ pkg/console/console.go | 9 +++++--- 18 files changed, 94 insertions(+), 86 deletions(-) diff --git a/cat_test.go b/cat_test.go index cc67d837..9cd42672 100644 --- a/cat_test.go +++ b/cat_test.go @@ -44,6 +44,6 @@ func (s *CmdTestSuite) TestCatCmd(c *C) { sourceConfigMap[objectPath] = &hostConfig{} sourceConfigMap[server.URL+"/bucket/object1"] = &hostConfig{} - _, err = doCatCmd(sourceConfigMap, false) + _, err = doCatCmd(sourceConfigMap) c.Assert(err, IsNil) } diff --git a/cmd-access.go b/cmd-access.go index 4771b0d4..e46be3a7 100644 --- a/cmd-access.go +++ b/cmd-access.go @@ -35,7 +35,6 @@ func runAccessCmd(ctx *cli.Context) { } config, err := getMcConfig() if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("loading config file failed with following reason: [%s]\n", iodine.ToError(err)) } targetURLConfigMap := make(map[string]*hostConfig) @@ -43,44 +42,39 @@ func runAccessCmd(ctx *cli.Context) { if err != nil { switch e := iodine.ToError(err).(type) { case errUnsupportedScheme: - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unknown type of URL ‘%s’. Reason: %s.\n", e.url, e) default: - console.Debugln(iodine.New(err, nil)) console.Fatalf("reading URLs failed with following Reason: %s\n", e) } } acl := bucketACL(ctx.Args().First()) if !acl.isValidBucketACL() { - console.Debugln(iodine.New(errInvalidACL{acl: acl.String()}, nil)) console.Fatalf("Access type ‘%s’ is not supported. Valid types are [private, public, readonly].\n", acl) } targetURLs = targetURLs[1:] // 1 or more target URLs for _, targetURL := range targetURLs { targetConfig, err := getHostConfig(targetURL) if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to read configuration for host ‘%s’. Reason: %s.\n", targetURL, iodine.ToError(err)) } targetURLConfigMap[targetURL] = targetConfig } for targetURL, targetConfig := range targetURLConfigMap { - errorMsg, err := doUpdateAccessCmd(targetURL, acl.String(), targetConfig, globalDebugFlag) + errorMsg, err := doUpdateAccessCmd(targetURL, acl.String(), targetConfig) err = iodine.New(err, nil) if err != nil { if errorMsg == "" { errorMsg = "Empty error message. Please rerun this command with --debug and file a bug report." } - console.Debugln(err) console.Errorf("%s", errorMsg) } } } -func doUpdateAccessCmd(targetURL, targetACL string, targetConfig *hostConfig, debug bool) (string, error) { +func doUpdateAccessCmd(targetURL, targetACL string, targetConfig *hostConfig) (string, error) { var err error var clnt client.Client - clnt, err = getNewClient(targetURL, targetConfig, debug) + clnt, err = getNewClient(targetURL, targetConfig) if err != nil { err := iodine.New(err, nil) msg := fmt.Sprintf("Unable to initialize client for ‘%s’. Reason: %s.\n", diff --git a/cmd-cat.go b/cmd-cat.go index 294f9889..58b3e2a5 100644 --- a/cmd-cat.go +++ b/cmd-cat.go @@ -35,7 +35,6 @@ func runCatCmd(ctx *cli.Context) { } config, err := getMcConfig() if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to read config file ‘%s’. Reason: %s.\n", mustGetMcConfigPath(), iodine.ToError(err)) } @@ -44,10 +43,8 @@ func runCatCmd(ctx *cli.Context) { if err != nil { switch e := iodine.ToError(err).(type) { case errUnsupportedScheme: - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unknown type of URL ‘%s’. Reason: %s.\n", e.url, e) default: - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to parse arguments. Reason: %s.\n", iodine.ToError(err)) } } @@ -55,20 +52,18 @@ func runCatCmd(ctx *cli.Context) { sourceURLs := urls sourceURLConfigMap, err := getHostConfigs(sourceURLs) if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to read host configuration for ‘%s’ from config file ‘%s’. Reason: %s.\n", sourceURLs, mustGetMcConfigPath(), iodine.ToError(err)) } - humanReadable, err := doCatCmd(sourceURLConfigMap, globalDebugFlag) + humanReadable, err := doCatCmd(sourceURLConfigMap) if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalln(humanReadable) } } -func doCatCmd(sourceURLConfigMap map[string]*hostConfig, debug bool) (string, error) { +func doCatCmd(sourceURLConfigMap map[string]*hostConfig) (string, error) { for url, config := range sourceURLConfigMap { - sourceClnt, err := getNewClient(url, config, debug) + sourceClnt, err := getNewClient(url, config) if err != nil { return "Unable to create client: " + url, iodine.New(err, nil) } diff --git a/cmd-config.go b/cmd-config.go index 01c4e906..8277c5e5 100644 --- a/cmd-config.go +++ b/cmd-config.go @@ -34,12 +34,10 @@ func runConfigCmd(ctx *cli.Context) { arg := ctx.Args().First() tailArgs := ctx.Args().Tail() if len(tailArgs) > 2 { - console.Debugln(iodine.New(errInvalidArgument{}, nil)) console.Fatalln("Incorrect number of arguments, please use \"mc config help\"") } msg, err := doConfig(arg, tailArgs) if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalln(msg) } console.Infoln(msg) diff --git a/cmd-ls.go b/cmd-ls.go index c570eb7e..8ed1268d 100644 --- a/cmd-ls.go +++ b/cmd-ls.go @@ -32,7 +32,6 @@ func runListCmd(ctx *cli.Context) { } config, err := getMcConfig() if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to read config file ‘%s’. Reason: %s.\n", mustGetMcConfigPath(), iodine.ToError(err)) } targetURLConfigMap := make(map[string]*hostConfig) @@ -41,16 +40,13 @@ func runListCmd(ctx *cli.Context) { if err != nil { switch e := iodine.ToError(err).(type) { case errUnsupportedScheme: - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unknown type of URL ‘%s’. Reason: %s.\n", e.url, e) default: - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to parse argument ‘%s’. Reason: %s.\n", arg, iodine.ToError(err)) } } targetConfig, err := getHostConfig(targetURL) if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to read host configuration for ‘%s’ from config file ‘%s’. Reason: %s.\n", targetURL, mustGetMcConfigPath(), iodine.ToError(err)) } @@ -59,18 +55,17 @@ func runListCmd(ctx *cli.Context) { for targetURL, targetConfig := range targetURLConfigMap { // if recursive strip off the "..." newTargetURL := stripRecursiveURL(targetURL) - err = doListCmd(newTargetURL, targetConfig, isURLRecursive(targetURL), globalDebugFlag) + err = doListCmd(newTargetURL, targetConfig, isURLRecursive(targetURL)) err = iodine.New(err, nil) if err != nil { - console.Debugln(err) console.Fatalf("Failed to list ‘%s’. Reason: %s.\n", targetURL, iodine.ToError(err)) } } } // doListCmd - -func doListCmd(targetURL string, targetConfig *hostConfig, recursive, debug bool) error { - clnt, err := getNewClient(targetURL, targetConfig, globalDebugFlag) +func doListCmd(targetURL string, targetConfig *hostConfig, recursive bool) error { + clnt, err := getNewClient(targetURL, targetConfig) if err != nil { return iodine.New(err, map[string]string{"Target": targetURL}) } diff --git a/cmd-mb.go b/cmd-mb.go index ef824826..666b8534 100644 --- a/cmd-mb.go +++ b/cmd-mb.go @@ -36,7 +36,6 @@ func runMakeBucketCmd(ctx *cli.Context) { } config, err := getMcConfig() if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to read config file ‘%s’. Reason: %s\n", mustGetMcConfigPath(), iodine.ToError(err)) } targetURLConfigMap := make(map[string]*hostConfig) @@ -44,39 +43,35 @@ func runMakeBucketCmd(ctx *cli.Context) { if err != nil { switch e := iodine.ToError(err).(type) { case errUnsupportedScheme: - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unknown URL type ‘%s’ passed. Reason: %s.\n", e.url, e) default: - console.Debugln(iodine.New(err, nil)) console.Fatalf("Error in parsing path or URL. Reason: %s.\n", e) } } for _, targetURL := range targetURLs { targetConfig, err := getHostConfig(targetURL) if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to read configuration for host ‘%s’. Reason: %s.\n", targetURL, iodine.ToError(err)) } targetURLConfigMap[targetURL] = targetConfig } for targetURL, targetConfig := range targetURLConfigMap { - errorMsg, err := doMakeBucketCmd(targetURL, targetConfig, globalDebugFlag) + errorMsg, err := doMakeBucketCmd(targetURL, targetConfig) err = iodine.New(err, nil) if err != nil { if errorMsg == "" { errorMsg = "Empty error message. Please rerun this command with --debug and file a bug report." } - console.Debugln(err) console.Errorf("%s", errorMsg) } } } // doMakeBucketCmd - -func doMakeBucketCmd(targetURL string, targetConfig *hostConfig, debug bool) (string, error) { +func doMakeBucketCmd(targetURL string, targetConfig *hostConfig) (string, error) { var err error var clnt client.Client - clnt, err = getNewClient(targetURL, targetConfig, debug) + clnt, err = getNewClient(targetURL, targetConfig) if err != nil { err := iodine.New(err, nil) msg := fmt.Sprintf("Unable to initialize client for ‘%s’. Reason: %s.\n", diff --git a/cmd-options.go b/cmd-options.go index 46697f9e..a74d8e42 100644 --- a/cmd-options.go +++ b/cmd-options.go @@ -340,7 +340,8 @@ var commands = []cli.Command{ // Collection of mc flags currently supported // -// --theme "minimal"Choose a console theme from this list [*minimal*, nocolor, white] +// --theme "minimal" Choose a console theme from this list [*minimal*, nocolor, white] +// --json Enable json formatted output // --debug Enable HTTP tracing // --quiet, -q Supress chatty console output // --retry "5" Number of retry count @@ -362,6 +363,10 @@ var ( return strings.Join(keys, ", ") }()), }, + cli.BoolFlag{ + Name: "json", + Usage: "Enable json formatted output", + }, cli.BoolFlag{ Name: "debug", Usage: "Enable HTTP tracing", diff --git a/cmd-update.go b/cmd-update.go index 814884a4..d91f7a47 100644 --- a/cmd-update.go +++ b/cmd-update.go @@ -30,7 +30,7 @@ const ( ) func doUpdateCheck(config *hostConfig) (string, error) { - clnt, err := getNewClient(mcUpdateURL, config, globalDebugFlag) + clnt, err := getNewClient(mcUpdateURL, config) if err != nil { return "Unable to create client: " + mcUpdateURL, iodine.New(err, map[string]string{"failedURL": mcUpdateURL}) } @@ -60,12 +60,10 @@ func runUpdateCmd(ctx *cli.Context) { } hostConfig, err := getHostConfig(mcUpdateURL) if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to read configuration for host ‘%s’. Reason: %s.\n", mcUpdateURL, iodine.ToError(err)) } msg, err := doUpdateCheck(hostConfig) if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalln(msg) } if msg != "" { diff --git a/cmd_test.go b/cmd_test.go index d64d43f6..4b3bb71d 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -66,13 +66,13 @@ func (s *CmdTestSuite) TearDownSuite(c *C) { } func (s *CmdTestSuite) TestGetNewClient(c *C) { - _, err := getNewClient("http://example.com/bucket1", &hostConfig{}, false) + _, err := getNewClient("http://example.com/bucket1", &hostConfig{}) c.Assert(err, IsNil) - _, err = getNewClient("C:\\Users\\Administrator\\MyDocuments", &hostConfig{}, false) + _, err = getNewClient("C:\\Users\\Administrator\\MyDocuments", &hostConfig{}) c.Assert(err, IsNil) - _, err = getNewClient("/usr/bin/pandoc", &hostConfig{}, false) + _, err = getNewClient("/usr/bin/pandoc", &hostConfig{}) c.Assert(err, IsNil) - _, err = getNewClient("pkg/client", &hostConfig{}, false) + _, err = getNewClient("pkg/client", &hostConfig{}) c.Assert(err, IsNil) } diff --git a/common-methods.go b/common-methods.go index 5168c180..8e8b61e1 100644 --- a/common-methods.go +++ b/common-methods.go @@ -29,7 +29,7 @@ import ( // getSource - func getSource(sourceURL string, sourceConfig *hostConfig) (reader io.Reader, length uint64, err error) { - sourceClnt, err := getNewClient(sourceURL, sourceConfig, globalDebugFlag) + sourceClnt, err := getNewClient(sourceURL, sourceConfig) if err != nil { return nil, 0, iodine.New(err, map[string]string{"failedURL": sourceURL}) } @@ -38,7 +38,7 @@ func getSource(sourceURL string, sourceConfig *hostConfig) (reader io.Reader, le // putTarget - func putTarget(targetURL string, targetConfig *hostConfig, length uint64, data io.Reader) error { - targetClnt, err := getNewClient(targetURL, targetConfig, globalDebugFlag) + targetClnt, err := getNewClient(targetURL, targetConfig) if err != nil { return iodine.New(err, nil) } @@ -50,7 +50,7 @@ func putTarget(targetURL string, targetConfig *hostConfig, length uint64, data i } // getNewClient gives a new client interface -func getNewClient(urlStr string, auth *hostConfig, debug bool) (clnt client.Client, err error) { +func getNewClient(urlStr string, auth *hostConfig) (clnt client.Client, err error) { url, err := client.Parse(urlStr) if err != nil { return nil, iodine.New(errInvalidURL{url: urlStr}, nil) @@ -67,7 +67,7 @@ func getNewClient(urlStr string, auth *hostConfig, debug bool) (clnt client.Clie s3Config.AppVersion = Version s3Config.AppComments = []string{os.Args[0], runtime.GOOS, runtime.GOARCH} s3Config.HostURL = urlStr - s3Config.Debug = debug + s3Config.Debug = globalDebugFlag return s3.New(s3Config) case client.Filesystem: return fs.New(urlStr) @@ -82,7 +82,7 @@ func url2Stat(urlStr string) (client client.Client, content *client.Content, err return nil, nil, iodine.New(err, map[string]string{"URL": urlStr}) } - client, err = getNewClient(urlStr, config, globalDebugFlag) + client, err = getNewClient(urlStr, config) if err != nil { return nil, nil, iodine.New(err, map[string]string{"URL": urlStr}) } diff --git a/cp-url.go b/cp-url.go index 84f4ec7d..0c7ec6c6 100644 --- a/cp-url.go +++ b/cp-url.go @@ -83,7 +83,7 @@ func source2Client(sourceURL string) (client.Client, error) { return nil, iodine.New(errInvalidSource{path: sourceURL}, nil) } - sourceClient, err := getNewClient(sourceURL, sourceConfig, globalDebugFlag) + sourceClient, err := getNewClient(sourceURL, sourceConfig) if err != nil { return nil, iodine.New(errInvalidSource{path: sourceURL}, nil) } @@ -105,7 +105,7 @@ func target2Client(targetURL string) (client.Client, error) { return nil, iodine.New(errInvalidTarget{path: targetURL}, nil) } - targetClient, err := getNewClient(targetURL, targetConfig, globalDebugFlag) + targetClient, err := getNewClient(targetURL, targetConfig) if err != nil { return nil, iodine.New(errInvalidTarget{path: targetURL}, nil) } @@ -123,7 +123,7 @@ func isTargetURLDir(targetURL string) bool { return false } - targetClient, err := getNewClient(targetURL, targetConfig, globalDebugFlag) + targetClient, err := getNewClient(targetURL, targetConfig) if err != nil { return false } diff --git a/errors.go b/errors.go index 134fa2f2..4556c40c 100644 --- a/errors.go +++ b/errors.go @@ -24,14 +24,6 @@ func (e errNotAnObject) Error() string { return "Not an object " + e.url } -type errInvalidACL struct { - acl string -} - -func (e errInvalidACL) Error() string { - return "Invalid ACL: " + e.acl -} - type errInvalidArgument struct{} func (e errInvalidArgument) Error() string { diff --git a/globals.go b/globals.go index c32a2285..b72f205c 100644 --- a/globals.go +++ b/globals.go @@ -21,6 +21,7 @@ var ( globalDebugFlag = false // Debug flag set via command line globalQuietFlag = false // Quiet flag set via command line globalMaxRetryFlag = 5 // Maximum number of retries + globalJSONFlag = false // Json flag set via command line mcCurrentConfigVersion = "1.0.0" ) diff --git a/ls.go b/ls.go index c07a5a95..9a688f52 100644 --- a/ls.go +++ b/ls.go @@ -17,6 +17,7 @@ package main import ( + "encoding/json" "fmt" "os" "strings" @@ -28,25 +29,51 @@ import ( "github.com/minio/minio/pkg/iodine" ) -/// LS - related internal functions +/// ls - related internal functions // iso8601 date const ( printDate = "2006-01-02 15:04:05 MST" ) +// printJSON rather than colored output +func printJSON(content *client.Content) { + type jsonContent struct { + Filetype string `json:"content-type"` + Date string `json:"last-modified"` + Size string `json:"size"` + Name string `json:"name"` + } + contentJSON := new(jsonContent) + contentJSON.Date = content.Time.Local().Format(printDate) + contentJSON.Size = humanize.IBytes(uint64(content.Size)) + contentJSON.Filetype = func() string { + if content.Type.IsDir() { + return "inode/directory" + } + if content.Type.IsRegular() { + return "application/octet-stream" + } + return "application/octet-stream" + }() + contentJSON.Name = content.Name + contentBytes, _ := json.MarshalIndent(contentJSON, "", "\t") + fmt.Println(string(contentBytes)) +} + // printContent prints content meta-data -func printContent(date time.Time, v int64, name string, fileType os.FileMode) { +func printContent(date time.Time, size int64, name string, fileType os.FileMode) { fmt.Printf(console.Time("[%s] ", date.Local().Format(printDate))) - fmt.Printf(console.Size("%6s ", humanize.IBytes(uint64(v)))) + fmt.Printf(console.Size("%6s ", humanize.IBytes(uint64(size)))) // just making it explicit - switch fileType.IsDir() { - case true: + switch { + case fileType.IsDir() == true: // if one finds a prior suffix no need to append a new one - if strings.HasSuffix(name, "/") { + switch { + case strings.HasSuffix(name, "/") == true: fmt.Println(console.Dir("%s", name)) - } else { + default: fmt.Println(console.Dir("%s/", name)) } default: @@ -70,7 +97,12 @@ func doList(clnt client.Client, targetURL string, recursive bool) error { // To be consistent we have to filter them out contentName = strings.TrimPrefix(contentName, strings.TrimSuffix(targetURL, "/")+"/") } - printContent(contentCh.Content.Time, contentCh.Content.Size, contentName, contentCh.Content.Type) + switch { + case globalJSONFlag == true: + printJSON(contentCh.Content) + default: + printContent(contentCh.Content.Time, contentCh.Content.Size, contentName, contentCh.Content.Type) + } } if err != nil { return iodine.New(err, map[string]string{"Target": targetURL}) diff --git a/ls_test.go b/ls_test.go index 62b6af1b..8428fbc2 100644 --- a/ls_test.go +++ b/ls_test.go @@ -40,10 +40,10 @@ func (s *CmdTestSuite) TestLSCmd(c *C) { c.Assert(err, IsNil) } - err = doListCmd(root, &hostConfig{}, false, false) + err = doListCmd(root, &hostConfig{}, false) c.Assert(err, IsNil) - err = doListCmd(root, &hostConfig{}, true, false) + err = doListCmd(root, &hostConfig{}, true) c.Assert(err, IsNil) for i := 0; i < 10; i++ { @@ -53,10 +53,10 @@ func (s *CmdTestSuite) TestLSCmd(c *C) { err := putTarget(objectPath, &hostConfig{}, uint64(dataLen), bytes.NewReader([]byte(data))) c.Assert(err, IsNil) } - err = doListCmd(server.URL+"/bucket", &hostConfig{}, false, false) + err = doListCmd(server.URL+"/bucket", &hostConfig{}, false) c.Assert(err, IsNil) - err = doListCmd(server.URL+"/bucket", &hostConfig{}, true, false) + err = doListCmd(server.URL+"/bucket", &hostConfig{}, true) c.Assert(err, IsNil) } diff --git a/main.go b/main.go index c4216cfb..994c82bb 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,6 @@ import ( func checkConfig() { _, err := user.Current() if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalln("Unable to determine current user") } @@ -46,7 +45,6 @@ func checkConfig() { // Ensures config file is sane _, err = getMcConfig() if err != nil { - console.Debugln(iodine.New(err, nil)) console.Fatalf("Unable to read config file: %s\n", mustGetMcConfigPath()) } } @@ -104,18 +102,20 @@ func main() { globalQuietFlag = ctx.GlobalBool("quiet") globalDebugFlag = ctx.GlobalBool("debug") globalMaxRetryFlag = ctx.GlobalInt("retry") + globalJSONFlag = ctx.GlobalBool("json") if globalDebugFlag { app.ExtraInfo = getSystemData() console.NoDebugPrint = false } themeName := ctx.GlobalString("theme") - if console.IsValidTheme(themeName) { + switch { + case console.IsValidTheme(themeName) != true: + console.Fatalf("Theme ‘%s’ is not supported. Please choose from this list: %s.\n", themeName, console.GetThemeNames()) + default: err := console.SetTheme(themeName) if err != nil { console.Fatalf("Failed to set theme ‘%s’. Reason: %s.\n", themeName, iodine.ToError(err)) } - } else { - console.Fatalf("Theme ‘%s’ is not supported. Please choose from this list: %s.\n", themeName, console.GetThemeNames()) } checkConfig() return nil diff --git a/mb_access_test.go b/mb_access_test.go index 023d2e04..74ce9c99 100644 --- a/mb_access_test.go +++ b/mb_access_test.go @@ -30,22 +30,22 @@ func (s *CmdTestSuite) TestMbAndAccessCmd(c *C) { c.Assert(err, IsNil) defer os.RemoveAll(root) - _, err = doMakeBucketCmd(filepath.Join(root, "bucket"), &hostConfig{}, false) + _, err = doMakeBucketCmd(filepath.Join(root, "bucket"), &hostConfig{}) c.Assert(err, IsNil) - _, err = doUpdateAccessCmd(filepath.Join(root, "bucket"), "public-read-write", &hostConfig{}, false) + _, err = doUpdateAccessCmd(filepath.Join(root, "bucket"), "public-read-write", &hostConfig{}) c.Assert(err, IsNil) - _, err = doUpdateAccessCmd(filepath.Join(root, "bucket"), "invalid", &hostConfig{}, false) + _, err = doUpdateAccessCmd(filepath.Join(root, "bucket"), "invalid", &hostConfig{}) c.Assert(err, Not(IsNil)) - _, err = doMakeBucketCmd(server.URL+"/bucket", &hostConfig{}, false) + _, err = doMakeBucketCmd(server.URL+"/bucket", &hostConfig{}) c.Assert(err, IsNil) - _, err = doUpdateAccessCmd(server.URL+"/bucket", "public-read-write", &hostConfig{}, false) + _, err = doUpdateAccessCmd(server.URL+"/bucket", "public-read-write", &hostConfig{}) c.Assert(err, IsNil) - _, err = doUpdateAccessCmd(server.URL+"/bucket", "invalid", &hostConfig{}, false) + _, err = doUpdateAccessCmd(server.URL+"/bucket", "invalid", &hostConfig{}) c.Assert(err, Not(IsNil)) } diff --git a/pkg/console/console.go b/pkg/console/console.go index 6b8f29b5..2ad0bf4c 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -28,7 +28,7 @@ import ( "github.com/shiena/ansicolor" ) -// NoDebugPrint defines if the input should be printed or not. By default it's set to true. +// NoDebugPrint defines if the input should be printed in debug or not. By default it's set to true. var NoDebugPrint = true var ( @@ -38,7 +38,11 @@ var ( stderrColoredOutput = ansicolor.NewAnsiColorWriter(os.Stderr) // themesDB contains supported list of Themes - themesDB = map[string]Theme{"minimal": MiniTheme, "nocolor": NoColorTheme, "white": WhiteTheme} + themesDB = map[string]Theme{ + "minimal": MiniTheme, + "nocolor": NoColorTheme, + "white": WhiteTheme, + } // currTheme is current theme currThemeName = func() string { @@ -120,7 +124,6 @@ type Theme struct { File *color.Color Dir *color.Color Retry *color.Color - // Reason *color.Color } var (