From 13a3d173213c8f7d4738ba7ac70cdde8814d9a3a Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 16 Nov 2019 14:57:36 -0800 Subject: [PATCH] Do not add comments after migration (#8530) Also filter out empty comments from being printed. --- cmd/config-current.go | 7 ++++++- cmd/config/cache/legacy.go | 1 - cmd/config/compress/legacy.go | 7 +++---- cmd/config/identity/ldap/legacy.go | 1 - cmd/config/identity/openid/legacy.go | 9 ++++----- cmd/config/legacy.go | 5 +---- cmd/config/notify/legacy.go | 10 ---------- cmd/config/policy/opa/legacy.go | 7 +++---- cmd/config/storageclass/legacy.go | 7 +++---- cmd/crypto/legacy.go | 1 - cmd/logger/legacy.go | 14 ++++++-------- pkg/madmin/parse-kv.go | 4 +++- 12 files changed, 29 insertions(+), 44 deletions(-) diff --git a/cmd/config-current.go b/cmd/config-current.go index 1d170aed4..b7dd9b986 100644 --- a/cmd/config-current.go +++ b/cmd/config-current.go @@ -18,6 +18,7 @@ package cmd import ( "context" + "fmt" "strings" "sync" @@ -288,7 +289,11 @@ var helpMap = map[string]config.HelpKV{ // GetHelp - returns help for sub-sys, a key for a sub-system or all the help. func GetHelp(subSys, key string, envOnly bool) (config.HelpKV, error) { if len(subSys) == 0 { - return nil, config.Error("no help available for empty sub-system inputs") + help := config.HelpKV{} + for _, subSys := range config.SubSystems.ToSlice() { + help[subSys] = fmt.Sprintf("Specify sub-sys '%s' to get further help", subSys) + } + return help, nil } subSystemValue := strings.SplitN(subSys, config.SubSystemSeparator, 2) if len(subSystemValue) == 0 { diff --git a/cmd/config/cache/legacy.go b/cmd/config/cache/legacy.go index c5676e3c1..3f51a9590 100644 --- a/cmd/config/cache/legacy.go +++ b/cmd/config/cache/legacy.go @@ -35,5 +35,4 @@ func SetCacheConfig(s config.Config, cfg Config) { s[config.CacheSubSys][config.Default][Expiry] = fmt.Sprintf("%d", cfg.Expiry) s[config.CacheSubSys][config.Default][Quota] = fmt.Sprintf("%d", cfg.MaxUse) s[config.CacheSubSys][config.Default][config.State] = config.StateOn - s[config.CacheSubSys][config.Default][config.Comment] = "Settings for Cache, after migrating config" } diff --git a/cmd/config/compress/legacy.go b/cmd/config/compress/legacy.go index e2602398d..ebac5f24a 100644 --- a/cmd/config/compress/legacy.go +++ b/cmd/config/compress/legacy.go @@ -35,9 +35,8 @@ func SetCompressionConfig(s config.Config, cfg Config) { return } s[config.CompressionSubSys][config.Default] = config.KVS{ - config.State: config.StateOn, - config.Comment: "Settings for Compression, after migrating config", - Extensions: strings.Join(cfg.Extensions, config.ValueSeparator), - MimeTypes: strings.Join(cfg.MimeTypes, config.ValueSeparator), + config.State: config.StateOn, + Extensions: strings.Join(cfg.Extensions, config.ValueSeparator), + MimeTypes: strings.Join(cfg.MimeTypes, config.ValueSeparator), } } diff --git a/cmd/config/identity/ldap/legacy.go b/cmd/config/identity/ldap/legacy.go index e8aaade6a..a51a76771 100644 --- a/cmd/config/identity/ldap/legacy.go +++ b/cmd/config/identity/ldap/legacy.go @@ -26,7 +26,6 @@ func SetIdentityLDAP(s config.Config, ldapArgs Config) { } s[config.IdentityLDAPSubSys][config.Default] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for LDAP, after migrating config", ServerAddr: ldapArgs.ServerAddr, STSExpiry: ldapArgs.STSExpiryDuration, UsernameFormat: ldapArgs.UsernameFormat, diff --git a/cmd/config/identity/openid/legacy.go b/cmd/config/identity/openid/legacy.go index 26177663a..71f2ca0b5 100644 --- a/cmd/config/identity/openid/legacy.go +++ b/cmd/config/identity/openid/legacy.go @@ -30,10 +30,9 @@ func SetIdentityOpenID(s config.Config, cfg Config) { return } s[config.IdentityOpenIDSubSys][config.Default] = config.KVS{ - config.State: config.StateOn, - config.Comment: "Settings for OpenID, after migrating config", - JwksURL: cfg.JWKS.URL.String(), - ConfigURL: "", - ClaimPrefix: "", + config.State: config.StateOn, + JwksURL: cfg.JWKS.URL.String(), + ConfigURL: "", + ClaimPrefix: "", } } diff --git a/cmd/config/legacy.go b/cmd/config/legacy.go index b684a4042..2c0e15142 100644 --- a/cmd/config/legacy.go +++ b/cmd/config/legacy.go @@ -32,7 +32,6 @@ func SetCredentials(c Config, cred auth.Credentials) { } c[CredentialsSubSys][Default] = KVS{ State: StateOn, - Comment: "Settings for credentials, after migrating config", AccessKey: cred.AccessKey, SecretKey: cred.SecretKey, } @@ -46,7 +45,6 @@ func SetRegion(c Config, name string) { c[RegionSubSys][Default] = KVS{ RegionName: name, State: StateOn, - Comment: "Settings for Region, after migrating config", } } @@ -58,7 +56,6 @@ func SetWorm(c Config, b bool) { } // Set the new value. c[WormSubSys][Default] = KVS{ - State: StateOn, - Comment: "Settings for WORM, after migrating config", + State: StateOn, } } diff --git a/cmd/config/notify/legacy.go b/cmd/config/notify/legacy.go index a12ef9326..e6c39beff 100644 --- a/cmd/config/notify/legacy.go +++ b/cmd/config/notify/legacy.go @@ -28,7 +28,6 @@ func SetNotifyKafka(s config.Config, kName string, cfg target.KafkaArgs) error { } return strings.Join(brokers, config.ValueSeparator) }(), - config.Comment: "Settings for Kafka notification, after migrating config", target.KafkaTopic: cfg.Topic, target.KafkaQueueDir: cfg.QueueDir, target.KafkaQueueLimit: strconv.Itoa(int(cfg.QueueLimit)), @@ -54,7 +53,6 @@ func SetNotifyAMQP(s config.Config, amqpName string, cfg target.AMQPArgs) error s[config.NotifyAMQPSubSys][amqpName] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for AMQP notification, after migrating config", target.AmqpURL: cfg.URL.String(), target.AmqpExchange: cfg.Exchange, target.AmqpRoutingKey: cfg.RoutingKey, @@ -84,7 +82,6 @@ func SetNotifyES(s config.Config, esName string, cfg target.ElasticsearchArgs) e s[config.NotifyESSubSys][esName] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for Elasticsearch notification, after migrating config", target.ElasticFormat: cfg.Format, target.ElasticURL: cfg.URL.String(), target.ElasticIndex: cfg.Index, @@ -107,7 +104,6 @@ func SetNotifyRedis(s config.Config, redisName string, cfg target.RedisArgs) err s[config.NotifyRedisSubSys][redisName] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for Redis notification, after migrating config", target.RedisFormat: cfg.Format, target.RedisAddress: cfg.Addr.String(), target.RedisPassword: cfg.Password, @@ -131,7 +127,6 @@ func SetNotifyWebhook(s config.Config, whName string, cfg target.WebhookArgs) er s[config.NotifyWebhookSubSys][whName] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for Webhook notification, after migrating config", target.WebhookEndpoint: cfg.Endpoint.String(), target.WebhookAuthToken: cfg.AuthToken, target.WebhookQueueDir: cfg.QueueDir, @@ -153,7 +148,6 @@ func SetNotifyPostgres(s config.Config, psqName string, cfg target.PostgreSQLArg s[config.NotifyPostgresSubSys][psqName] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for Postgres notification, after migrating config", target.PostgresFormat: cfg.Format, target.PostgresConnectionString: cfg.ConnectionString, target.PostgresTable: cfg.Table, @@ -181,7 +175,6 @@ func SetNotifyNSQ(s config.Config, nsqName string, cfg target.NSQArgs) error { s[config.NotifyNSQSubSys][nsqName] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for NSQ notification, after migrating config", target.NSQAddress: cfg.NSQDAddress.String(), target.NSQTopic: cfg.Topic, target.NSQTLS: config.FormatBool(cfg.TLS.Enable), @@ -205,7 +198,6 @@ func SetNotifyNATS(s config.Config, natsName string, cfg target.NATSArgs) error s[config.NotifyNATSSubSys][natsName] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for NATS notification, after migrating config", target.NATSAddress: cfg.Address.String(), target.NATSSubject: cfg.Subject, target.NATSUsername: cfg.Username, @@ -244,7 +236,6 @@ func SetNotifyMySQL(s config.Config, sqlName string, cfg target.MySQLArgs) error s[config.NotifyMySQLSubSys][sqlName] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for MySQL notification, after migrating config", target.MySQLFormat: cfg.Format, target.MySQLDSNString: cfg.DSN, target.MySQLTable: cfg.Table, @@ -272,7 +263,6 @@ func SetNotifyMQTT(s config.Config, mqttName string, cfg target.MQTTArgs) error s[config.NotifyMQTTSubSys][mqttName] = config.KVS{ config.State: config.StateOn, - config.Comment: "Settings for MQTT notification, after migrating config", target.MqttBroker: cfg.Broker.String(), target.MqttTopic: cfg.Topic, target.MqttQoS: fmt.Sprintf("%d", cfg.QoS), diff --git a/cmd/config/policy/opa/legacy.go b/cmd/config/policy/opa/legacy.go index 484c9e917..01e2f0ffd 100644 --- a/cmd/config/policy/opa/legacy.go +++ b/cmd/config/policy/opa/legacy.go @@ -33,9 +33,8 @@ func SetPolicyOPAConfig(s config.Config, opaArgs Args) { return } s[config.PolicyOPASubSys][config.Default] = config.KVS{ - config.State: config.StateOn, - config.Comment: "Settings for OPA, after migrating config", - URL: opaArgs.URL.String(), - AuthToken: opaArgs.AuthToken, + config.State: config.StateOn, + URL: opaArgs.URL.String(), + AuthToken: opaArgs.AuthToken, } } diff --git a/cmd/config/storageclass/legacy.go b/cmd/config/storageclass/legacy.go index 02f56cb69..23ed334a0 100644 --- a/cmd/config/storageclass/legacy.go +++ b/cmd/config/storageclass/legacy.go @@ -27,9 +27,8 @@ func SetStorageClass(s config.Config, cfg Config) { return } s[config.StorageClassSubSys][config.Default] = config.KVS{ - ClassStandard: cfg.Standard.String(), - ClassRRS: cfg.RRS.String(), - config.State: config.StateOn, - config.Comment: "Settings for StorageClass, after migrating config", + ClassStandard: cfg.Standard.String(), + ClassRRS: cfg.RRS.String(), + config.State: config.StateOn, } } diff --git a/cmd/crypto/legacy.go b/cmd/crypto/legacy.go index aeea1a7cc..393c20738 100644 --- a/cmd/crypto/legacy.go +++ b/cmd/crypto/legacy.go @@ -97,7 +97,6 @@ func SetKMSConfig(s config.Config, cfg KMSConfig) { KMSVaultKeyVersion: strconv.Itoa(cfg.Vault.Key.Version), KMSVaultNamespace: cfg.Vault.Namespace, config.State: config.StateOn, - config.Comment: "Settings for KMS Vault, after migrating config", } } diff --git a/cmd/logger/legacy.go b/cmd/logger/legacy.go index 02090f485..d78d8fd47 100644 --- a/cmd/logger/legacy.go +++ b/cmd/logger/legacy.go @@ -30,10 +30,9 @@ func SetLoggerHTTPAudit(scfg config.Config, k string, args HTTP) { return } scfg[config.AuditWebhookSubSys][k] = config.KVS{ - config.State: config.StateOn, - config.Comment: "Settings for Webhook Audit logging, after migrating config", - Endpoint: args.Endpoint, - AuthToken: args.AuthToken, + config.State: config.StateOn, + Endpoint: args.Endpoint, + AuthToken: args.AuthToken, } } @@ -45,9 +44,8 @@ func SetLoggerHTTP(scfg config.Config, k string, args HTTP) { } scfg[config.LoggerWebhookSubSys][k] = config.KVS{ - config.State: config.StateOn, - config.Comment: "Settings for Webhook logging, after migrating config", - Endpoint: args.Endpoint, - AuthToken: args.AuthToken, + config.State: config.StateOn, + Endpoint: args.Endpoint, + AuthToken: args.AuthToken, } } diff --git a/pkg/madmin/parse-kv.go b/pkg/madmin/parse-kv.go index d7cfca271..0fdf373b1 100644 --- a/pkg/madmin/parse-kv.go +++ b/pkg/madmin/parse-kv.go @@ -46,6 +46,9 @@ func (kvs KVS) String() string { if k == stateKey && v == stateOn { continue } + if k == commentKey && v == "" { + continue + } s.WriteString(k) s.WriteString(KvSeparator) spc := hasSpace(v) @@ -96,7 +99,6 @@ func (t Targets) String() string { s.WriteString(kv.String()) if (len(t) > 1 || len(targetKV) > 1) && count > 0 { s.WriteString(KvNewline) - s.WriteString(KvNewline) } } }