@@ -18,7 +18,6 @@ package restapi
18
18
19
19
import (
20
20
"context"
21
- "errors"
22
21
"fmt"
23
22
"strings"
24
23
@@ -132,7 +131,7 @@ func getConfig(ctx context.Context, client MinioAdmin, name string) ([]*models.C
132
131
confkv = append (confkv , & models.ConfigurationKV {Key : kv .Key , Value : kv .Value })
133
132
}
134
133
if len (confkv ) == 0 {
135
- return nil , errors . New ( "Invalid SubSystem - check config format" )
134
+ continue
136
135
}
137
136
var fullConfigName string
138
137
if scfg .Target == "" {
@@ -192,15 +191,20 @@ func setConfigWithARNAccountID(ctx context.Context, client MinioAdmin, configNam
192
191
// buildConfig builds a concatenated string including name and keyvalues
193
192
// e.g. `region name=us-west-1`
194
193
func buildConfig (configName * string , kvs []* models.ConfigurationKV ) * string {
195
- configElements := []string {* configName }
194
+ var builder strings.Builder
195
+ builder .WriteString (* configName )
196
196
for _ , kv := range kvs {
197
- key := kv .Key
198
- val := fmt .Sprintf ("\" %s\" " , kv .Value )
199
- if key != "" {
200
- configElements = append (configElements , fmt .Sprintf ("%s=%s" , key , val ))
197
+ key := strings .TrimSpace (kv .Key )
198
+ if key == "" {
199
+ continue
201
200
}
201
+ builder .WriteString (" " )
202
+ builder .WriteString (key )
203
+ builder .WriteString ("=" )
204
+ // All newlines must be converted to ','
205
+ builder .WriteString (strings .ReplaceAll (strings .TrimSpace (fmt .Sprintf ("\" %s\" " , kv .Value )), "\n " , "," ))
202
206
}
203
- config := strings . Join ( configElements , " " )
207
+ config := builder . String ( )
204
208
return & config
205
209
}
206
210
0 commit comments