connect: fix two CA tests that were broken in a previous PR (#60)

pull/4275/head
Kyle Havlovitz 7 years ago committed by Jack Pearkes
parent 01fefd3d92
commit 82a4b3c13f

@ -85,7 +85,7 @@ func fixupConfig(conf *structs.CAConfiguration) {
conf.Config[k] = ca.Uint8ToString(raw) conf.Config[k] = ca.Uint8ToString(raw)
} }
} }
if conf.Config["PrivateKey"] != "" { if v, ok := conf.Config["PrivateKey"]; ok && v != "" {
conf.Config["PrivateKey"] = "hidden" conf.Config["PrivateKey"] = "hidden"
} }
} }

@ -32,7 +32,19 @@ type ConsulCAProviderConfig struct {
// ConsulCAProviderConfig. // ConsulCAProviderConfig.
func ParseConsulCAConfig(raw map[string]interface{}) (*ConsulCAProviderConfig, error) { func ParseConsulCAConfig(raw map[string]interface{}) (*ConsulCAProviderConfig, error) {
var config ConsulCAProviderConfig var config ConsulCAProviderConfig
if err := mapstructure.WeakDecode(raw, &config); err != nil { decodeConf := &mapstructure.DecoderConfig{
DecodeHook: mapstructure.StringToTimeDurationHookFunc(),
ErrorUnused: true,
Result: &config,
WeaklyTypedInput: true,
}
decoder, err := mapstructure.NewDecoder(decodeConf)
if err != nil {
return nil, err
}
if err := decoder.Decode(raw); err != nil {
return nil, fmt.Errorf("error decoding config: %s", err) return nil, fmt.Errorf("error decoding config: %s", err)
} }

Loading…
Cancel
Save