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

This commit is contained in:
Kyle Havlovitz 2018-06-11 13:59:29 -07:00 committed by Jack Pearkes
parent a8d3131de9
commit 549dc22944
2 changed files with 14 additions and 2 deletions

View File

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

View File

@ -32,7 +32,19 @@ type ConsulCAProviderConfig struct {
// ConsulCAProviderConfig.
func ParseConsulCAConfig(raw map[string]interface{}) (*ConsulCAProviderConfig, error) {
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)
}