From e8b381b90e7d70231e9f5ab024888055131e2513 Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Thu, 1 Dec 2022 07:47:08 +0100 Subject: [PATCH] support both lists and tuples in var-file arg (#66) --- test/test_args.py | 2 ++ tftest.py | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test_args.py b/test/test_args.py index 52762c4..b25b1b1 100644 --- a/test/test_args.py +++ b/test/test_args.py @@ -45,6 +45,8 @@ ({'upgrade': False}, []), ({'tf_var_file': None}, []), ({'tf_var_file': 'foo.tfvar'}, ['-var-file=foo.tfvar']), + ({'tf_var_file': ['foo.tfvar', 'bar.tfvar']}, [ + '-var-file=foo.tfvar', '-var-file=bar.tfvar']), ) diff --git a/tftest.py b/tftest.py index 139eddc..efca26c 100644 --- a/tftest.py +++ b/tftest.py @@ -151,9 +151,8 @@ def parse_args(init_vars=None, tf_vars=None, targets=None, **kw): cmd_args += [("-target={}".format(t)) for t in targets] if kw.get('tf_var_file'): tf_var_file = kw['tf_var_file'] - if isinstance(tf_var_file, list): - for x in tf_var_file: - cmd_args.append('-var-file={}'.format(x)) + if isinstance(tf_var_file, (list, tuple)): + cmd_args += ['-var-file={}'.format(v) for v in tf_var_file] else: cmd_args.append('-var-file={}'.format(tf_var_file)) return cmd_args