1
0
mirror of https://github.com/minio/mc.git synced 2025-07-30 07:23:03 +03:00

cleanup commands to use Go 'err' as 'e' (#4232)

many commands seem to have sort of had
stopped following the expected convention
in `mc` to differentiate *probe.Error.

To keep things readable this PR is the
first attempt at such a cleanup.
This commit is contained in:
Harshavardhana
2022-09-06 08:03:25 -07:00
committed by GitHub
parent 2c9a733cae
commit 5cd7ff8876
22 changed files with 104 additions and 114 deletions

View File

@ -133,9 +133,12 @@ func mainAdminBucketQuota(ctx *cli.Context) error {
quotaStr := ctx.String("hard") quotaStr := ctx.String("hard")
quota, e := humanize.ParseBytes(quotaStr) quota, e := humanize.ParseBytes(quotaStr)
fatalIf(probe.NewError(e).Trace(quotaStr), "Unable to parse quota") fatalIf(probe.NewError(e).Trace(quotaStr), "Unable to parse quota")
if e = client.SetBucketQuota(globalContext, targetURL, &madmin.BucketQuota{Quota: quota, Type: qType}); e != nil {
fatalIf(probe.NewError(e).Trace(args...), "Unable to set bucket quota") fatalIf(probe.NewError(client.SetBucketQuota(globalContext, targetURL, &madmin.BucketQuota{
} Quota: quota,
Type: qType,
})).Trace(args...), "Unable to set bucket quota")
printMsg(quotaMessage{ printMsg(quotaMessage{
op: "set", op: "set",
Bucket: targetURL, Bucket: targetURL,
@ -144,8 +147,8 @@ func mainAdminBucketQuota(ctx *cli.Context) error {
Status: "success", Status: "success",
}) })
} else if ctx.Bool("clear") { } else if ctx.Bool("clear") {
if err := client.SetBucketQuota(globalContext, targetURL, &madmin.BucketQuota{}); err != nil { if e := client.SetBucketQuota(globalContext, targetURL, &madmin.BucketQuota{}); e != nil {
fatalIf(probe.NewError(err).Trace(args...), "Unable to clear bucket quota config") fatalIf(probe.NewError(e).Trace(args...), "Unable to clear bucket quota config")
} }
printMsg(quotaMessage{ printMsg(quotaMessage{
op: "unset", op: "unset",

View File

@ -84,8 +84,8 @@ func mainClusterBucketExport(ctx *cli.Context) error {
aliasedURL = filepath.Clean(aliasedURL) aliasedURL = filepath.Clean(aliasedURL)
_, bucket := url2Alias(aliasedURL) _, bucket := url2Alias(aliasedURL)
r, ierr := client.ExportBucketMetadata(context.Background(), bucket) r, e := client.ExportBucketMetadata(context.Background(), bucket)
fatalIf(probe.NewError(ierr).Trace(aliasedURL), "Unable to export bucket metadata.") fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to export bucket metadata.")
if bucket == "" { if bucket == "" {
bucket = "cluster" bucket = "cluster"

View File

@ -109,8 +109,9 @@ func mainClusterBucketImport(ctx *cli.Context) error {
aliasedURL = filepath.Clean(aliasedURL) aliasedURL = filepath.Clean(aliasedURL)
_, bucket := url2Alias(aliasedURL) _, bucket := url2Alias(aliasedURL)
rpt, ierr := client.ImportBucketMetadata(context.Background(), bucket, f) rpt, e := client.ImportBucketMetadata(context.Background(), bucket, f)
fatalIf(probe.NewError(ierr).Trace(aliasedURL), "Unable to import bucket metadata.") fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to import bucket metadata.")
printMsg(importMetaMsg{ printMsg(importMetaMsg{
BucketMetaImportErrs: rpt, BucketMetaImportErrs: rpt,
Status: "success", Status: "success",

View File

@ -78,8 +78,8 @@ func mainClusterIAMExport(ctx *cli.Context) error {
return nil return nil
} }
r, ierr := client.ExportIAM(context.Background()) r, e := client.ExportIAM(context.Background())
fatalIf(probe.NewError(ierr).Trace(aliasedURL), "Unable to export IAM info.") fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to export IAM info.")
// Create iam info zip file // Create iam info zip file
tmpFile, e := ioutil.TempFile("", fmt.Sprintf("%s-iam-info", aliasedURL)) tmpFile, e := ioutil.TempFile("", fmt.Sprintf("%s-iam-info", aliasedURL))

View File

@ -92,8 +92,9 @@ func mainClusterIAMImport(ctx *cli.Context) error {
return nil return nil
} }
ierr := client.ImportIAM(context.Background(), f) e = client.ImportIAM(context.Background(), f)
fatalIf(probe.NewError(ierr).Trace(aliasedURL), "Unable to import IAM info.") fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to import IAM info.")
if !globalJSON { if !globalJSON {
console.Infof("IAM info imported to %s from %s\n", aliasedURL, args.Get(1)) console.Infof("IAM info imported to %s from %s\n", aliasedURL, args.Get(1))
} }

View File

@ -18,8 +18,6 @@
package cmd package cmd
import ( import (
"errors"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/minio/cli" "github.com/minio/cli"
"github.com/minio/madmin-go" "github.com/minio/madmin-go"
@ -71,18 +69,17 @@ func mainAdminGroupEnableDisable(ctx *cli.Context) error {
fatalIf(err, "Unable to initialize admin connection.") fatalIf(err, "Unable to initialize admin connection.")
group := args.Get(1) group := args.Get(1)
var err1 error
var status madmin.GroupStatus var status madmin.GroupStatus
if ctx.Command.Name == "enable" { switch ctx.Command.Name {
case "enable":
status = madmin.GroupEnabled status = madmin.GroupEnabled
} else if ctx.Command.Name == "disable" { case "disable":
status = madmin.GroupDisabled status = madmin.GroupDisabled
} else { default:
err1 = errors.New("cannot happen") fatalIf(errInvalidArgument().Trace(ctx.Command.Name), "Invalid group status name")
fatalIf(probe.NewError(err1).Trace(args...), "Could not get group enable")
} }
err1 = client.SetGroupStatus(globalContext, group, status) e := client.SetGroupStatus(globalContext, group, status)
fatalIf(probe.NewError(err1).Trace(args...), "Could not get group enable") fatalIf(probe.NewError(e).Trace(args...), "Unable set group status")
printMsg(groupMessage{ printMsg(groupMessage{
op: ctx.Command.Name, op: ctx.Command.Name,

View File

@ -68,8 +68,8 @@ func mainAdminGroupInfo(ctx *cli.Context) error {
fatalIf(err, "Unable to initialize admin connection.") fatalIf(err, "Unable to initialize admin connection.")
group := args.Get(1) group := args.Get(1)
gd, err1 := client.GetGroupDescription(globalContext, group) gd, e := client.GetGroupDescription(globalContext, group)
fatalIf(probe.NewError(err1).Trace(args...), "Could not get group info") fatalIf(probe.NewError(e).Trace(args...), "Unable to fetch group info")
printMsg(groupMessage{ printMsg(groupMessage{
op: "info", op: "info",

View File

@ -67,8 +67,8 @@ func mainAdminGroupList(ctx *cli.Context) error {
client, err := newAdminClient(aliasedURL) client, err := newAdminClient(aliasedURL)
fatalIf(err, "Unable to initialize admin connection.") fatalIf(err, "Unable to initialize admin connection.")
gs, err1 := client.ListGroups(globalContext) gs, e := client.ListGroups(globalContext)
fatalIf(probe.NewError(err1).Trace(args...), "Could not get group list") fatalIf(probe.NewError(e).Trace(args...), "Unable to list groups")
printMsg(groupMessage{ printMsg(groupMessage{
op: "list", op: "list",

View File

@ -98,10 +98,7 @@ func mainAdminScannerInfo(ctx *cli.Context) error {
// Create a new MinIO Admin Client // Create a new MinIO Admin Client
client, err := newAdminClient(aliasedURL) client, err := newAdminClient(aliasedURL)
if err != nil { fatalIf(err.Trace(aliasedURL), "Unable to initialize admin client.")
fatalIf(err.Trace(aliasedURL), "Unable to initialize admin client.")
return nil
}
ctxt, cancel := context.WithCancel(globalContext) ctxt, cancel := context.WithCancel(globalContext)
defer cancel() defer cancel()
@ -123,7 +120,7 @@ func mainAdminScannerInfo(ctx *cli.Context) error {
os.Exit(0) os.Exit(0)
}() }()
} }
cerr := client.Metrics(ctxt, opts, func(metrics madmin.RealtimeMetrics) { e := client.Metrics(ctxt, opts, func(metrics madmin.RealtimeMetrics) {
if globalJSON { if globalJSON {
printMsg(metricsMessage{RealtimeMetrics: metrics}) printMsg(metricsMessage{RealtimeMetrics: metrics})
return return
@ -131,8 +128,8 @@ func mainAdminScannerInfo(ctx *cli.Context) error {
ui.Send(metrics) ui.Send(metrics)
}) })
if cerr != nil && !errors.Is(cerr, context.Canceled) { if e != nil && !errors.Is(e, context.Canceled) {
fatalIf(probe.NewError(cerr).Trace(aliasedURL), "Error making request") fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to fetch scanner metrics")
return nil return nil
} }

View File

@ -363,8 +363,8 @@ func mainAdminTierAdd(ctx *cli.Context) error {
args := ctx.Args() args := ctx.Args()
tierTypeStr := args.Get(0) tierTypeStr := args.Get(0)
tierType, err := madmin.NewTierType(tierTypeStr) tierType, e := madmin.NewTierType(tierTypeStr)
fatalIf(probe.NewError(err), "Unsupported tier type") fatalIf(probe.NewError(e), "Unsupported tier type")
aliasedURL := args.Get(1) aliasedURL := args.Get(1)
tierName := args.Get(2) tierName := args.Get(2)
@ -377,9 +377,7 @@ func mainAdminTierAdd(ctx *cli.Context) error {
fatalIf(cerr, "Unable to initialize admin connection.") fatalIf(cerr, "Unable to initialize admin connection.")
tCfg := fetchTierConfig(ctx, strings.ToUpper(tierName), tierType) tCfg := fetchTierConfig(ctx, strings.ToUpper(tierName), tierType)
if err = client.AddTier(globalContext, tCfg); err != nil { fatalIf(probe.NewError(client.AddTier(globalContext, tCfg)).Trace(args...), "Unable to configure remote tier target")
fatalIf(probe.NewError(err).Trace(args...), "Unable to configure remote tier target")
}
msg := &tierMessage{ msg := &tierMessage{
op: "add", op: "add",

View File

@ -135,9 +135,8 @@ func mainAdminTierEdit(ctx *cli.Context) error {
fatalIf(errInvalidArgument().Trace(args.Tail()...), "Insufficient credential information supplied to update remote tier target credentials") fatalIf(errInvalidArgument().Trace(args.Tail()...), "Insufficient credential information supplied to update remote tier target credentials")
} }
if err := client.EditTier(globalContext, tierName, creds); err != nil { e := client.EditTier(globalContext, tierName, creds)
fatalIf(probe.NewError(err).Trace(args...), "Unable to edit remote tier") fatalIf(probe.NewError(e).Trace(args...), "Unable to edit remote tier")
}
printMsg(&tierMessage{ printMsg(&tierMessage{
op: "edit", op: "edit",

View File

@ -180,19 +180,18 @@ func mainAdminTierInfo(ctx *cli.Context) error {
checkAdminTierInfoSyntax(ctx) checkAdminTierInfoSyntax(ctx)
args := ctx.Args() args := ctx.Args()
aliasedURL := args.Get(0) aliasedURL := args.Get(0)
var err error
// Create a new MinIO Admin Client // Create a new MinIO Admin Client
client, cerr := newAdminClient(aliasedURL) client, cerr := newAdminClient(aliasedURL)
fatalIf(cerr, "Unable to initialize admin connection.") fatalIf(cerr, "Unable to initialize admin connection.")
var msg tierInfoMessage var msg tierInfoMessage
tInfos, err := client.TierStats(globalContext) tInfos, e := client.TierStats(globalContext)
if err != nil { if e != nil {
msg = tierInfoMessage{ msg = tierInfoMessage{
Status: "error", Status: "error",
Context: ctx, Context: ctx,
Error: err.Error(), Error: e.Error(),
} }
} else { } else {
msg = tierInfoMessage{ msg = tierInfoMessage{

View File

@ -178,10 +178,8 @@ func mainAdminTierList(ctx *cli.Context) error {
client, cerr := newAdminClient(aliasedURL) client, cerr := newAdminClient(aliasedURL)
fatalIf(cerr, "Unable to initialize admin connection.") fatalIf(cerr, "Unable to initialize admin connection.")
tiers, err := client.ListTiers(globalContext) tiers, e := client.ListTiers(globalContext)
if err != nil { fatalIf(probe.NewError(e).Trace(args...), "Unable to list configured remote tier targets")
fatalIf(probe.NewError(err).Trace(args...), "Unable to list configured remote tier targets")
}
printMsg(&tierListMessage{ printMsg(&tierListMessage{
Status: "success", Status: "success",

View File

@ -68,9 +68,8 @@ func mainAdminTierRm(ctx *cli.Context) error {
client, cerr := newAdminClient(aliasedURL) client, cerr := newAdminClient(aliasedURL)
fatalIf(cerr, "Unable to initialize admin connection.") fatalIf(cerr, "Unable to initialize admin connection.")
if err := client.RemoveTier(globalContext, tierName); err != nil { e := client.RemoveTier(globalContext, tierName)
fatalIf(probe.NewError(err).Trace(args...), "Unable to remove remote tier target") fatalIf(probe.NewError(e).Trace(args...), "Unable to remove remote tier target")
}
printMsg(&tierMessage{ printMsg(&tierMessage{
op: "rm", op: "rm",

View File

@ -68,9 +68,8 @@ func mainAdminTierVerify(ctx *cli.Context) error {
client, cerr := newAdminClient(aliasedURL) client, cerr := newAdminClient(aliasedURL)
fatalIf(cerr, "Unable to initialize admin connection.") fatalIf(cerr, "Unable to initialize admin connection.")
if err := client.VerifyTier(globalContext, tierName); err != nil { e := client.VerifyTier(globalContext, tierName)
fatalIf(probe.NewError(err).Trace(args...), "Unable to verify remote tier target") fatalIf(probe.NewError(e).Trace(args...), "Unable to verify remote tier target")
}
printMsg(&tierMessage{ printMsg(&tierMessage{
op: "verify", op: "verify",

View File

@ -136,7 +136,7 @@ func odCopy(ctx context.Context, odURLs URLs, args argKVS, odType string) (odMes
// Create reader from source. // Create reader from source.
reader, err := getSourceStreamFromURL(ctx, sourcePath, encKeyDB, getSourceOpts{GetOptions: getOpts}) reader, err := getSourceStreamFromURL(ctx, sourcePath, encKeyDB, getSourceOpts{GetOptions: getOpts})
fatalIf(err, "Unable to get source stream") fatalIf(err.Trace(sourcePath), "Unable to get source stream")
defer reader.Close() defer reader.Close()
putOpts := PutOptions{ putOpts := PutOptions{
@ -155,11 +155,11 @@ func odCopy(ctx context.Context, odURLs URLs, args argKVS, odType string) (odMes
// Write to target. // Write to target.
targetClnt, err := newClientFromAlias(targetAlias, targetURL.String()) targetClnt, err := newClientFromAlias(targetAlias, targetURL.String())
fatalIf(err, "Unable to initialize target client") fatalIf(err.Trace(targetURL.String()), "Unable to initialize target client")
// Put object. // Put object.
total, err := targetClnt.PutPart(ctx, reader, combinedSize, pg, putOpts) total, err := targetClnt.PutPart(ctx, reader, combinedSize, pg, putOpts)
fatalIf(err, "Unable to put object") fatalIf(err.Trace(targetURL.String()), "Unable to upload")
// Get upload time. // Get upload time.
elapsed := time.Since(pg.startTime) elapsed := time.Since(pg.startTime)
@ -242,7 +242,7 @@ func odDownload(ctx context.Context, odURLs URLs, args argKVS) (odMessage, error
// Upload the file. // Upload the file.
total, err := putTargetStream(ctx, "", targetPath, "", "", "", total, err := putTargetStream(ctx, "", targetPath, "", "", "",
reader, -1, pg, PutOptions{}) reader, -1, pg, PutOptions{})
fatalIf(err, "Unable to download object") fatalIf(err.Trace(targetPath), "Unable to upload an object")
// Get upload time. // Get upload time.
elapsed := time.Since(pg.startTime) elapsed := time.Since(pg.startTime)
@ -264,7 +264,7 @@ func odDownload(ctx context.Context, odURLs URLs, args argKVS) (odMessage, error
// singleGet helps odDownload download a single part. // singleGet helps odDownload download a single part.
func singleGet(ctx context.Context, cli Client) io.ReadCloser { func singleGet(ctx context.Context, cli Client) io.ReadCloser {
reader, err := cli.GetPart(ctx, 0) reader, err := cli.GetPart(ctx, 0)
fatalIf(err, "Unable to get object reader") fatalIf(err, "Unable to download object")
return reader return reader
} }
@ -276,7 +276,7 @@ func multiGet(ctx context.Context, cli Client, parts, skip int) io.Reader {
// Get reader for each part. // Get reader for each part.
for i := 1 + skip; i <= parts; i++ { for i := 1 + skip; i <= parts; i++ {
reader, err := cli.GetPart(ctx, parts) reader, err := cli.GetPart(ctx, parts)
fatalIf(err, "Unable to get object reader") fatalIf(err, "Unable to download part of an object")
readers = append(readers, reader) readers = append(readers, reader)
} }
reader := io.MultiReader(readers...) reader := io.MultiReader(readers...)

View File

@ -105,9 +105,9 @@ func checkSupportDiagSyntax(ctx *cli.Context) {
// compress and tar MinIO diagnostics output // compress and tar MinIO diagnostics output
func tarGZ(healthInfo interface{}, version string, filename string) error { func tarGZ(healthInfo interface{}, version string, filename string) error {
f, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, 0o666) f, e := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, 0o666)
if err != nil { if e != nil {
return err return e
} }
defer f.Close() defer f.Close()
@ -120,12 +120,12 @@ func tarGZ(healthInfo interface{}, version string, filename string) error {
Version string `json:"version"` Version string `json:"version"`
}{Version: version} }{Version: version}
if err := enc.Encode(header); err != nil { if e := enc.Encode(header); e != nil {
return err return e
} }
if err := enc.Encode(healthInfo); err != nil { if e := enc.Encode(healthInfo); e != nil {
return err return e
} }
if globalAirgapped { if globalAirgapped {
@ -355,12 +355,11 @@ func fetchServerDiagInfo(ctx *cli.Context, client *madmin.AdminClient) (interfac
admin(len(info.Minio.Info.Servers) > 0) admin(len(info.Minio.Info.Servers) > 0)
} }
var err error
// Fetch info of all servers (cluster or single server) // Fetch info of all servers (cluster or single server)
resp, version, err := client.ServerHealthInfo(cont, *opts, ctx.Duration("deadline")) resp, version, e := client.ServerHealthInfo(cont, *opts, ctx.Duration("deadline"))
if err != nil { if e != nil {
cancel() cancel()
return nil, "", err return nil, "", e
} }
var healthInfo interface{} var healthInfo interface{}
@ -370,9 +369,9 @@ func fetchServerDiagInfo(ctx *cli.Context, client *madmin.AdminClient) (interfac
case madmin.HealthInfoVersion0: case madmin.HealthInfoVersion0:
info := madmin.HealthInfoV0{} info := madmin.HealthInfoV0{}
for { for {
if err = decoder.Decode(&info); err != nil { if e = decoder.Decode(&info); e != nil {
if errors.Is(err, io.EOF) { if errors.Is(e, io.EOF) {
err = nil e = nil
} }
break break
@ -383,9 +382,9 @@ func fetchServerDiagInfo(ctx *cli.Context, client *madmin.AdminClient) (interfac
// Old minio versions don't return the MinIO info in // Old minio versions don't return the MinIO info in
// response of the healthinfo api. So fetch it separately // response of the healthinfo api. So fetch it separately
minioInfo, err := client.ServerInfo(globalContext) minioInfo, e := client.ServerInfo(globalContext)
if err != nil { if e != nil {
info.Minio.Error = err.Error() info.Minio.Error = e.Error()
} else { } else {
info.Minio.Info = minioInfo info.Minio.Info = minioInfo
} }
@ -395,9 +394,9 @@ func fetchServerDiagInfo(ctx *cli.Context, client *madmin.AdminClient) (interfac
case madmin.HealthInfoVersion2: case madmin.HealthInfoVersion2:
info := madmin.HealthInfoV2{} info := madmin.HealthInfoV2{}
for { for {
if err = decoder.Decode(&info); err != nil { if e = decoder.Decode(&info); e != nil {
if errors.Is(err, io.EOF) { if errors.Is(e, io.EOF) {
err = nil e = nil
} }
break break
@ -409,9 +408,9 @@ func fetchServerDiagInfo(ctx *cli.Context, client *madmin.AdminClient) (interfac
case madmin.HealthInfoVersion: case madmin.HealthInfoVersion:
info := madmin.HealthInfo{} info := madmin.HealthInfo{}
for { for {
if err = decoder.Decode(&info); err != nil { if e = decoder.Decode(&info); e != nil {
if errors.Is(err, io.EOF) { if errors.Is(e, io.EOF) {
err = nil e = nil
} }
break break
@ -422,9 +421,9 @@ func fetchServerDiagInfo(ctx *cli.Context, client *madmin.AdminClient) (interfac
healthInfo = info healthInfo = info
} }
// cancel the context if obdChan has returned. // cancel the context if supportDiagChan has returned.
cancel() cancel()
return healthInfo, version, err return healthInfo, version, e
} }
// HealthDataTypeSlice is a typed list of health tests // HealthDataTypeSlice is a typed list of health tests
@ -433,8 +432,8 @@ type HealthDataTypeSlice []madmin.HealthDataType
// Set - sets the flag to the given value // Set - sets the flag to the given value
func (d *HealthDataTypeSlice) Set(value string) error { func (d *HealthDataTypeSlice) Set(value string) error {
for _, v := range strings.Split(value, ",") { for _, v := range strings.Split(value, ",") {
if obdData, ok := madmin.HealthDataTypesMap[strings.Trim(v, " ")]; ok { if supportDiagData, ok := madmin.HealthDataTypesMap[strings.Trim(v, " ")]; ok {
*d = append(*d, obdData) *d = append(*d, supportDiagData)
} else { } else {
return fmt.Errorf("valid options include %s", options.String()) return fmt.Errorf("valid options include %s", options.String())
} }
@ -445,14 +444,14 @@ func (d *HealthDataTypeSlice) Set(value string) error {
// String - returns the string representation of the health datatypes // String - returns the string representation of the health datatypes
func (d *HealthDataTypeSlice) String() string { func (d *HealthDataTypeSlice) String() string {
val := "" val := ""
for _, obdData := range *d { for _, supportDiagData := range *d {
formatStr := "%s" formatStr := "%s"
if val != "" { if val != "" {
formatStr = fmt.Sprintf("%s,%%s", formatStr) formatStr = fmt.Sprintf("%s,%%s", formatStr)
} else { } else {
formatStr = fmt.Sprintf("%s%%s", formatStr) formatStr = fmt.Sprintf("%s%%s", formatStr)
} }
val = fmt.Sprintf(formatStr, val, string(obdData)) val = fmt.Sprintf(formatStr, val, string(supportDiagData))
} }
return val return val
} }
@ -518,8 +517,8 @@ func (f HealthDataTypeFlag) ApplyWithError(set *flag.FlagSet) error {
newVal := &HealthDataTypeSlice{} newVal := &HealthDataTypeSlice{}
for _, s := range strings.Split(envVal, ",") { for _, s := range strings.Split(envVal, ",") {
s = strings.TrimSpace(s) s = strings.TrimSpace(s)
if err := newVal.Set(s); err != nil { if e := newVal.Set(s); e != nil {
return fmt.Errorf("could not parse %s as health datatype value for flag %s: %s", envVal, f.Name, err) return fmt.Errorf("could not parse %s as health datatype value for flag %s: %s", envVal, f.Name, e)
} }
} }
f.Value = newVal f.Value = newVal

View File

@ -121,11 +121,11 @@ func mainSupportInspect(ctx *cli.Context) error {
console.Infoln("Your shell is auto determined as '" + shellName + "', wildcard patterns are only supported with 'bash' SHELL.") console.Infoln("Your shell is auto determined as '" + shellName + "', wildcard patterns are only supported with 'bash' SHELL.")
} }
key, r, ierr := client.Inspect(context.Background(), madmin.InspectOptions{ key, r, e := client.Inspect(context.Background(), madmin.InspectOptions{
Volume: bucket, Volume: bucket,
File: prefix, File: prefix,
}) })
fatalIf(probe.NewError(ierr).Trace(aliasedURL), "Unable to inspect file.") fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to inspect file.")
// Create profile zip file // Create profile zip file
tmpFile, e := ioutil.TempFile("", "mc-inspect-") tmpFile, e := ioutil.TempFile("", "mc-inspect-")

View File

@ -60,17 +60,17 @@ func mainAdminSpeedTestDrive(ctx *cli.Context, aliasedURL string) error {
serial := ctx.Bool("serial") serial := ctx.Bool("serial")
resultCh, speedTestErr := client.DriveSpeedtest(ctxt, madmin.DriveSpeedTestOpts{ resultCh, e := client.DriveSpeedtest(ctxt, madmin.DriveSpeedTestOpts{
Serial: serial, Serial: serial,
BlockSize: uint64(blocksize), BlockSize: uint64(blocksize),
FileSize: uint64(filesize), FileSize: uint64(filesize),
}) })
if globalJSON { if globalJSON {
if speedTestErr != nil { if e != nil {
printMsg(speedTestResult{ printMsg(speedTestResult{
Type: driveSpeedTest, Type: driveSpeedTest,
Err: speedTestErr.Error(), Err: e.Error(),
Final: true, Final: true,
}) })
return nil return nil
@ -102,10 +102,10 @@ func mainAdminSpeedTestDrive(ctx *cli.Context, aliasedURL string) error {
}() }()
go func() { go func() {
if speedTestErr != nil { if e != nil {
printMsg(speedTestResult{ printMsg(speedTestResult{
Type: driveSpeedTest, Type: driveSpeedTest,
Err: speedTestErr.Error(), Err: e.Error(),
}) })
return return
} }

View File

@ -54,19 +54,19 @@ func mainAdminSpeedTestNetperf(ctx *cli.Context, aliasedURL string) error {
defer close(resultCh) defer close(resultCh)
defer close(errorCh) defer close(errorCh)
result, err := client.Netperf(ctxt, duration) result, e := client.Netperf(ctxt, duration)
if err != nil { if e != nil {
errorCh <- err errorCh <- e
} }
resultCh <- result resultCh <- result
}() }()
if globalJSON { if globalJSON {
select { select {
case err := <-errorCh: case e := <-errorCh:
printMsg(speedTestResult{ printMsg(speedTestResult{
Type: netSpeedTest, Type: netSpeedTest,
Err: err.Error(), Err: e.Error(),
Final: true, Final: true,
}) })
case result := <-resultCh: case result := <-resultCh:
@ -92,10 +92,10 @@ func mainAdminSpeedTestNetperf(ctx *cli.Context, aliasedURL string) error {
go func() { go func() {
for { for {
select { select {
case err := <-errorCh: case e := <-errorCh:
p.Send(speedTestResult{ p.Send(speedTestResult{
Type: netSpeedTest, Type: netSpeedTest,
Err: err.Error(), Err: e.Error(),
Final: true, Final: true,
}) })
return return

View File

@ -85,7 +85,7 @@ func mainAdminSpeedTestObject(ctx *cli.Context, aliasedURL string) error {
// in all other scenarios keep auto-tuning on. // in all other scenarios keep auto-tuning on.
autotune := !ctx.IsSet("concurrent") autotune := !ctx.IsSet("concurrent")
resultCh, speedTestErr := client.Speedtest(ctxt, madmin.SpeedtestOpts{ resultCh, e := client.Speedtest(ctxt, madmin.SpeedtestOpts{
Size: int(size), Size: int(size),
Duration: duration, Duration: duration,
Concurrency: concurrent, Concurrency: concurrent,
@ -94,10 +94,10 @@ func mainAdminSpeedTestObject(ctx *cli.Context, aliasedURL string) error {
}) })
if globalJSON { if globalJSON {
if speedTestErr != nil { if e != nil {
printMsg(speedTestResult{ printMsg(speedTestResult{
Type: objectSpeedTest, Type: objectSpeedTest,
Err: speedTestErr.Error(), Err: e.Error(),
Final: true, Final: true,
}) })
return nil return nil
@ -134,10 +134,10 @@ func mainAdminSpeedTestObject(ctx *cli.Context, aliasedURL string) error {
}() }()
go func() { go func() {
if speedTestErr != nil { if e != nil {
p.Send(speedTestResult{ p.Send(speedTestResult{
Type: objectSpeedTest, Type: objectSpeedTest,
Err: speedTestErr.Error(), Err: e.Error(),
Final: true, Final: true,
}) })
return return

View File

@ -180,9 +180,9 @@ func mainSupportProfile(ctx *cli.Context) error {
} }
console.Infof("Profiling '%s' for %d seconds... ", aliasedURL, duration) console.Infof("Profiling '%s' for %d seconds... ", aliasedURL, duration)
data, adminErr := client.Profile(globalContext, madmin.ProfilerType(profilers), time.Second*time.Duration(duration)) data, e := client.Profile(globalContext, madmin.ProfilerType(profilers), time.Second*time.Duration(duration))
fatalIf(probe.NewError(adminErr), "Unable to save profile data") fatalIf(probe.NewError(e), "Unable to save profile data")
clr := color.New(color.FgGreen, color.Bold) clr := color.New(color.FgGreen, color.Bold)
clr.Printf("saved successfully at '%s'\n", getProfileData(data)) clr.Printf("saved successfully at '%s'\n", getProfileData(data))
return nil return nil