Skip to content

Commit

Permalink
Fix warnings (#5023)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramondeklein authored Aug 15, 2024
1 parent b34cd74 commit 479171e
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions cmd/admin-prometheus-metrics-v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ func validateV3Args(subsys string, bucket string) {
if len(bucket) > 0 {
bms := strings.Join(bucketMetricsSubSystems.ToSlice(), ", ")
if len(subsys) == 0 {
fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("metric type must be passed with --bucket. valid values are `"+bms+"`"))
fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("metric type must be passed with --bucket. valid values are `%s`", bms))
}

if !bucketMetricsSubSystems.Contains(subsys) {
fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("--bucket is applicable only for metric types `"+bms+"`"))
fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("--bucket is applicable only for metric types `%s`", bms))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/anonymous-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func runAnonymousLinksCmd(args cli.Args, recursive bool) {

// Encode public URL
u, e := url.Parse(content.URL.String())
errorIf(probe.NewError(e), "Unable to parse url `"+content.URL.String()+"`.")
errorIf(probe.NewError(e), "Unable to parse url `%s`.", content.URL)
publicURL := u.String()

// Construct the message to be displayed to the user
Expand Down
2 changes: 1 addition & 1 deletion cmd/cp-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ loop:
console.Eraseline()
}
errorIf(cpURLs.Error.Trace(cpURLs.SourceContent.URL.String()),
fmt.Sprintf("Failed to copy `%s`.", cpURLs.SourceContent.URL.String()))
"Failed to copy `%s`.", cpURLs.SourceContent.URL)
if isErrIgnored(cpURLs.Error) {
cpAllFilesErr = false
continue loop
Expand Down
4 changes: 2 additions & 2 deletions cmd/du-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func du(ctx context.Context, urlStr string, timeRef time.Time, withVersions bool

clnt, pErr := newClientFromAlias(targetAlias, targetURL)
if pErr != nil {
errorIf(pErr.Trace(urlStr), "Failed to summarize disk usage `"+urlStr+"`.")
errorIf(pErr.Trace(urlStr), "Failed to summarize disk usage `%s`.", urlStr)
return 0, 0, exitStatus(globalErrorExitStatus) // End of journey.
}

Expand Down Expand Up @@ -156,7 +156,7 @@ func du(ctx context.Context, urlStr string, timeRef time.Time, withVersions bool
errorIf(content.Err.Trace(clnt.GetURL().String()), "Unable to list folder.")
continue
}
errorIf(content.Err.Trace(urlStr), "Failed to find disk usage of `"+urlStr+"` recursively.")
errorIf(content.Err.Trace(urlStr), "Failed to find disk usage of `%s` recursively.", urlStr)
return 0, 0, exitStatus(globalErrorExitStatus)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/idp-ldap-accesskey-info.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func mainIDPLdapAccesskeyInfo(ctx *cli.Context) error {
// If not a service account must be sts
tempRes, e := client.TemporaryAccountInfo(globalContext, accessKey)
if e != nil {
errorIf(probe.NewError(e), "Unable to retrieve access key "+accessKey+" info.")
errorIf(probe.NewError(e), "Unable to retrieve access key %s info.", accessKey)
} else {
m := ldapAccesskeyMessage{
op: "info",
Expand Down
2 changes: 1 addition & 1 deletion cmd/legalhold-info.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func showLegalHoldInfo(ctx context.Context, urlStr, versionID string, timeRef ti
lhold, probeErr := newClnt.GetObjectLegalHold(ctx, content.VersionID)
if probeErr != nil {
errorsFound = true
errorIf(probeErr.Trace(content.URL.Path), "Failed to get legal hold information on `"+content.URL.Path+"`")
errorIf(probeErr.Trace(content.URL.Path), "Failed to get legal hold information on `%s`", content.URL.Path)
} else {
if !globalJSON {

Expand Down
4 changes: 2 additions & 2 deletions cmd/legalhold-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func setLegalHold(ctx context.Context, urlStr, versionID string, timeRef time.Ti
if !recursive && !withVersions {
err = clnt.PutObjectLegalHold(ctx, versionID, lhold)
if err != nil {
errorIf(err.Trace(urlStr), "Failed to set legal hold on `"+urlStr+"` successfully")
errorIf(err.Trace(urlStr), "Failed to set legal hold on `%s` successfully", urlStr)
} else {
contentURL := filepath.ToSlash(clnt.GetURL().Path)
key := strings.TrimPrefix(contentURL, prefixPath)
Expand Down Expand Up @@ -143,7 +143,7 @@ func setLegalHold(ctx context.Context, urlStr, versionID string, timeRef time.Ti

probeErr := newClnt.PutObjectLegalHold(ctx, content.VersionID, lhold)
if probeErr != nil {
errorIf(probeErr.Trace(content.URL.Path), "Failed to set legal hold on `"+content.URL.Path+"` successfully")
errorIf(probeErr.Trace(content.URL.Path), "Failed to set legal hold on `%s` successfully", content.URL.Path)
} else {
if !globalJSON {
contentURL := filepath.ToSlash(content.URL.Path)
Expand Down
4 changes: 2 additions & 2 deletions cmd/mb-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func mainMakeBucket(cliCtx *cli.Context) error {
// Instantiate client for URL.
clnt, err := newClient(targetURL)
if err != nil {
errorIf(err.Trace(targetURL), "Invalid target `"+targetURL+"`.")
errorIf(err.Trace(targetURL), "Invalid target `%s`.", targetURL)
cErr = exitStatus(globalErrorExitStatus)
continue
}
Expand All @@ -150,7 +150,7 @@ func mainMakeBucket(cliCtx *cli.Context) error {
case BucketNameEmpty:
errorIf(err.Trace(targetURL), "Unable to make bucket, please use `mc mb %s`.", urlJoinPath(targetURL, "your-bucket-name"))
default:
errorIf(err.Trace(targetURL), "Unable to make bucket `"+targetURL+"`.")
errorIf(err.Trace(targetURL), "Unable to make bucket `%s`.", targetURL)
}
cErr = exitStatus(globalErrorExitStatus)
continue
Expand Down
12 changes: 6 additions & 6 deletions cmd/mirror-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,16 @@ func (mj *mirrorJob) monitorMirrorStatus(cancel context.CancelFunc) (errDuringMi
if !ignoreErr {
if !mj.opts.skipErrors {
errorIf(sURLs.Error.Trace(sURLs.SourceContent.URL.String()),
fmt.Sprintf("Failed to copy `%s`.", sURLs.SourceContent.URL.String()))
"Failed to copy `%s`.", sURLs.SourceContent.URL)
} else {
console.Infof("[Warn] Failed to copy `%s`. %s", sURLs.SourceContent.URL.String(), sURLs.Error.Trace(sURLs.SourceContent.URL.String()))
console.Infof("[Warn] Failed to copy `%s`. %s", sURLs.SourceContent.URL, sURLs.Error.Trace(sURLs.SourceContent.URL.String()))
}
}
}
case sURLs.TargetContent != nil:
// When sURLs.SourceContent is nil, we know that we have an error related to removing
errorIf(sURLs.Error.Trace(sURLs.TargetContent.URL.String()),
fmt.Sprintf("Failed to remove `%s`.", sURLs.TargetContent.URL.String()))
"Failed to remove `%s`.", sURLs.TargetContent.URL.String())
default:
if strings.Contains(sURLs.Error.ToGoError().Error(), "Overwrite not allowed") {
ignoreErr = true
Expand Down Expand Up @@ -1055,14 +1055,14 @@ func runMirror(ctx context.Context, srcURL, dstURL string, cli *cli.Context, enc

// Bucket only exists in the source, create the same bucket in the destination
if err := newDstClt.MakeBucket(ctx, cli.String("region"), false, withLock); err != nil {
errorIf(err, "Unable to create bucket at `"+newTgtURL+"`.")
errorIf(err, "Unable to create bucket at `%s`.", newTgtURL)
continue
}
if preserve && mirrorBucketsToBuckets {
// object lock configuration set on bucket
if mode != "" {
err = newDstClt.SetObjectLockConfig(ctx, mode, validity, unit)
errorIf(err, "Unable to set object lock config in `"+newTgtURL+"`.")
errorIf(err, "Unable to set object lock config in `%s`.", newTgtURL)
if err != nil && mj.opts.activeActive {
return true
}
Expand All @@ -1071,7 +1071,7 @@ func runMirror(ctx context.Context, srcURL, dstURL string, cli *cli.Context, enc
}
}
errorIf(copyBucketPolicies(ctx, newSrcClt, newDstClt, isOverwrite),
"Unable to copy bucket policies to `"+newDstClt.GetURL().String()+"`.")
"Unable to copy bucket policies to `%s`.", newDstClt.GetURL())
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/mv-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (rm *removeManager) readErrors(resultCh <-chan RemoveResult, targetURL stri
defer rm.wg.Done()
for result := range resultCh {
if result.Err != nil {
errorIf(result.Err.Trace(targetURL), "Failed to remove in`"+targetURL+"`.")
errorIf(result.Err.Trace(targetURL), "Failed to remove in `%s`.", targetURL)
}
}
}()
Expand All @@ -164,7 +164,7 @@ func (rm *removeManager) add(ctx context.Context, targetAlias, targetURL string)
if clientInfo == nil {
client, pErr := newClientFromAlias(targetAlias, targetURL)
if pErr != nil {
errorIf(pErr.Trace(targetURL), "Invalid argument `"+targetURL+"`.")
errorIf(pErr.Trace(targetURL), "Invalid argument `%s`.", targetURL)
return
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/rb-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func mainRemoveBucket(cliCtx *cli.Context) error {
// Instantiate client for URL.
clnt, err := newClient(targetURL)
if err != nil {
errorIf(err.Trace(targetURL), "Invalid target `"+targetURL+"`.")
errorIf(err.Trace(targetURL), "Invalid target `%s`.", targetURL)
cErr = exitStatus(globalErrorExitStatus)
continue
}
Expand All @@ -262,11 +262,11 @@ func mainRemoveBucket(cliCtx *cli.Context) error {
if isForce {
continue
}
errorIf(err.Trace(targetURL), "Unable to validate target `"+targetURL+"`.")
errorIf(err.Trace(targetURL), "Unable to validate target `%s`.", targetURL)
cErr = exitStatus(globalErrorExitStatus)
continue
default:
errorIf(err.Trace(targetURL), "Unable to validate target `"+targetURL+"`.")
errorIf(err.Trace(targetURL), "Unable to validate target `%s`.", targetURL)
cErr = exitStatus(globalErrorExitStatus)
continue
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/retention-common.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func applyRetention(ctx context.Context, op lockOpType, target, versionID string
}

if !atLeastOneRetentionApplied {
errorIf(errDummy().Trace(clnt.GetURL().String()), "Unable to find any object/version to "+string(op)+" its retention.")
errorIf(errDummy().Trace(clnt.GetURL().String()), "Unable to find any object/version to %s its retention.", op)
cErr = exitStatus(globalErrorExitStatus) // Set the exit status.
}

Expand Down
22 changes: 11 additions & 11 deletions cmd/rm-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func removeSingle(url, versionID string, opts removeOpts) error {
_, ok := pErr.ToGoError().(ObjectMissing)
ignoreStatError = (st == http.StatusServiceUnavailable || ok || st == http.StatusNotFound) && (opts.isForce && opts.isForceDel)
if !ignoreStatError {
errorIf(pErr.Trace(url), "Failed to remove `"+url+"`.")
errorIf(pErr.Trace(url), "Failed to remove `%s`.", url)
return exitStatus(globalErrorExitStatus)
}
}
Expand All @@ -330,7 +330,7 @@ func removeSingle(url, versionID string, opts removeOpts) error {

// We should not proceed
if ignoreStatError && (opts.olderThan != "" || opts.newerThan != "") {
errorIf(pErr.Trace(url), "Unable to stat `"+url+"`.")
errorIf(pErr.Trace(url), "Unable to stat `%s`.", url)
return exitStatus(globalErrorExitStatus)
}

Expand All @@ -352,7 +352,7 @@ func removeSingle(url, versionID string, opts removeOpts) error {

clnt, pErr := newClientFromAlias(targetAlias, targetURL)
if pErr != nil {
errorIf(pErr.Trace(url), "Invalid argument `"+url+"`.")
errorIf(pErr.Trace(url), "Invalid argument `%s`.", url)
return exitStatus(globalErrorExitStatus) // End of journey.
}

Expand All @@ -368,7 +368,7 @@ func removeSingle(url, versionID string, opts removeOpts) error {
resultCh := clnt.Remove(ctx, opts.isIncomplete, isRemoveBucket, opts.isBypass, opts.isForce && opts.isForceDel, contentCh)
for result := range resultCh {
if result.Err != nil {
errorIf(result.Err.Trace(url), "Failed to remove `"+url+"`.")
errorIf(result.Err.Trace(url), "Failed to remove `%s`.", url)
switch result.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
Expand Down Expand Up @@ -431,7 +431,7 @@ func listAndRemove(url string, opts removeOpts) error {
targetAlias, targetURL, _ := mustExpandAlias(url)
clnt, pErr := newClientFromAlias(targetAlias, targetURL)
if pErr != nil {
errorIf(pErr.Trace(url), "Failed to remove `"+url+"` recursively.")
errorIf(pErr.Trace(url), "Failed to remove `%s` recursively.", url)
return exitStatus(globalErrorExitStatus) // End of journey.
}
contentCh := make(chan *ClientContent)
Expand All @@ -451,7 +451,7 @@ func listAndRemove(url string, opts removeOpts) error {
var perObjectVersions []*ClientContent
for content := range clnt.List(ctx, listOpts) {
if content.Err != nil {
errorIf(content.Err.Trace(url), "Failed to remove `"+url+"` recursively.")
errorIf(content.Err.Trace(url), "Failed to remove `%s` recursively.", url)
switch content.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
Expand Down Expand Up @@ -512,7 +512,7 @@ func listAndRemove(url string, opts removeOpts) error {
path := path.Join(targetAlias, result.BucketName, result.ObjectName)
if result.Err != nil {
errorIf(result.Err.Trace(path),
"Failed to remove `"+path+"`.")
"Failed to remove `%s`.", path)
switch result.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
Expand Down Expand Up @@ -570,7 +570,7 @@ func listAndRemove(url string, opts removeOpts) error {
path := path.Join(targetAlias, result.BucketName, result.ObjectName)
if result.Err != nil {
errorIf(result.Err.Trace(path),
"Failed to remove `"+path+"`.")
"Failed to remove `%s`.", path)
switch e := result.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
Expand Down Expand Up @@ -633,7 +633,7 @@ func listAndRemove(url string, opts removeOpts) error {
path := path.Join(targetAlias, result.BucketName, result.ObjectName)
if result.Err != nil {
errorIf(result.Err.Trace(path),
"Failed to remove `"+path+"`.")
"Failed to remove `%s`.", path)
switch result.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
Expand Down Expand Up @@ -663,7 +663,7 @@ func listAndRemove(url string, opts removeOpts) error {
for result := range resultCh {
path := path.Join(targetAlias, result.BucketName, result.ObjectName)
if result.Err != nil {
errorIf(result.Err.Trace(path), "Failed to remove `"+path+"` recursively.")
errorIf(result.Err.Trace(path), "Failed to remove `%s` recursively.", path)
switch result.Err.ToGoError().(type) {
case PathInsufficientPermission:
// Ignore Permission error.
Expand All @@ -688,7 +688,7 @@ func listAndRemove(url string, opts removeOpts) error {
// behavior and do not print an error as well.
return nil
}
errorIf(errDummy().Trace(url), "No object/version found to be removed in `"+url+"`.")
errorIf(errDummy().Trace(url), "No object/version found to be removed in `%s`.", url)
return exitStatus(globalErrorExitStatus)
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/sql-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func mainSQL(cliCtx *cli.Context) error {
writeHdr := true
for _, url := range URLs {
if _, targetContent, err := url2Stat(ctx, url2StatOptions{urlStr: url, versionID: "", fileAttr: false, encKeyDB: encKeyDB, timeRef: time.Time{}, isZip: false, ignoreBucketExistsCheck: false}); err != nil {
errorIf(err.Trace(url), "Unable to run sql for "+url+".")
errorIf(err.Trace(url), "Unable to run sql for %s.", url)
continue
} else if !targetContent.Type.IsDir() {
if writeHdr {
Expand All @@ -466,13 +466,13 @@ func mainSQL(cliCtx *cli.Context) error {
targetAlias, targetURL, _ := mustExpandAlias(url)
clnt, err := newClientFromAlias(targetAlias, targetURL)
if err != nil {
errorIf(err.Trace(url), "Unable to initialize target `"+url+"`.")
errorIf(err.Trace(url), "Unable to initialize target `%s`.", url)
continue
}

for content := range clnt.List(ctx, ListOptions{Recursive: cliCtx.Bool("recursive"), WithMetadata: true, ShowDir: DirNone}) {
if content.Err != nil {
errorIf(content.Err.Trace(url), "Unable to list on target `"+url+"`.")
errorIf(content.Err.Trace(url), "Unable to list on target `%s`.", url)
continue
}
if writeHdr {
Expand Down
8 changes: 4 additions & 4 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ func (qs *QuietStatus) Update() {
}

func (qs *QuietStatus) errorIf(err *probe.Error, msg string) {
errorIf(err, msg)
errorIf(err, "%s", msg)
}

func (qs *QuietStatus) fatalIf(err *probe.Error, msg string) {
fatalIf(err, msg)
fatalIf(err, "%s", msg)
}

// NewProgressStatus returns a progress status object
Expand Down Expand Up @@ -235,15 +235,15 @@ func (ps *ProgressStatus) Update() {
func (ps *ProgressStatus) errorIf(err *probe.Error, msg string) {
// remove progressbar
console.Eraseline()
errorIf(err, msg)
errorIf(err, "%s", msg)

ps.progressBar.Update()
}

func (ps *ProgressStatus) fatalIf(err *probe.Error, msg string) {
// remove progressbar
console.Eraseline()
fatalIf(err, msg)
fatalIf(err, "%s", msg)

ps.progressBar.Update()
}

0 comments on commit 479171e

Please sign in to comment.