Start using error wrapping with fmt.Errorf (#8588)

Use fatih/errwrap to fix all the code to use
error wrapping with fmt.Errorf()
This commit is contained in:
Harshavardhana 2019-12-02 09:28:01 -08:00 committed by GitHub
parent 0bfd20a8e3
commit 5d3d57c12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 113 additions and 112 deletions

View File

@ -117,7 +117,7 @@ func initFederatorBackend(buckets []BucketInfo, objLayer ObjectLayer) {
// We go to here, so we know the bucket no longer exists, but is registered in DNS to this server
if err := globalDNSConfig.DeleteRecord(dnsBuckets[index]); err != nil {
return fmt.Errorf("Failed to remove DNS entry for %s due to %v", dnsBuckets[index].Key, err)
return fmt.Errorf("Failed to remove DNS entry for %s due to %w", dnsBuckets[index].Key, err)
}
return nil

View File

@ -246,7 +246,7 @@ func purgeV1() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 1. %v", err)
return fmt.Errorf("Unable to load config version 1. %w", err)
}
if cv1.Version != "1" {
return fmt.Errorf("unrecognized config version %s", cv1.Version)
@ -267,7 +267,7 @@ func migrateV2ToV3() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 2. %v", err)
return fmt.Errorf("Unable to load config version 2. %w", err)
}
if cv2.Version != "2" {
return nil
@ -275,7 +275,7 @@ func migrateV2ToV3() error {
cred, err := auth.CreateCredentials(cv2.Credentials.AccessKey, cv2.Credentials.SecretKey)
if err != nil {
return fmt.Errorf("Invalid credential in V2 configuration file. %v", err)
return fmt.Errorf("Invalid credential in V2 configuration file. %w", err)
}
srvConfig := &configV3{}
@ -308,7 +308,7 @@ func migrateV2ToV3() error {
srvConfig.Logger.Syslog = slogger
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv2.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv2.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv2.Version, srvConfig.Version)
@ -326,7 +326,7 @@ func migrateV3ToV4() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 3. %v", err)
return fmt.Errorf("Unable to load config version 3. %w", err)
}
if cv3.Version != "3" {
return nil
@ -346,7 +346,7 @@ func migrateV3ToV4() error {
srvConfig.Logger.Syslog = cv3.Logger.Syslog
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv3.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv3.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv3.Version, srvConfig.Version)
@ -364,7 +364,7 @@ func migrateV4ToV5() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 4. %v", err)
return fmt.Errorf("Unable to load config version 4. %w", err)
}
if cv4.Version != "4" {
return nil
@ -387,7 +387,7 @@ func migrateV4ToV5() error {
srvConfig.Logger.Redis.Enable = false
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv4.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv4.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv4.Version, srvConfig.Version)
@ -405,7 +405,7 @@ func migrateV5ToV6() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 5. %v", err)
return fmt.Errorf("Unable to load config version 5. %w", err)
}
if cv5.Version != "5" {
return nil
@ -476,7 +476,7 @@ func migrateV5ToV6() error {
}
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv5.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv5.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv5.Version, srvConfig.Version)
@ -494,7 +494,7 @@ func migrateV6ToV7() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 6. %v", err)
return fmt.Errorf("Unable to load config version 6. %w", err)
}
if cv6.Version != "6" {
return nil
@ -532,7 +532,7 @@ func migrateV6ToV7() error {
}
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv6.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv6.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv6.Version, srvConfig.Version)
@ -550,7 +550,7 @@ func migrateV7ToV8() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 7. %v", err)
return fmt.Errorf("Unable to load config version 7. %w", err)
}
if cv7.Version != "7" {
return nil
@ -595,7 +595,7 @@ func migrateV7ToV8() error {
}
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv7.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv7.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv7.Version, srvConfig.Version)
@ -612,7 +612,7 @@ func migrateV8ToV9() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 8. %v", err)
return fmt.Errorf("Unable to load config version 8. %w", err)
}
if cv8.Version != "8" {
return nil
@ -665,7 +665,7 @@ func migrateV8ToV9() error {
}
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv8.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv8.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv8.Version, srvConfig.Version)
@ -682,7 +682,7 @@ func migrateV9ToV10() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 9. %v", err)
return fmt.Errorf("Unable to load config version 9. %w", err)
}
if cv9.Version != "9" {
return nil
@ -733,7 +733,7 @@ func migrateV9ToV10() error {
}
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv9.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv9.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv9.Version, srvConfig.Version)
@ -750,7 +750,7 @@ func migrateV10ToV11() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 10. %v", err)
return fmt.Errorf("Unable to load config version 10. %w", err)
}
if cv10.Version != "10" {
return nil
@ -804,7 +804,7 @@ func migrateV10ToV11() error {
srvConfig.Notify.Kafka["1"] = target.KafkaArgs{}
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv10.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv10.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv10.Version, srvConfig.Version)
@ -821,7 +821,7 @@ func migrateV11ToV12() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 11. %v", err)
return fmt.Errorf("Unable to load config version 11. %w", err)
}
if cv11.Version != "11" {
return nil
@ -902,7 +902,7 @@ func migrateV11ToV12() error {
}
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv11.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv11.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv11.Version, srvConfig.Version)
@ -918,7 +918,7 @@ func migrateV12ToV13() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 12. %v", err)
return fmt.Errorf("Unable to load config version 12. %w", err)
}
if cv12.Version != "12" {
return nil
@ -982,7 +982,7 @@ func migrateV12ToV13() error {
srvConfig.Notify.Webhook["1"] = target.WebhookArgs{}
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv12.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv12.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv12.Version, srvConfig.Version)
@ -998,7 +998,7 @@ func migrateV13ToV14() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 13. %v", err)
return fmt.Errorf("Unable to load config version 13. %w", err)
}
if cv13.Version != "13" {
return nil
@ -1067,7 +1067,7 @@ func migrateV13ToV14() error {
srvConfig.Browser = true
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv13.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv13.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv13.Version, srvConfig.Version)
@ -1083,7 +1083,7 @@ func migrateV14ToV15() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 14. %v", err)
return fmt.Errorf("Unable to load config version 14. %w", err)
}
if cv14.Version != "14" {
return nil
@ -1156,7 +1156,7 @@ func migrateV14ToV15() error {
srvConfig.Browser = cv14.Browser
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv14.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv14.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv14.Version, srvConfig.Version)
@ -1173,7 +1173,7 @@ func migrateV15ToV16() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 15. %v", err)
return fmt.Errorf("Unable to load config version 15. %w", err)
}
if cv15.Version != "15" {
return nil
@ -1246,7 +1246,7 @@ func migrateV15ToV16() error {
srvConfig.Browser = cv15.Browser
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv15.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv15.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv15.Version, srvConfig.Version)
@ -1263,7 +1263,7 @@ func migrateV16ToV17() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 16. %v", err)
return fmt.Errorf("Unable to load config version 16. %w", err)
}
if cv16.Version != "16" {
return nil
@ -1367,7 +1367,7 @@ func migrateV16ToV17() error {
srvConfig.Browser = cv16.Browser
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv16.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv16.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv16.Version, srvConfig.Version)
@ -1384,7 +1384,7 @@ func migrateV17ToV18() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 17. %v", err)
return fmt.Errorf("Unable to load config version 17. %w", err)
}
if cv17.Version != "17" {
return nil
@ -1471,7 +1471,7 @@ func migrateV17ToV18() error {
srvConfig.Browser = cv17.Browser
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv17.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv17.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv17.Version, srvConfig.Version)
@ -1486,7 +1486,7 @@ func migrateV18ToV19() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 18. %v", err)
return fmt.Errorf("Unable to load config version 18. %w", err)
}
if cv18.Version != "18" {
return nil
@ -1577,7 +1577,7 @@ func migrateV18ToV19() error {
srvConfig.Browser = cv18.Browser
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv18.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv18.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv18.Version, srvConfig.Version)
@ -1592,7 +1592,7 @@ func migrateV19ToV20() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 18. %v", err)
return fmt.Errorf("Unable to load config version 18. %w", err)
}
if cv19.Version != "19" {
return nil
@ -1682,7 +1682,7 @@ func migrateV19ToV20() error {
srvConfig.Browser = cv19.Browser
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv19.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv19.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv19.Version, srvConfig.Version)
@ -1697,7 +1697,7 @@ func migrateV20ToV21() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 20. %v", err)
return fmt.Errorf("Unable to load config version 20. %w", err)
}
if cv20.Version != "20" {
return nil
@ -1786,7 +1786,7 @@ func migrateV20ToV21() error {
srvConfig.Domain = cv20.Domain
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv20.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv20.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv20.Version, srvConfig.Version)
@ -1801,7 +1801,7 @@ func migrateV21ToV22() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 21. %v", err)
return fmt.Errorf("Unable to load config version 21. %w", err)
}
if cv21.Version != "21" {
return nil
@ -1890,7 +1890,7 @@ func migrateV21ToV22() error {
srvConfig.Domain = cv21.Domain
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv21.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv21.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv21.Version, srvConfig.Version)
@ -1905,7 +1905,7 @@ func migrateV22ToV23() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 22. %v", err)
return fmt.Errorf("Unable to load config version 22. %w", err)
}
if cv22.Version != "22" {
return nil
@ -2003,7 +2003,7 @@ func migrateV22ToV23() error {
srvConfig.Cache.Expiry = 90
if err = Save(configFile, srvConfig); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv22.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv22.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv22.Version, srvConfig.Version)
@ -2018,7 +2018,7 @@ func migrateV23ToV24() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 23. %v", err)
return fmt.Errorf("Unable to load config version 23. %w", err)
}
if cv23.Version != "23" {
return nil
@ -2116,7 +2116,7 @@ func migrateV23ToV24() error {
srvConfig.Cache.Expiry = cv23.Cache.Expiry
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv23.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv23.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv23.Version, srvConfig.Version)
@ -2131,7 +2131,7 @@ func migrateV24ToV25() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 24. %v", err)
return fmt.Errorf("Unable to load config version 24. %w", err)
}
if cv24.Version != "24" {
return nil
@ -2234,7 +2234,7 @@ func migrateV24ToV25() error {
srvConfig.Cache.Expiry = cv24.Cache.Expiry
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv24.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv24.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv24.Version, srvConfig.Version)
@ -2249,7 +2249,7 @@ func migrateV25ToV26() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config version 25. %v", err)
return fmt.Errorf("Unable to load config version 25. %w", err)
}
if cv25.Version != "25" {
return nil
@ -2353,7 +2353,7 @@ func migrateV25ToV26() error {
srvConfig.Cache.MaxUse = 80
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from %s to %s. %v", cv25.Version, srvConfig.Version, err)
return fmt.Errorf("Failed to migrate config from %s to %s. %w", cv25.Version, srvConfig.Version, err)
}
logger.Info(configMigrateMSGTemplate, configFile, cv25.Version, srvConfig.Version)
@ -2371,7 +2371,7 @@ func migrateV26ToV27() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err)
return fmt.Errorf("Unable to load config file. %w", err)
}
if srvConfig.Version != "26" {
@ -2386,7 +2386,7 @@ func migrateV26ToV27() error {
srvConfig.Logger.HTTP["1"] = logger.HTTP{}
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from 26 to 27. %v", err)
return fmt.Errorf("Failed to migrate config from 26 to 27. %w", err)
}
logger.Info(configMigrateMSGTemplate, configFile, "26", "27")
@ -2404,7 +2404,7 @@ func migrateV27ToV28() error {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err)
return fmt.Errorf("Unable to load config file. %w", err)
}
if srvConfig.Version != "27" {
@ -2414,7 +2414,7 @@ func migrateV27ToV28() error {
srvConfig.Version = "28"
srvConfig.KMS = crypto.KMSConfig{}
if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil {
return fmt.Errorf("Failed to migrate config from 27 to 28. %v", err)
return fmt.Errorf("Failed to migrate config from 27 to 28. %w", err)
}
logger.Info(configMigrateMSGTemplate, configFile, "27", "28")
@ -2534,7 +2534,7 @@ func migrateV27ToV28MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err)
return fmt.Errorf("Unable to load config file. %w", err)
}
if !ok {
return nil
@ -2549,7 +2549,7 @@ func migrateV27ToV28MinioSys(objAPI ObjectLayer) error {
cfg.KMS = crypto.KMSConfig{}
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from 27 to 28. %v", err)
return fmt.Errorf("Failed to migrate config from 27 to 28. %w", err)
}
logger.Info(configMigrateMSGTemplate, configFile, "27", "28")
@ -2563,7 +2563,7 @@ func migrateV28ToV29MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err)
return fmt.Errorf("Unable to load config file. %w", err)
}
if !ok {
return nil
@ -2576,7 +2576,7 @@ func migrateV28ToV29MinioSys(objAPI ObjectLayer) error {
cfg.Version = "29"
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from 28 to 29. %v", err)
return fmt.Errorf("Failed to migrate config from 28 to 29. %w", err)
}
logger.Info(configMigrateMSGTemplate, configFile, "28", "29")
@ -2590,7 +2590,7 @@ func migrateV29ToV30MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err)
return fmt.Errorf("Unable to load config file. %w", err)
}
if !ok {
return nil
@ -2608,7 +2608,7 @@ func migrateV29ToV30MinioSys(objAPI ObjectLayer) error {
cfg.Compression.MimeTypes = strings.Split(compress.DefaultMimeTypes, config.ValueSeparator)
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from 29 to 30. %v", err)
return fmt.Errorf("Failed to migrate config from 29 to 30. %w", err)
}
logger.Info(configMigrateMSGTemplate, configFile, "29", "30")
@ -2622,7 +2622,7 @@ func migrateV30ToV31MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err)
return fmt.Errorf("Unable to load config file. %w", err)
}
if !ok {
return nil
@ -2643,7 +2643,7 @@ func migrateV30ToV31MinioSys(objAPI ObjectLayer) error {
}
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from 30 to 31. %v", err)
return fmt.Errorf("Failed to migrate config from 30 to 31. %w", err)
}
logger.Info(configMigrateMSGTemplate, configFile, "30", "31")
@ -2657,7 +2657,7 @@ func migrateV31ToV32MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err)
return fmt.Errorf("Unable to load config file. %w", err)
}
if !ok {
return nil
@ -2673,7 +2673,7 @@ func migrateV31ToV32MinioSys(objAPI ObjectLayer) error {
cfg.Notify.NSQ["1"] = target.NSQArgs{}
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from 31 to 32. %v", err)
return fmt.Errorf("Failed to migrate config from 31 to 32. %w", err)
}
logger.Info(configMigrateMSGTemplate, configFile, "31", "32")
@ -2687,7 +2687,7 @@ func migrateV32ToV33MinioSys(objAPI ObjectLayer) error {
if err == errConfigNotFound {
return nil
} else if err != nil {
return fmt.Errorf("Unable to load config file. %v", err)
return fmt.Errorf("Unable to load config file. %w", err)
}
if !ok {
return nil
@ -2701,7 +2701,7 @@ func migrateV32ToV33MinioSys(objAPI ObjectLayer) error {
cfg.Version = "33"
if err = saveServerConfig(context.Background(), objAPI, cfg); err != nil {
return fmt.Errorf("Failed to migrate config from '32' to '33' . %v", err)
return fmt.Errorf("Failed to migrate config from '32' to '33' . %w", err)
}
logger.Info(configMigrateMSGTemplate, configFile, "32", "33")

View File

@ -124,7 +124,7 @@ type diskCache struct {
// Inits the disk cache dir if it is not initialized already.
func newDiskCache(dir string, expiry int, quotaPct int) (*diskCache, error) {
if err := os.MkdirAll(dir, 0777); err != nil {
return nil, fmt.Errorf("Unable to initialize '%s' dir, %s", dir, err)
return nil, fmt.Errorf("Unable to initialize '%s' dir, %w", dir, err)
}
cache := diskCache{
dir: dir,

View File

@ -118,7 +118,7 @@ func NewEndpoint(arg string) (ep Endpoint, e error) {
host, port, err = net.SplitHostPort(u.Host)
if err != nil {
if !strings.Contains(err.Error(), "missing port in address") {
return ep, fmt.Errorf("invalid URL endpoint format: %s", err)
return ep, fmt.Errorf("invalid URL endpoint format: %w", err)
}
host = u.Host

View File

@ -32,9 +32,9 @@ func etcdErrToErr(err error, etcdEndpoints []string) error {
}
switch err {
case context.DeadlineExceeded:
return fmt.Errorf("%s %s", errEtcdUnreachable, etcdEndpoints)
return fmt.Errorf("%w %s", errEtcdUnreachable, etcdEndpoints)
default:
return fmt.Errorf("unexpected error %s from etcd, please check your endpoints %s", err, etcdEndpoints)
return fmt.Errorf("unexpected error %w from etcd, please check your endpoints %s", err, etcdEndpoints)
}
}

View File

@ -489,7 +489,7 @@ func formatXLFixDeploymentID(endpoints Endpoints, storageDisks []StorageAPI, ref
formats, sErrs := loadFormatXLAll(storageDisks)
for i, sErr := range sErrs {
if _, ok := formatCriticalErrors[sErr]; ok {
return fmt.Errorf("Disk %s: %s", endpoints[i], sErr)
return fmt.Errorf("Disk %s: %w", endpoints[i], sErr)
}
}
@ -547,7 +547,7 @@ func formatXLFixLocalDeploymentID(endpoints Endpoints, storageDisks []StorageAPI
format.ID = refFormat.ID
if err := saveFormatXL(storageDisk, format); err != nil {
logger.LogIf(context.Background(), err)
return fmt.Errorf("Unable to save format.json, %s", err)
return fmt.Errorf("Unable to save format.json, %w", err)
}
}
}
@ -747,7 +747,7 @@ func initFormatXL(ctx context.Context, storageDisks []StorageAPI, setCount, driv
// Initialize meta volume, if volume already exists ignores it.
if err := initFormatXLMetaVolume(storageDisks, formats); err != nil {
return format, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %s", err)
return format, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %w", err)
}
// Save formats `format.json` across all disks.

View File

@ -237,8 +237,9 @@ func testPutObjectPartDiskNotFound(obj ObjectLayer, instanceType string, disks [
if err == nil {
t.Fatalf("Test %s: expected to fail but passed instead", instanceType)
}
// as majority of xl.json are not available, we expect uploadID to be not available.
expectedErr1 := InsufficientReadQuorum{}
expectedErr1 := BucketNotFound{Bucket: testCase.bucketName}
if err.Error() != expectedErr1.Error() {
t.Fatalf("Test %s: expected error %s, got %s instead.", instanceType, expectedErr1, err)
}
@ -255,8 +256,8 @@ func testPutObjectPartDiskNotFound(obj ObjectLayer, instanceType string, disks [
}
// As all disks at not available, bucket not found.
expectedErr2 := errDiskNotFound
if err != errDiskNotFound {
expectedErr2 := BucketNotFound{Bucket: testCase.bucketName}
if err.Error() != expectedErr2.Error() {
t.Fatalf("Test %s: expected error %s, got %s instead.", instanceType, expectedErr2, err)
}
}

View File

@ -139,7 +139,7 @@ func renameAll(srcFilePath, dstFilePath string) (err error) {
// directory" error message. Handle this specifically here.
return errFileAccessDenied
case isSysErrCrossDevice(err):
return fmt.Errorf("%s (%s)->(%s)", errCrossDeviceLink, srcFilePath, dstFilePath)
return fmt.Errorf("%w (%s)->(%s)", errCrossDeviceLink, srcFilePath, dstFilePath)
case os.IsNotExist(err):
return errFileNotFound
case os.IsExist(err):

View File

@ -1351,7 +1351,7 @@ func TestPosixFormatFileChange(t *testing.T) {
}
err = posixStorage.MakeVol(volume)
if err != errDiskNotFound {
if err != errVolumeExists {
t.Fatalf("MakeVol expected to fail with errDiskNotFound but failed with %s", err)
}
}

View File

@ -67,7 +67,7 @@ func formatXLMigrateLocalEndpoints(endpoints Endpoints) error {
if os.IsNotExist(err) {
return nil
}
return fmt.Errorf("unable to access (%s) %s", formatPath, err)
return fmt.Errorf("unable to access (%s) %w", formatPath, err)
}
return formatXLMigrate(epPath)
}, index)
@ -96,11 +96,11 @@ func formatXLCleanupTmpLocalEndpoints(endpoints Endpoints) error {
if os.IsNotExist(err) {
return nil
}
return fmt.Errorf("unable to access (%s) %s", formatPath, err)
return fmt.Errorf("unable to access (%s) %w", formatPath, err)
}
if _, err := os.Stat(pathJoin(epPath, minioMetaTmpBucket+"-old")); err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("unable to access (%s) %s",
return fmt.Errorf("unable to access (%s) %w",
pathJoin(epPath, minioMetaTmpBucket+"-old"),
err)
}
@ -119,7 +119,7 @@ func formatXLCleanupTmpLocalEndpoints(endpoints Endpoints) error {
tmpOld := pathJoin(epPath, minioMetaTmpBucket+"-old", mustGetUUID())
if err := renameAll(pathJoin(epPath, minioMetaTmpBucket),
tmpOld); err != nil && err != errFileNotFound {
return fmt.Errorf("unable to rename (%s -> %s) %s",
return fmt.Errorf("unable to rename (%s -> %s) %w",
pathJoin(epPath, minioMetaTmpBucket),
tmpOld,
err)
@ -129,7 +129,7 @@ func formatXLCleanupTmpLocalEndpoints(endpoints Endpoints) error {
go removeAll(pathJoin(epPath, minioMetaTmpBucket+"-old"))
if err := mkdirAll(pathJoin(epPath, minioMetaTmpBucket), 0777); err != nil {
return fmt.Errorf("unable to create (%s) %s",
return fmt.Errorf("unable to create (%s) %w",
pathJoin(epPath, minioMetaTmpBucket),
err)
}
@ -151,7 +151,7 @@ func validateXLFormats(format *formatXLV3, formats []*formatXLV3, endpoints Endp
continue
}
if err := formatXLV3Check(format, formats[i]); err != nil {
return fmt.Errorf("%s format error: %s", endpoints[i], err)
return fmt.Errorf("%s format error: %w", endpoints[i], err)
}
}
if len(format.XL.Sets) != setCount {
@ -189,7 +189,7 @@ func connectLoadInitFormats(retryCount int, firstDisk bool, endpoints Endpoints,
// Check if we have
for i, sErr := range sErrs {
if _, ok := formatCriticalErrors[sErr]; ok {
return nil, fmt.Errorf("Disk %s: %s", endpoints[i], sErr)
return nil, fmt.Errorf("Disk %s: %w", endpoints[i], sErr)
}
}

View File

@ -234,7 +234,7 @@ func initSafeModeInit(buckets []BucketInfo) (err error) {
// Migrate all backend configs to encrypted backend, also handles rotation as well.
if err = handleEncryptedConfigBackend(newObject, true); err != nil {
return fmt.Errorf("Unable to handle encrypted backend for config, iam and policies: %v", err)
return fmt.Errorf("Unable to handle encrypted backend for config, iam and policies: %w", err)
}
// **** WARNING ****
@ -264,7 +264,7 @@ func initAllSubsystems(buckets []BucketInfo, newObject ObjectLayer) (err error)
// Migrating to encrypted backend on etcd should happen before initialization of
// IAM sub-systems, make sure that we do not move the above codeblock elsewhere.
if err = migrateIAMConfigsEtcdToEncrypted(globalEtcdClient); err != nil {
return fmt.Errorf("Unable to handle encrypted backend for iam and policies: %v", err)
return fmt.Errorf("Unable to handle encrypted backend for iam and policies: %w", err)
}
}
@ -284,7 +284,7 @@ func initAllSubsystems(buckets []BucketInfo, newObject ObjectLayer) (err error)
// Initialize lifecycle system.
if err = globalLifecycleSys.Init(buckets, newObject); err != nil {
return fmt.Errorf("Unable to initialize lifecycle system: %v", err)
return fmt.Errorf("Unable to initialize lifecycle system: %w", err)
}
return nil

View File

@ -476,11 +476,11 @@ func (sts *stsAPIHandlers) AssumeRoleWithLDAPIdentity(w http.ResponseWriter, r *
ldapConn, err := globalLDAPConfig.Connect()
if err != nil {
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP server connection failure: %v", err))
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP server connection failure: %w", err))
return
}
if ldapConn == nil {
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP server not configured: %v", err))
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP server not configured: %w", err))
return
}
@ -490,7 +490,7 @@ func (sts *stsAPIHandlers) AssumeRoleWithLDAPIdentity(w http.ResponseWriter, r *
usernameDN, _ := usernameSubs.Substitute(globalLDAPConfig.UsernameFormat)
// Bind with user credentials to validate the password
if err = ldapConn.Bind(usernameDN, ldapPassword); err != nil {
err = fmt.Errorf("LDAP authentication failure: %v", err)
err = fmt.Errorf("LDAP authentication failure: %w", err)
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, err)
return
}
@ -517,7 +517,7 @@ func (sts *stsAPIHandlers) AssumeRoleWithLDAPIdentity(w http.ResponseWriter, r *
sr, err := ldapConn.Search(searchRequest)
if err != nil {
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP search failure: %v", err))
writeSTSErrorResponse(ctx, w, ErrSTSInvalidParameterValue, fmt.Errorf("LDAP search failure: %w", err))
return
}
for _, entry := range sr.Entries {

View File

@ -2220,7 +2220,7 @@ func generateTLSCertKey(host string) ([]byte, []byte, error) {
var err error
priv, err = rsa.GenerateKey(crand.Reader, rsaBits)
if err != nil {
return nil, nil, fmt.Errorf("failed to generate private key: %s", err)
return nil, nil, fmt.Errorf("failed to generate private key: %w", err)
}
notBefore := time.Now()
@ -2229,7 +2229,7 @@ func generateTLSCertKey(host string) ([]byte, []byte, error) {
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := crand.Int(crand.Reader, serialNumberLimit)
if err != nil {
return nil, nil, fmt.Errorf("failed to generate serial number: %s", err)
return nil, nil, fmt.Errorf("failed to generate serial number: %w", err)
}
template := x509.Certificate{
@ -2259,7 +2259,7 @@ func generateTLSCertKey(host string) ([]byte, []byte, error) {
derBytes, err := x509.CreateCertificate(crand.Reader, &template, &template, publicKey(priv), priv)
if err != nil {
return nil, nil, fmt.Errorf("Failed to create certificate: %s", err)
return nil, nil, fmt.Errorf("Failed to create certificate: %w", err)
}
certOut := bytes.NewBuffer([]byte{})

View File

@ -95,14 +95,14 @@ func getModTime(path string) (t time.Time, err error) {
// Convert to absolute path
absPath, err := filepath.Abs(path)
if err != nil {
return t, fmt.Errorf("Unable to get absolute path of %s. %s", path, err)
return t, fmt.Errorf("Unable to get absolute path of %s. %w", path, err)
}
// Version is minio non-standard, we will use minio binary's
// ModTime as release time.
fi, err := os.Stat(absPath)
if err != nil {
return t, fmt.Errorf("Unable to get ModTime of %s. %s", absPath, err)
return t, fmt.Errorf("Unable to get ModTime of %s. %w", absPath, err)
}
// Return the ModTime
@ -385,7 +385,7 @@ func parseReleaseData(data string) (sha256Hex string, releaseTime time.Time, err
releaseTime, err = releaseTagToReleaseTime(nfields[1])
if err != nil {
err = fmt.Errorf("Unknown release tag format. %s", err)
err = fmt.Errorf("Unknown release tag format. %w", err)
}
return sha256Hex, releaseTime, err

View File

@ -1293,7 +1293,7 @@ func (s *xlSets) ReloadFormat(ctx context.Context, dryRun bool) (err error) {
// Look for acceptable heal errors, for any other
// errors we should simply quit and return.
if _, ok := formatHealErrors[sErr]; !ok {
return fmt.Errorf("Disk %s: %s", s.endpoints[index], sErr)
return fmt.Errorf("Disk %s: %w", s.endpoints[index], sErr)
}
}
}
@ -1423,7 +1423,7 @@ func (s *xlSets) HealFormat(ctx context.Context, dryRun bool) (res madmin.HealRe
// Look for acceptable heal errors, for any other
// errors we should simply quit and return.
if _, ok := formatHealErrors[sErr]; !ok {
return res, fmt.Errorf("Disk %s: %s", s.endpoints[index], sErr)
return res, fmt.Errorf("Disk %s: %w", s.endpoints[index], sErr)
}
}
}
@ -1493,7 +1493,7 @@ func (s *xlSets) HealFormat(ctx context.Context, dryRun bool) (res madmin.HealRe
// Initialize meta volume, if volume already exists ignores it, all disks which
// are not found are ignored as well.
if err = initFormatXLMetaVolume(storageDisks, tmpNewFormats); err != nil {
return madmin.HealResultItem{}, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %s", err)
return madmin.HealResultItem{}, fmt.Errorf("Unable to initialize '.minio.sys' meta volume, %w", err)
}
// Save formats `format.json` across all disks.

View File

@ -85,7 +85,7 @@ func (f *mintJSONFormatter) Format(entry *log.Entry) ([]byte, error) {
serialized, err := json.Marshal(data)
if err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
return nil, fmt.Errorf("Failed to marshal fields to JSON, %w", err)
}
return append(serialized, '\n'), nil
}

View File

@ -59,7 +59,7 @@ func (f *mintJSONFormatter) Format(entry *log.Entry) ([]byte, error) {
serialized, err := json.Marshal(data)
if err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
return nil, fmt.Errorf("Failed to marshal fields to JSON, %w", err)
}
return append(serialized, '\n'), nil
}

View File

@ -219,7 +219,7 @@ func (f *mintJSONFormatter) Format(entry *log.Entry) ([]byte, error) {
serialized, err := json.Marshal(data)
if err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
return nil, fmt.Errorf("Failed to marshal fields to JSON, %w", err)
}
return append(serialized, '\n'), nil
}

View File

@ -71,7 +71,7 @@ func (f *mintJSONFormatter) Format(entry *log.Entry) ([]byte, error) {
serialized, err := json.Marshal(data)
if err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
return nil, fmt.Errorf("Failed to marshal fields to JSON, %w", err)
}
return append(serialized, '\n'), nil
}

View File

@ -229,7 +229,7 @@ func NewMQTTTarget(id string, args MQTTArgs, doneCh <-chan struct{}, loggerOnce
ok := token.WaitTimeout(reconnectInterval * time.Second)
if ok && token.Error() != nil {
target.loggerOnce(context.Background(),
fmt.Errorf("Previous connect failed with %s attempting a reconnect",
fmt.Errorf("Previous connect failed with %w attempting a reconnect",
token.Error()),
target.ID())
time.Sleep(reconnectInterval * time.Second)

View File

@ -70,7 +70,7 @@ func replayEvents(store Store, doneCh <-chan struct{}, loggerOnce func(ctx conte
case <-retryTicker.C:
if err != nil {
loggerOnce(context.Background(),
fmt.Errorf("store.List() failed '%v'", err), id)
fmt.Errorf("store.List() failed '%w'", err), id)
}
case <-doneCh:
return
@ -110,7 +110,7 @@ func sendEvents(target event.Target, eventKeyCh <-chan string, doneCh <-chan str
if err != errNotConnected && !IsConnResetErr(err) {
loggerOnce(context.Background(),
fmt.Errorf("target.Send() failed with '%v'", err),
fmt.Errorf("target.Send() failed with '%w'", err),
target.ID())
continue
}

View File

@ -143,7 +143,7 @@ func saveFileConfigEtcd(filename string, clnt *etcd.Client, v interface{}) error
if err == context.DeadlineExceeded {
return fmt.Errorf("etcd setup is unreachable, please check your endpoints %s", clnt.Endpoints())
} else if err != nil {
return fmt.Errorf("unexpected error %s returned by etcd setup, please check your endpoints %s", err, clnt.Endpoints())
return fmt.Errorf("unexpected error %w returned by etcd setup, please check your endpoints %s", err, clnt.Endpoints())
}
return nil
}
@ -156,7 +156,7 @@ func loadFileConfigEtcd(filename string, clnt *etcd.Client, v interface{}) error
if err == context.DeadlineExceeded {
return fmt.Errorf("etcd setup is unreachable, please check your endpoints %s", clnt.Endpoints())
}
return fmt.Errorf("unexpected error %s returned by etcd setup, please check your endpoints %s", err, clnt.Endpoints())
return fmt.Errorf("unexpected error %w returned by etcd setup, please check your endpoints %s", err, clnt.Endpoints())
}
if resp.Count == 0 {
return os.ErrNotExist

View File

@ -84,7 +84,7 @@ func ParseSelectStatement(s string) (stmt SelectStatement, err error) {
if selectAST.Where != nil {
whereQProp := selectAST.Where.analyze(&selectAST)
if whereQProp.err != nil {
err = errQueryAnalysisFailure(fmt.Errorf("Where clause error: %v", whereQProp.err))
err = errQueryAnalysisFailure(fmt.Errorf("Where clause error: %w", whereQProp.err))
return
}