Skip to content

Commit

Permalink
connect: fix two CA tests that were broken in a previous PR (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyhavlov authored and pearkes committed Jun 25, 2018
1 parent 01fefd3 commit 82a4b3c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion agent/connect_ca_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
14 changes: 13 additions & 1 deletion api/connect_ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 82a4b3c

Please sign in to comment.