connect/ca: use weak type decoding in the Vault config parsing

This commit is contained in:
Kyle Havlovitz 2018-06-20 14:33:02 -07:00 committed by Jack Pearkes
parent b4ef7bb64d
commit 8c2c9705d9
1 changed files with 12 additions and 1 deletions

View File

@ -285,7 +285,18 @@ func (v *VaultProvider) Cleanup() error {
func ParseVaultCAConfig(raw map[string]interface{}) (*structs.VaultCAProviderConfig, error) {
var config structs.VaultCAProviderConfig
if err := mapstructure.Decode(raw, &config); err != nil {
decodeConf := &mapstructure.DecoderConfig{
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)
}