fixes #2249: sanitize tenant and tenantid

If tenant or tenantid are passed as env variables, we systematically use Sprint to make sure they are string and not integer as it would make mapstructure fail.

Signed-off-by: Raphaël Enrici <raphael@root-42.com>
This commit is contained in:
Raphaël Enrici 2017-12-17 18:26:09 +01:00
parent f411848591
commit 8777e97b72

View file

@ -142,6 +142,19 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
InsecureSkipVerify: false, InsecureSkipVerify: false,
} }
// Sanitize some entries before trying to decode parameters with mapstructure
// TenantID and Tenant when integers only and passed as ENV variables
// are considered as integer and not string. The parser fails in this
// case.
_, ok := parameters["tenant"]
if ok {
parameters["tenant"] = fmt.Sprint(parameters["tenant"])
}
_, ok = parameters["tenantid"]
if ok {
parameters["tenantid"] = fmt.Sprint(parameters["tenantid"])
}
if err := mapstructure.Decode(parameters, &params); err != nil { if err := mapstructure.Decode(parameters, &params); err != nil {
return nil, err return nil, err
} }