feat(template): do not print new lines if value of flag is None
All checks were successful
test / Linting (push) Successful in 37s
test / Molecule tests (default, ubuntu2004) (push) Successful in 50s
test / Molecule tests (default, debian11) (push) Successful in 1m22s
test / Molecule tests (default, debian12) (push) Successful in 1m23s
test / Molecule tests (with_custom_flags, debian11) (push) Successful in 34s
test / Molecule tests (with_custom_flags, debian12) (push) Successful in 32s
test / Molecule tests (default, ubuntu2204) (push) Successful in 59s
test / Molecule tests (with_custom_flags, ubuntu2204) (push) Successful in 53s
test / Molecule tests (with_custom_flags, ubuntu2004) (push) Successful in 59s
All checks were successful
test / Linting (push) Successful in 37s
test / Molecule tests (default, ubuntu2004) (push) Successful in 50s
test / Molecule tests (default, debian11) (push) Successful in 1m22s
test / Molecule tests (default, debian12) (push) Successful in 1m23s
test / Molecule tests (with_custom_flags, debian11) (push) Successful in 34s
test / Molecule tests (with_custom_flags, debian12) (push) Successful in 32s
test / Molecule tests (default, ubuntu2204) (push) Successful in 59s
test / Molecule tests (with_custom_flags, ubuntu2204) (push) Successful in 53s
test / Molecule tests (with_custom_flags, ubuntu2004) (push) Successful in 59s
This commit is contained in:
parent
670cc6529f
commit
1d71409b22
@ -1,9 +1,11 @@
|
||||
# filter_plugins/docker_filters.py
|
||||
|
||||
|
||||
def create_docker_flags(flags):
|
||||
if flags:
|
||||
return "\n".join([create_docker_flag(item) for item in flags])
|
||||
filtered_flags = [
|
||||
create_docker_flag(item) for item in flags if create_docker_flag(item)
|
||||
]
|
||||
return "\n".join(filtered_flags)
|
||||
return None
|
||||
|
||||
|
||||
@ -11,14 +13,16 @@ def create_docker_flag(item):
|
||||
if isinstance(item, dict):
|
||||
key = list(item.keys())[0]
|
||||
value = item[key]
|
||||
if isinstance(value, list):
|
||||
return "\n".join(['--{} "{}" \\'.format(key, val) for val in value])
|
||||
else:
|
||||
return '--{} "{}" \\'.format(key, value)
|
||||
if value is not None:
|
||||
if isinstance(value, list):
|
||||
flag_values = ['--{} "{}"'.format(key, val) for val in value]
|
||||
joined_values = " \\\n".join(flag_values)
|
||||
return f"{joined_values} \\" if joined_values else None
|
||||
else:
|
||||
return '--{} "{}" \\'.format(key, value)
|
||||
elif isinstance(item, str):
|
||||
return "--{} \\".format(item)
|
||||
else:
|
||||
return ""
|
||||
return None
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
|
Loading…
Reference in New Issue
Block a user