Fix action alias parameter casting.
Code would incorrectly try to cast a value to a list even if it's
already a list which means it would break in scenarios when value is
already a list (e.g. when parameter contains a default value or when
immutable_parameters are used with an action alias).
@@ -47,8 +47,16 @@ http_client = six.moves.http_client
LOG = logging.getLogger(__name__)
+
+def cast_array(value):
+ if isinstance(value, list):
+ # Already a list, no casting needed nor wanted.
+ return value
+
+ return [v.strip() for v in value.split(',')]
+
CAST_OVERRIDES = {
- 'array': (lambda cs_x: [v.strip() for v in cs_x.split(',')])
+ 'array': cast_array,
}
