agent: format all CA config fields

This commit is contained in:
Kyle Havlovitz 2018-06-06 10:46:34 -07:00 committed by Jack Pearkes
parent edbeeeb23c
commit aafa3ca64a
1 changed files with 6 additions and 3 deletions

View File

@ -76,14 +76,17 @@ func (s *HTTPServer) ConnectCAConfigurationSet(resp http.ResponseWriter, req *ht
// A hack to fix up the config types inside of the map[string]interface{} // A hack to fix up the config types inside of the map[string]interface{}
// so that they get formatted correctly during json.Marshal. Without this, // so that they get formatted correctly during json.Marshal. Without this,
// duration values given as text like "24h" end up getting output back // string values that get converted to []uint8 end up getting output back
// to the user in base64-encoded form. // to the user in base64-encoded form.
func fixupConfig(conf *structs.CAConfiguration) { func fixupConfig(conf *structs.CAConfiguration) {
if conf.Provider == structs.ConsulCAProvider { if conf.Provider == structs.ConsulCAProvider {
if v, ok := conf.Config["RotationPeriod"]; ok { for k, v := range conf.Config {
if raw, ok := v.([]uint8); ok { if raw, ok := v.([]uint8); ok {
conf.Config["RotationPeriod"] = ca.Uint8ToString(raw) conf.Config[k] = ca.Uint8ToString(raw)
} }
} }
if conf.Config["PrivateKey"] != "" {
conf.Config["PrivateKey"] = "hidden"
}
} }
} }