mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-18 21:02:36 +00:00
Address redefined-builtin.
This commit is contained in:
parent
5de721bf3b
commit
b02ad20a34
@ -408,7 +408,6 @@ disable=raw-checker-failed,
|
|||||||
protected-access,
|
protected-access,
|
||||||
raise-missing-from,
|
raise-missing-from,
|
||||||
redefined-argument-from-local,
|
redefined-argument-from-local,
|
||||||
redefined-builtin,
|
|
||||||
redefined-outer-name,
|
redefined-outer-name,
|
||||||
simplifiable-if-expression,
|
simplifiable-if-expression,
|
||||||
subprocess-popen-preexec-fn,
|
subprocess-popen-preexec-fn,
|
||||||
|
|||||||
@ -149,10 +149,10 @@ class Connection(ConnectionBase):
|
|||||||
transport = "community.docker.docker_api"
|
transport = "community.docker.docker_api"
|
||||||
has_pipelining = True
|
has_pipelining = True
|
||||||
|
|
||||||
def _call_client(self, callable, not_found_can_be_resource=False):
|
def _call_client(self, f, not_found_can_be_resource=False):
|
||||||
remote_addr = self.get_option("remote_addr")
|
remote_addr = self.get_option("remote_addr")
|
||||||
try:
|
try:
|
||||||
return callable()
|
return f()
|
||||||
except NotFound as e:
|
except NotFound as e:
|
||||||
if not_found_can_be_resource:
|
if not_found_can_be_resource:
|
||||||
raise AnsibleConnectionFailure(
|
raise AnsibleConnectionFailure(
|
||||||
|
|||||||
@ -243,24 +243,24 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
|||||||
|
|
||||||
filters = parse_filters(self.get_option("filters"))
|
filters = parse_filters(self.get_option("filters"))
|
||||||
for container in containers:
|
for container in containers:
|
||||||
id = container.get("Id")
|
container_id = container.get("Id")
|
||||||
short_id = id[:13]
|
short_container_id = container_id[:13]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
name = container.get("Names", list())[0].lstrip("/")
|
name = container.get("Names", list())[0].lstrip("/")
|
||||||
full_name = name
|
full_name = name
|
||||||
except IndexError:
|
except IndexError:
|
||||||
name = short_id
|
name = short_container_id
|
||||||
full_name = id
|
full_name = container_id
|
||||||
|
|
||||||
facts = dict(
|
facts = dict(
|
||||||
docker_name=make_unsafe(name),
|
docker_name=make_unsafe(name),
|
||||||
docker_short_id=make_unsafe(short_id),
|
docker_short_id=make_unsafe(short_container_id),
|
||||||
)
|
)
|
||||||
full_facts = dict()
|
full_facts = dict()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
inspect = client.get_json("/containers/{0}/json", id)
|
inspect = client.get_json("/containers/{0}/json", container_id)
|
||||||
except APIError as exc:
|
except APIError as exc:
|
||||||
raise AnsibleError(f"Error inspecting container {name} - {exc}")
|
raise AnsibleError(f"Error inspecting container {name} - {exc}")
|
||||||
|
|
||||||
@ -371,12 +371,12 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
|||||||
# When we do this before a set_variable() call, the variables are assigned
|
# When we do this before a set_variable() call, the variables are assigned
|
||||||
# to the group, and not to the host.
|
# to the group, and not to the host.
|
||||||
if add_legacy_groups:
|
if add_legacy_groups:
|
||||||
self.inventory.add_group(id)
|
self.inventory.add_group(container_id)
|
||||||
self.inventory.add_host(name, group=id)
|
self.inventory.add_host(name, group=container_id)
|
||||||
self.inventory.add_group(name)
|
self.inventory.add_group(name)
|
||||||
self.inventory.add_host(name, group=name)
|
self.inventory.add_host(name, group=name)
|
||||||
self.inventory.add_group(short_id)
|
self.inventory.add_group(short_container_id)
|
||||||
self.inventory.add_host(name, group=short_id)
|
self.inventory.add_host(name, group=short_container_id)
|
||||||
self.inventory.add_group(hostname)
|
self.inventory.add_group(hostname)
|
||||||
self.inventory.add_host(name, group=hostname)
|
self.inventory.add_host(name, group=hostname)
|
||||||
|
|
||||||
|
|||||||
@ -170,15 +170,15 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
|
|
||||||
# capture any of the DOCKER_xxx variables that were output and create Ansible host vars
|
# capture any of the DOCKER_xxx variables that were output and create Ansible host vars
|
||||||
# with the same name and value but with a dm_ name prefix.
|
# with the same name and value but with a dm_ name prefix.
|
||||||
vars = []
|
env_vars = []
|
||||||
for line in env_lines:
|
for line in env_lines:
|
||||||
match = re.search('(DOCKER_[^=]+)="([^"]+)"', line)
|
match = re.search('(DOCKER_[^=]+)="([^"]+)"', line)
|
||||||
if match:
|
if match:
|
||||||
env_var_name = match.group(1)
|
env_var_name = match.group(1)
|
||||||
env_var_value = match.group(2)
|
env_var_value = match.group(2)
|
||||||
vars.append((env_var_name, env_var_value))
|
env_vars.append((env_var_name, env_var_value))
|
||||||
|
|
||||||
return vars
|
return env_vars
|
||||||
|
|
||||||
def _get_machine_names(self):
|
def _get_machine_names(self):
|
||||||
# Filter out machines that are not in the Running state as we probably cannot do anything useful actions
|
# Filter out machines that are not in the Running state as we probably cannot do anything useful actions
|
||||||
|
|||||||
@ -258,16 +258,18 @@ class AnsibleDockerClientBase(Client):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_value(param_name, param_value, env_variable, default_value, type="str"):
|
def _get_value(
|
||||||
|
param_name, param_value, env_variable, default_value, value_type="str"
|
||||||
|
):
|
||||||
if param_value is not None:
|
if param_value is not None:
|
||||||
# take module parameter value
|
# take module parameter value
|
||||||
if type == "bool":
|
if value_type == "bool":
|
||||||
if param_value in BOOLEANS_TRUE:
|
if param_value in BOOLEANS_TRUE:
|
||||||
return True
|
return True
|
||||||
if param_value in BOOLEANS_FALSE:
|
if param_value in BOOLEANS_FALSE:
|
||||||
return False
|
return False
|
||||||
return bool(param_value)
|
return bool(param_value)
|
||||||
if type == "int":
|
if value_type == "int":
|
||||||
return int(param_value)
|
return int(param_value)
|
||||||
return param_value
|
return param_value
|
||||||
|
|
||||||
@ -281,13 +283,13 @@ class AnsibleDockerClientBase(Client):
|
|||||||
return os.path.join(env_value, "ca.pem")
|
return os.path.join(env_value, "ca.pem")
|
||||||
if param_name == "key_path":
|
if param_name == "key_path":
|
||||||
return os.path.join(env_value, "key.pem")
|
return os.path.join(env_value, "key.pem")
|
||||||
if type == "bool":
|
if value_type == "bool":
|
||||||
if env_value in BOOLEANS_TRUE:
|
if env_value in BOOLEANS_TRUE:
|
||||||
return True
|
return True
|
||||||
if env_value in BOOLEANS_FALSE:
|
if env_value in BOOLEANS_FALSE:
|
||||||
return False
|
return False
|
||||||
return bool(env_value)
|
return bool(env_value)
|
||||||
if type == "int":
|
if value_type == "int":
|
||||||
return int(env_value)
|
return int(env_value)
|
||||||
return env_value
|
return env_value
|
||||||
|
|
||||||
@ -317,50 +319,66 @@ class AnsibleDockerClientBase(Client):
|
|||||||
params["docker_host"],
|
params["docker_host"],
|
||||||
"DOCKER_HOST",
|
"DOCKER_HOST",
|
||||||
DEFAULT_DOCKER_HOST,
|
DEFAULT_DOCKER_HOST,
|
||||||
type="str",
|
value_type="str",
|
||||||
),
|
),
|
||||||
tls_hostname=self._get_value(
|
tls_hostname=self._get_value(
|
||||||
"tls_hostname",
|
"tls_hostname",
|
||||||
params["tls_hostname"],
|
params["tls_hostname"],
|
||||||
"DOCKER_TLS_HOSTNAME",
|
"DOCKER_TLS_HOSTNAME",
|
||||||
None,
|
None,
|
||||||
type="str",
|
value_type="str",
|
||||||
),
|
),
|
||||||
api_version=self._get_value(
|
api_version=self._get_value(
|
||||||
"api_version",
|
"api_version",
|
||||||
params["api_version"],
|
params["api_version"],
|
||||||
"DOCKER_API_VERSION",
|
"DOCKER_API_VERSION",
|
||||||
"auto",
|
"auto",
|
||||||
type="str",
|
value_type="str",
|
||||||
),
|
),
|
||||||
cacert_path=self._get_value(
|
cacert_path=self._get_value(
|
||||||
"cacert_path", params["ca_path"], "DOCKER_CERT_PATH", None, type="str"
|
"cacert_path",
|
||||||
|
params["ca_path"],
|
||||||
|
"DOCKER_CERT_PATH",
|
||||||
|
None,
|
||||||
|
value_type="str",
|
||||||
),
|
),
|
||||||
cert_path=self._get_value(
|
cert_path=self._get_value(
|
||||||
"cert_path", params["client_cert"], "DOCKER_CERT_PATH", None, type="str"
|
"cert_path",
|
||||||
|
params["client_cert"],
|
||||||
|
"DOCKER_CERT_PATH",
|
||||||
|
None,
|
||||||
|
value_type="str",
|
||||||
),
|
),
|
||||||
key_path=self._get_value(
|
key_path=self._get_value(
|
||||||
"key_path", params["client_key"], "DOCKER_CERT_PATH", None, type="str"
|
"key_path",
|
||||||
|
params["client_key"],
|
||||||
|
"DOCKER_CERT_PATH",
|
||||||
|
None,
|
||||||
|
value_type="str",
|
||||||
),
|
),
|
||||||
tls=self._get_value(
|
tls=self._get_value(
|
||||||
"tls", params["tls"], "DOCKER_TLS", DEFAULT_TLS, type="bool"
|
"tls", params["tls"], "DOCKER_TLS", DEFAULT_TLS, value_type="bool"
|
||||||
),
|
),
|
||||||
tls_verify=self._get_value(
|
tls_verify=self._get_value(
|
||||||
"validate_certs",
|
"validate_certs",
|
||||||
params["validate_certs"],
|
params["validate_certs"],
|
||||||
"DOCKER_TLS_VERIFY",
|
"DOCKER_TLS_VERIFY",
|
||||||
DEFAULT_TLS_VERIFY,
|
DEFAULT_TLS_VERIFY,
|
||||||
type="bool",
|
value_type="bool",
|
||||||
),
|
),
|
||||||
timeout=self._get_value(
|
timeout=self._get_value(
|
||||||
"timeout",
|
"timeout",
|
||||||
params["timeout"],
|
params["timeout"],
|
||||||
"DOCKER_TIMEOUT",
|
"DOCKER_TIMEOUT",
|
||||||
DEFAULT_TIMEOUT_SECONDS,
|
DEFAULT_TIMEOUT_SECONDS,
|
||||||
type="int",
|
value_type="int",
|
||||||
),
|
),
|
||||||
use_ssh_client=self._get_value(
|
use_ssh_client=self._get_value(
|
||||||
"use_ssh_client", params["use_ssh_client"], None, False, type="bool"
|
"use_ssh_client",
|
||||||
|
params["use_ssh_client"],
|
||||||
|
None,
|
||||||
|
False,
|
||||||
|
value_type="bool",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -151,16 +151,18 @@ class AnsibleDockerClientBase(Client):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_value(param_name, param_value, env_variable, default_value, type="str"):
|
def _get_value(
|
||||||
|
param_name, param_value, env_variable, default_value, value_type="str"
|
||||||
|
):
|
||||||
if param_value is not None:
|
if param_value is not None:
|
||||||
# take module parameter value
|
# take module parameter value
|
||||||
if type == "bool":
|
if value_type == "bool":
|
||||||
if param_value in BOOLEANS_TRUE:
|
if param_value in BOOLEANS_TRUE:
|
||||||
return True
|
return True
|
||||||
if param_value in BOOLEANS_FALSE:
|
if param_value in BOOLEANS_FALSE:
|
||||||
return False
|
return False
|
||||||
return bool(param_value)
|
return bool(param_value)
|
||||||
if type == "int":
|
if value_type == "int":
|
||||||
return int(param_value)
|
return int(param_value)
|
||||||
return param_value
|
return param_value
|
||||||
|
|
||||||
@ -174,13 +176,13 @@ class AnsibleDockerClientBase(Client):
|
|||||||
return os.path.join(env_value, "ca.pem")
|
return os.path.join(env_value, "ca.pem")
|
||||||
if param_name == "key_path":
|
if param_name == "key_path":
|
||||||
return os.path.join(env_value, "key.pem")
|
return os.path.join(env_value, "key.pem")
|
||||||
if type == "bool":
|
if value_type == "bool":
|
||||||
if env_value in BOOLEANS_TRUE:
|
if env_value in BOOLEANS_TRUE:
|
||||||
return True
|
return True
|
||||||
if env_value in BOOLEANS_FALSE:
|
if env_value in BOOLEANS_FALSE:
|
||||||
return False
|
return False
|
||||||
return bool(env_value)
|
return bool(env_value)
|
||||||
if type == "int":
|
if value_type == "int":
|
||||||
return int(env_value)
|
return int(env_value)
|
||||||
return env_value
|
return env_value
|
||||||
|
|
||||||
@ -210,50 +212,66 @@ class AnsibleDockerClientBase(Client):
|
|||||||
params["docker_host"],
|
params["docker_host"],
|
||||||
"DOCKER_HOST",
|
"DOCKER_HOST",
|
||||||
DEFAULT_DOCKER_HOST,
|
DEFAULT_DOCKER_HOST,
|
||||||
type="str",
|
value_type="str",
|
||||||
),
|
),
|
||||||
tls_hostname=self._get_value(
|
tls_hostname=self._get_value(
|
||||||
"tls_hostname",
|
"tls_hostname",
|
||||||
params["tls_hostname"],
|
params["tls_hostname"],
|
||||||
"DOCKER_TLS_HOSTNAME",
|
"DOCKER_TLS_HOSTNAME",
|
||||||
None,
|
None,
|
||||||
type="str",
|
value_type="str",
|
||||||
),
|
),
|
||||||
api_version=self._get_value(
|
api_version=self._get_value(
|
||||||
"api_version",
|
"api_version",
|
||||||
params["api_version"],
|
params["api_version"],
|
||||||
"DOCKER_API_VERSION",
|
"DOCKER_API_VERSION",
|
||||||
"auto",
|
"auto",
|
||||||
type="str",
|
value_type="str",
|
||||||
),
|
),
|
||||||
cacert_path=self._get_value(
|
cacert_path=self._get_value(
|
||||||
"cacert_path", params["ca_path"], "DOCKER_CERT_PATH", None, type="str"
|
"cacert_path",
|
||||||
|
params["ca_path"],
|
||||||
|
"DOCKER_CERT_PATH",
|
||||||
|
None,
|
||||||
|
value_type="str",
|
||||||
),
|
),
|
||||||
cert_path=self._get_value(
|
cert_path=self._get_value(
|
||||||
"cert_path", params["client_cert"], "DOCKER_CERT_PATH", None, type="str"
|
"cert_path",
|
||||||
|
params["client_cert"],
|
||||||
|
"DOCKER_CERT_PATH",
|
||||||
|
None,
|
||||||
|
value_type="str",
|
||||||
),
|
),
|
||||||
key_path=self._get_value(
|
key_path=self._get_value(
|
||||||
"key_path", params["client_key"], "DOCKER_CERT_PATH", None, type="str"
|
"key_path",
|
||||||
|
params["client_key"],
|
||||||
|
"DOCKER_CERT_PATH",
|
||||||
|
None,
|
||||||
|
value_type="str",
|
||||||
),
|
),
|
||||||
tls=self._get_value(
|
tls=self._get_value(
|
||||||
"tls", params["tls"], "DOCKER_TLS", DEFAULT_TLS, type="bool"
|
"tls", params["tls"], "DOCKER_TLS", DEFAULT_TLS, value_type="bool"
|
||||||
),
|
),
|
||||||
tls_verify=self._get_value(
|
tls_verify=self._get_value(
|
||||||
"validate_certs",
|
"validate_certs",
|
||||||
params["validate_certs"],
|
params["validate_certs"],
|
||||||
"DOCKER_TLS_VERIFY",
|
"DOCKER_TLS_VERIFY",
|
||||||
DEFAULT_TLS_VERIFY,
|
DEFAULT_TLS_VERIFY,
|
||||||
type="bool",
|
value_type="bool",
|
||||||
),
|
),
|
||||||
timeout=self._get_value(
|
timeout=self._get_value(
|
||||||
"timeout",
|
"timeout",
|
||||||
params["timeout"],
|
params["timeout"],
|
||||||
"DOCKER_TIMEOUT",
|
"DOCKER_TIMEOUT",
|
||||||
DEFAULT_TIMEOUT_SECONDS,
|
DEFAULT_TIMEOUT_SECONDS,
|
||||||
type="int",
|
value_type="int",
|
||||||
),
|
),
|
||||||
use_ssh_client=self._get_value(
|
use_ssh_client=self._get_value(
|
||||||
"use_ssh_client", params["use_ssh_client"], None, False, type="bool"
|
"use_ssh_client",
|
||||||
|
params["use_ssh_client"],
|
||||||
|
None,
|
||||||
|
False,
|
||||||
|
value_type="bool",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -942,9 +942,9 @@ class BaseComposeManager(DockerBaseClass):
|
|||||||
result.pop(res)
|
result.pop(res)
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
for dir in self.cleanup_dirs:
|
for directory in self.cleanup_dirs:
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(dir, True)
|
shutil.rmtree(directory, True)
|
||||||
except Exception:
|
except Exception:
|
||||||
# should not happen, but simply ignore to be on the safe side
|
# should not happen, but simply ignore to be on the safe side
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -53,19 +53,19 @@ _MOUNT_OPTION_TYPES = dict(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _get_ansible_type(type):
|
def _get_ansible_type(value_type):
|
||||||
if type == "set":
|
if value_type == "set":
|
||||||
return "list"
|
return "list"
|
||||||
if type not in ("list", "dict", "bool", "int", "float", "str"):
|
if value_type not in ("list", "dict", "bool", "int", "float", "str"):
|
||||||
raise Exception(f'Invalid type "{type}"')
|
raise Exception(f'Invalid type "{value_type}"')
|
||||||
return type
|
return value_type
|
||||||
|
|
||||||
|
|
||||||
class Option(object):
|
class Option(object):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name,
|
name,
|
||||||
type,
|
value_type,
|
||||||
owner,
|
owner,
|
||||||
ansible_type=None,
|
ansible_type=None,
|
||||||
elements=None,
|
elements=None,
|
||||||
@ -81,9 +81,9 @@ class Option(object):
|
|||||||
compare=None,
|
compare=None,
|
||||||
):
|
):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.type = type
|
self.value_type = value_type
|
||||||
self.ansible_type = ansible_type or _get_ansible_type(type)
|
self.ansible_type = ansible_type or _get_ansible_type(value_type)
|
||||||
needs_elements = self.type in ("list", "set")
|
needs_elements = self.value_type in ("list", "set")
|
||||||
needs_ansible_elements = self.ansible_type in ("list",)
|
needs_ansible_elements = self.ansible_type in ("list",)
|
||||||
if elements is not None and not needs_elements:
|
if elements is not None and not needs_elements:
|
||||||
raise Exception("elements only allowed for lists/sets")
|
raise Exception("elements only allowed for lists/sets")
|
||||||
@ -118,7 +118,7 @@ class Option(object):
|
|||||||
self.ansible_suboptions = ansible_suboptions if needs_suboptions else None
|
self.ansible_suboptions = ansible_suboptions if needs_suboptions else None
|
||||||
self.ansible_aliases = ansible_aliases or []
|
self.ansible_aliases = ansible_aliases or []
|
||||||
self.ansible_choices = ansible_choices
|
self.ansible_choices = ansible_choices
|
||||||
comparison_type = self.type
|
comparison_type = self.value_type
|
||||||
if comparison_type == "set" and self.elements == "dict":
|
if comparison_type == "set" and self.elements == "dict":
|
||||||
comparison_type = "set(dict)"
|
comparison_type = "set(dict)"
|
||||||
elif comparison_type not in ("set", "list", "dict"):
|
elif comparison_type not in ("set", "list", "dict"):
|
||||||
@ -920,55 +920,55 @@ def _compare_platform(option, param_value, container_value):
|
|||||||
return param_value == container_value
|
return param_value == container_value
|
||||||
|
|
||||||
|
|
||||||
OPTION_AUTO_REMOVE = OptionGroup().add_option("auto_remove", type="bool")
|
OPTION_AUTO_REMOVE = OptionGroup().add_option("auto_remove", value_type="bool")
|
||||||
|
|
||||||
OPTION_BLKIO_WEIGHT = OptionGroup().add_option("blkio_weight", type="int")
|
OPTION_BLKIO_WEIGHT = OptionGroup().add_option("blkio_weight", value_type="int")
|
||||||
|
|
||||||
OPTION_CAPABILITIES = OptionGroup().add_option(
|
OPTION_CAPABILITIES = OptionGroup().add_option(
|
||||||
"capabilities", type="set", elements="str"
|
"capabilities", value_type="set", elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_CAP_DROP = OptionGroup().add_option("cap_drop", type="set", elements="str")
|
OPTION_CAP_DROP = OptionGroup().add_option("cap_drop", value_type="set", elements="str")
|
||||||
|
|
||||||
OPTION_CGROUP_NS_MODE = OptionGroup().add_option(
|
OPTION_CGROUP_NS_MODE = OptionGroup().add_option(
|
||||||
"cgroupns_mode", type="str", ansible_choices=["private", "host"]
|
"cgroupns_mode", value_type="str", ansible_choices=["private", "host"]
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_CGROUP_PARENT = OptionGroup().add_option("cgroup_parent", type="str")
|
OPTION_CGROUP_PARENT = OptionGroup().add_option("cgroup_parent", value_type="str")
|
||||||
|
|
||||||
OPTION_COMMAND = OptionGroup(preprocess=_preprocess_command).add_option(
|
OPTION_COMMAND = OptionGroup(preprocess=_preprocess_command).add_option(
|
||||||
"command", type="list", elements="str", ansible_type="raw"
|
"command", value_type="list", elements="str", ansible_type="raw"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_CPU_PERIOD = OptionGroup().add_option("cpu_period", type="int")
|
OPTION_CPU_PERIOD = OptionGroup().add_option("cpu_period", value_type="int")
|
||||||
|
|
||||||
OPTION_CPU_QUOTA = OptionGroup().add_option("cpu_quota", type="int")
|
OPTION_CPU_QUOTA = OptionGroup().add_option("cpu_quota", value_type="int")
|
||||||
|
|
||||||
OPTION_CPUSET_CPUS = OptionGroup().add_option("cpuset_cpus", type="str")
|
OPTION_CPUSET_CPUS = OptionGroup().add_option("cpuset_cpus", value_type="str")
|
||||||
|
|
||||||
OPTION_CPUSET_MEMS = OptionGroup().add_option("cpuset_mems", type="str")
|
OPTION_CPUSET_MEMS = OptionGroup().add_option("cpuset_mems", value_type="str")
|
||||||
|
|
||||||
OPTION_CPU_SHARES = OptionGroup().add_option("cpu_shares", type="int")
|
OPTION_CPU_SHARES = OptionGroup().add_option("cpu_shares", value_type="int")
|
||||||
|
|
||||||
OPTION_ENTRYPOINT = OptionGroup(preprocess=_preprocess_entrypoint).add_option(
|
OPTION_ENTRYPOINT = OptionGroup(preprocess=_preprocess_entrypoint).add_option(
|
||||||
"entrypoint", type="list", elements="str"
|
"entrypoint", value_type="list", elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_CPUS = OptionGroup().add_option("cpus", type="int", ansible_type="float")
|
OPTION_CPUS = OptionGroup().add_option("cpus", value_type="int", ansible_type="float")
|
||||||
|
|
||||||
OPTION_DETACH_INTERACTIVE = (
|
OPTION_DETACH_INTERACTIVE = (
|
||||||
OptionGroup()
|
OptionGroup()
|
||||||
.add_option("detach", type="bool")
|
.add_option("detach", value_type="bool")
|
||||||
.add_option("interactive", type="bool")
|
.add_option("interactive", value_type="bool")
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_DEVICES = OptionGroup().add_option(
|
OPTION_DEVICES = OptionGroup().add_option(
|
||||||
"devices", type="set", elements="dict", ansible_elements="str"
|
"devices", value_type="set", elements="dict", ansible_elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_DEVICE_READ_BPS = OptionGroup().add_option(
|
OPTION_DEVICE_READ_BPS = OptionGroup().add_option(
|
||||||
"device_read_bps",
|
"device_read_bps",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="dict",
|
elements="dict",
|
||||||
ansible_suboptions=dict(
|
ansible_suboptions=dict(
|
||||||
path=dict(required=True, type="str"),
|
path=dict(required=True, type="str"),
|
||||||
@ -978,7 +978,7 @@ OPTION_DEVICE_READ_BPS = OptionGroup().add_option(
|
|||||||
|
|
||||||
OPTION_DEVICE_WRITE_BPS = OptionGroup().add_option(
|
OPTION_DEVICE_WRITE_BPS = OptionGroup().add_option(
|
||||||
"device_write_bps",
|
"device_write_bps",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="dict",
|
elements="dict",
|
||||||
ansible_suboptions=dict(
|
ansible_suboptions=dict(
|
||||||
path=dict(required=True, type="str"),
|
path=dict(required=True, type="str"),
|
||||||
@ -988,7 +988,7 @@ OPTION_DEVICE_WRITE_BPS = OptionGroup().add_option(
|
|||||||
|
|
||||||
OPTION_DEVICE_READ_IOPS = OptionGroup().add_option(
|
OPTION_DEVICE_READ_IOPS = OptionGroup().add_option(
|
||||||
"device_read_iops",
|
"device_read_iops",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="dict",
|
elements="dict",
|
||||||
ansible_suboptions=dict(
|
ansible_suboptions=dict(
|
||||||
path=dict(required=True, type="str"),
|
path=dict(required=True, type="str"),
|
||||||
@ -998,7 +998,7 @@ OPTION_DEVICE_READ_IOPS = OptionGroup().add_option(
|
|||||||
|
|
||||||
OPTION_DEVICE_WRITE_IOPS = OptionGroup().add_option(
|
OPTION_DEVICE_WRITE_IOPS = OptionGroup().add_option(
|
||||||
"device_write_iops",
|
"device_write_iops",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="dict",
|
elements="dict",
|
||||||
ansible_suboptions=dict(
|
ansible_suboptions=dict(
|
||||||
path=dict(required=True, type="str"),
|
path=dict(required=True, type="str"),
|
||||||
@ -1008,7 +1008,7 @@ OPTION_DEVICE_WRITE_IOPS = OptionGroup().add_option(
|
|||||||
|
|
||||||
OPTION_DEVICE_REQUESTS = OptionGroup().add_option(
|
OPTION_DEVICE_REQUESTS = OptionGroup().add_option(
|
||||||
"device_requests",
|
"device_requests",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="dict",
|
elements="dict",
|
||||||
ansible_suboptions=dict(
|
ansible_suboptions=dict(
|
||||||
capabilities=dict(type="list", elements="list"),
|
capabilities=dict(type="list", elements="list"),
|
||||||
@ -1020,29 +1020,33 @@ OPTION_DEVICE_REQUESTS = OptionGroup().add_option(
|
|||||||
)
|
)
|
||||||
|
|
||||||
OPTION_DEVICE_CGROUP_RULES = OptionGroup().add_option(
|
OPTION_DEVICE_CGROUP_RULES = OptionGroup().add_option(
|
||||||
"device_cgroup_rules", type="list", elements="str"
|
"device_cgroup_rules", value_type="list", elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_DNS_SERVERS = OptionGroup().add_option(
|
OPTION_DNS_SERVERS = OptionGroup().add_option(
|
||||||
"dns_servers", type="list", elements="str"
|
"dns_servers", value_type="list", elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_DNS_OPTS = OptionGroup().add_option("dns_opts", type="set", elements="str")
|
OPTION_DNS_OPTS = OptionGroup().add_option("dns_opts", value_type="set", elements="str")
|
||||||
|
|
||||||
OPTION_DNS_SEARCH_DOMAINS = OptionGroup().add_option(
|
OPTION_DNS_SEARCH_DOMAINS = OptionGroup().add_option(
|
||||||
"dns_search_domains", type="list", elements="str"
|
"dns_search_domains", value_type="list", elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_DOMAINNAME = OptionGroup().add_option("domainname", type="str")
|
OPTION_DOMAINNAME = OptionGroup().add_option("domainname", value_type="str")
|
||||||
|
|
||||||
OPTION_ENVIRONMENT = (
|
OPTION_ENVIRONMENT = (
|
||||||
OptionGroup(preprocess=_preprocess_env)
|
OptionGroup(preprocess=_preprocess_env)
|
||||||
.add_option(
|
.add_option(
|
||||||
"env", type="set", ansible_type="dict", elements="str", needs_no_suboptions=True
|
"env",
|
||||||
|
value_type="set",
|
||||||
|
ansible_type="dict",
|
||||||
|
elements="str",
|
||||||
|
needs_no_suboptions=True,
|
||||||
)
|
)
|
||||||
.add_option(
|
.add_option(
|
||||||
"env_file",
|
"env_file",
|
||||||
type="set",
|
value_type="set",
|
||||||
ansible_type="path",
|
ansible_type="path",
|
||||||
elements="str",
|
elements="str",
|
||||||
not_a_container_option=True,
|
not_a_container_option=True,
|
||||||
@ -1051,17 +1055,17 @@ OPTION_ENVIRONMENT = (
|
|||||||
|
|
||||||
OPTION_ETC_HOSTS = OptionGroup().add_option(
|
OPTION_ETC_HOSTS = OptionGroup().add_option(
|
||||||
"etc_hosts",
|
"etc_hosts",
|
||||||
type="set",
|
value_type="set",
|
||||||
ansible_type="dict",
|
ansible_type="dict",
|
||||||
elements="str",
|
elements="str",
|
||||||
needs_no_suboptions=True,
|
needs_no_suboptions=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_GROUPS = OptionGroup().add_option("groups", type="set", elements="str")
|
OPTION_GROUPS = OptionGroup().add_option("groups", value_type="set", elements="str")
|
||||||
|
|
||||||
OPTION_HEALTHCHECK = OptionGroup(preprocess=_preprocess_healthcheck).add_option(
|
OPTION_HEALTHCHECK = OptionGroup(preprocess=_preprocess_healthcheck).add_option(
|
||||||
"healthcheck",
|
"healthcheck",
|
||||||
type="dict",
|
value_type="dict",
|
||||||
ansible_suboptions=dict(
|
ansible_suboptions=dict(
|
||||||
test=dict(type="raw"),
|
test=dict(type="raw"),
|
||||||
test_cli_compatible=dict(type="bool", default=False),
|
test_cli_compatible=dict(type="bool", default=False),
|
||||||
@ -1073,69 +1077,71 @@ OPTION_HEALTHCHECK = OptionGroup(preprocess=_preprocess_healthcheck).add_option(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_HOSTNAME = OptionGroup().add_option("hostname", type="str")
|
OPTION_HOSTNAME = OptionGroup().add_option("hostname", value_type="str")
|
||||||
|
|
||||||
OPTION_IMAGE = OptionGroup().add_option("image", type="str")
|
OPTION_IMAGE = OptionGroup().add_option("image", value_type="str")
|
||||||
|
|
||||||
OPTION_INIT = OptionGroup().add_option("init", type="bool")
|
OPTION_INIT = OptionGroup().add_option("init", value_type="bool")
|
||||||
|
|
||||||
OPTION_IPC_MODE = OptionGroup().add_option("ipc_mode", type="str")
|
OPTION_IPC_MODE = OptionGroup().add_option("ipc_mode", value_type="str")
|
||||||
|
|
||||||
OPTION_KERNEL_MEMORY = OptionGroup(
|
OPTION_KERNEL_MEMORY = OptionGroup(
|
||||||
preprocess=partial(_preprocess_convert_to_bytes, name="kernel_memory")
|
preprocess=partial(_preprocess_convert_to_bytes, name="kernel_memory")
|
||||||
).add_option("kernel_memory", type="int", ansible_type="str")
|
).add_option("kernel_memory", value_type="int", ansible_type="str")
|
||||||
|
|
||||||
OPTION_LABELS = OptionGroup(preprocess=_preprocess_labels).add_option(
|
OPTION_LABELS = OptionGroup(preprocess=_preprocess_labels).add_option(
|
||||||
"labels", type="dict", needs_no_suboptions=True
|
"labels", value_type="dict", needs_no_suboptions=True
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_LINKS = OptionGroup().add_option(
|
OPTION_LINKS = OptionGroup().add_option(
|
||||||
"links", type="set", elements="list", ansible_elements="str"
|
"links", value_type="set", elements="list", ansible_elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_LOG_DRIVER_OPTIONS = (
|
OPTION_LOG_DRIVER_OPTIONS = (
|
||||||
OptionGroup(
|
OptionGroup(
|
||||||
preprocess=_preprocess_log, ansible_required_by={"log_options": ["log_driver"]}
|
preprocess=_preprocess_log, ansible_required_by={"log_options": ["log_driver"]}
|
||||||
)
|
)
|
||||||
.add_option("log_driver", type="str")
|
.add_option("log_driver", value_type="str")
|
||||||
.add_option(
|
.add_option(
|
||||||
"log_options",
|
"log_options",
|
||||||
type="dict",
|
value_type="dict",
|
||||||
ansible_aliases=["log_opt"],
|
ansible_aliases=["log_opt"],
|
||||||
needs_no_suboptions=True,
|
needs_no_suboptions=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_MAC_ADDRESS = OptionGroup(preprocess=_preprocess_mac_address).add_option(
|
OPTION_MAC_ADDRESS = OptionGroup(preprocess=_preprocess_mac_address).add_option(
|
||||||
"mac_address", type="str"
|
"mac_address", value_type="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_MEMORY = OptionGroup(
|
OPTION_MEMORY = OptionGroup(
|
||||||
preprocess=partial(_preprocess_convert_to_bytes, name="memory")
|
preprocess=partial(_preprocess_convert_to_bytes, name="memory")
|
||||||
).add_option("memory", type="int", ansible_type="str")
|
).add_option("memory", value_type="int", ansible_type="str")
|
||||||
|
|
||||||
OPTION_MEMORY_RESERVATION = OptionGroup(
|
OPTION_MEMORY_RESERVATION = OptionGroup(
|
||||||
preprocess=partial(_preprocess_convert_to_bytes, name="memory_reservation")
|
preprocess=partial(_preprocess_convert_to_bytes, name="memory_reservation")
|
||||||
).add_option("memory_reservation", type="int", ansible_type="str")
|
).add_option("memory_reservation", value_type="int", ansible_type="str")
|
||||||
|
|
||||||
OPTION_MEMORY_SWAP = OptionGroup(
|
OPTION_MEMORY_SWAP = OptionGroup(
|
||||||
preprocess=partial(
|
preprocess=partial(
|
||||||
_preprocess_convert_to_bytes, name="memory_swap", unlimited_value=-1
|
_preprocess_convert_to_bytes, name="memory_swap", unlimited_value=-1
|
||||||
)
|
)
|
||||||
).add_option("memory_swap", type="int", ansible_type="str")
|
).add_option("memory_swap", value_type="int", ansible_type="str")
|
||||||
|
|
||||||
OPTION_MEMORY_SWAPPINESS = OptionGroup().add_option("memory_swappiness", type="int")
|
OPTION_MEMORY_SWAPPINESS = OptionGroup().add_option(
|
||||||
|
"memory_swappiness", value_type="int"
|
||||||
|
)
|
||||||
|
|
||||||
OPTION_STOP_TIMEOUT = OptionGroup().add_option(
|
OPTION_STOP_TIMEOUT = OptionGroup().add_option(
|
||||||
"stop_timeout", type="int", default_comparison="ignore"
|
"stop_timeout", value_type="int", default_comparison="ignore"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_NETWORK = (
|
OPTION_NETWORK = (
|
||||||
OptionGroup(preprocess=_preprocess_networks)
|
OptionGroup(preprocess=_preprocess_networks)
|
||||||
.add_option("network_mode", type="str")
|
.add_option("network_mode", value_type="str")
|
||||||
.add_option(
|
.add_option(
|
||||||
"networks",
|
"networks",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="dict",
|
elements="dict",
|
||||||
ansible_suboptions=dict(
|
ansible_suboptions=dict(
|
||||||
name=dict(type="str", required=True),
|
name=dict(type="str", required=True),
|
||||||
@ -1150,81 +1156,81 @@ OPTION_NETWORK = (
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_OOM_KILLER = OptionGroup().add_option("oom_killer", type="bool")
|
OPTION_OOM_KILLER = OptionGroup().add_option("oom_killer", value_type="bool")
|
||||||
|
|
||||||
OPTION_OOM_SCORE_ADJ = OptionGroup().add_option("oom_score_adj", type="int")
|
OPTION_OOM_SCORE_ADJ = OptionGroup().add_option("oom_score_adj", value_type="int")
|
||||||
|
|
||||||
OPTION_PID_MODE = OptionGroup().add_option("pid_mode", type="str")
|
OPTION_PID_MODE = OptionGroup().add_option("pid_mode", value_type="str")
|
||||||
|
|
||||||
OPTION_PIDS_LIMIT = OptionGroup().add_option("pids_limit", type="int")
|
OPTION_PIDS_LIMIT = OptionGroup().add_option("pids_limit", value_type="int")
|
||||||
|
|
||||||
OPTION_PLATFORM = OptionGroup().add_option(
|
OPTION_PLATFORM = OptionGroup().add_option(
|
||||||
"platform", type="str", compare=_compare_platform
|
"platform", value_type="str", compare=_compare_platform
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_PRIVILEGED = OptionGroup().add_option("privileged", type="bool")
|
OPTION_PRIVILEGED = OptionGroup().add_option("privileged", value_type="bool")
|
||||||
|
|
||||||
OPTION_READ_ONLY = OptionGroup().add_option("read_only", type="bool")
|
OPTION_READ_ONLY = OptionGroup().add_option("read_only", value_type="bool")
|
||||||
|
|
||||||
OPTION_RESTART_POLICY = (
|
OPTION_RESTART_POLICY = (
|
||||||
OptionGroup(ansible_required_by={"restart_retries": ["restart_policy"]})
|
OptionGroup(ansible_required_by={"restart_retries": ["restart_policy"]})
|
||||||
.add_option(
|
.add_option(
|
||||||
"restart_policy",
|
"restart_policy",
|
||||||
type="str",
|
value_type="str",
|
||||||
ansible_choices=["no", "on-failure", "always", "unless-stopped"],
|
ansible_choices=["no", "on-failure", "always", "unless-stopped"],
|
||||||
)
|
)
|
||||||
.add_option("restart_retries", type="int")
|
.add_option("restart_retries", value_type="int")
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_RUNTIME = OptionGroup().add_option("runtime", type="str")
|
OPTION_RUNTIME = OptionGroup().add_option("runtime", value_type="str")
|
||||||
|
|
||||||
OPTION_SECURITY_OPTS = OptionGroup().add_option(
|
OPTION_SECURITY_OPTS = OptionGroup().add_option(
|
||||||
"security_opts", type="set", elements="str"
|
"security_opts", value_type="set", elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_SHM_SIZE = OptionGroup(
|
OPTION_SHM_SIZE = OptionGroup(
|
||||||
preprocess=partial(_preprocess_convert_to_bytes, name="shm_size")
|
preprocess=partial(_preprocess_convert_to_bytes, name="shm_size")
|
||||||
).add_option("shm_size", type="int", ansible_type="str")
|
).add_option("shm_size", value_type="int", ansible_type="str")
|
||||||
|
|
||||||
OPTION_STOP_SIGNAL = OptionGroup().add_option("stop_signal", type="str")
|
OPTION_STOP_SIGNAL = OptionGroup().add_option("stop_signal", value_type="str")
|
||||||
|
|
||||||
OPTION_STORAGE_OPTS = OptionGroup().add_option(
|
OPTION_STORAGE_OPTS = OptionGroup().add_option(
|
||||||
"storage_opts", type="dict", needs_no_suboptions=True
|
"storage_opts", value_type="dict", needs_no_suboptions=True
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_SYSCTLS = OptionGroup(preprocess=_preprocess_sysctls).add_option(
|
OPTION_SYSCTLS = OptionGroup(preprocess=_preprocess_sysctls).add_option(
|
||||||
"sysctls", type="dict", needs_no_suboptions=True
|
"sysctls", value_type="dict", needs_no_suboptions=True
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_TMPFS = OptionGroup(preprocess=_preprocess_tmpfs).add_option(
|
OPTION_TMPFS = OptionGroup(preprocess=_preprocess_tmpfs).add_option(
|
||||||
"tmpfs", type="dict", ansible_type="list", ansible_elements="str"
|
"tmpfs", value_type="dict", ansible_type="list", ansible_elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_TTY = OptionGroup().add_option("tty", type="bool")
|
OPTION_TTY = OptionGroup().add_option("tty", value_type="bool")
|
||||||
|
|
||||||
OPTION_ULIMITS = OptionGroup(preprocess=_preprocess_ulimits).add_option(
|
OPTION_ULIMITS = OptionGroup(preprocess=_preprocess_ulimits).add_option(
|
||||||
"ulimits", type="set", elements="dict", ansible_elements="str"
|
"ulimits", value_type="set", elements="dict", ansible_elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_USER = OptionGroup().add_option("user", type="str")
|
OPTION_USER = OptionGroup().add_option("user", value_type="str")
|
||||||
|
|
||||||
OPTION_USERNS_MODE = OptionGroup().add_option("userns_mode", type="str")
|
OPTION_USERNS_MODE = OptionGroup().add_option("userns_mode", value_type="str")
|
||||||
|
|
||||||
OPTION_UTS = OptionGroup().add_option("uts", type="str")
|
OPTION_UTS = OptionGroup().add_option("uts", value_type="str")
|
||||||
|
|
||||||
OPTION_VOLUME_DRIVER = OptionGroup().add_option("volume_driver", type="str")
|
OPTION_VOLUME_DRIVER = OptionGroup().add_option("volume_driver", value_type="str")
|
||||||
|
|
||||||
OPTION_VOLUMES_FROM = OptionGroup().add_option(
|
OPTION_VOLUMES_FROM = OptionGroup().add_option(
|
||||||
"volumes_from", type="set", elements="str"
|
"volumes_from", value_type="set", elements="str"
|
||||||
)
|
)
|
||||||
|
|
||||||
OPTION_WORKING_DIR = OptionGroup().add_option("working_dir", type="str")
|
OPTION_WORKING_DIR = OptionGroup().add_option("working_dir", value_type="str")
|
||||||
|
|
||||||
OPTION_MOUNTS_VOLUMES = (
|
OPTION_MOUNTS_VOLUMES = (
|
||||||
OptionGroup(preprocess=_preprocess_mounts)
|
OptionGroup(preprocess=_preprocess_mounts)
|
||||||
.add_option(
|
.add_option(
|
||||||
"mounts",
|
"mounts",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="dict",
|
elements="dict",
|
||||||
ansible_suboptions=dict(
|
ansible_suboptions=dict(
|
||||||
target=dict(type="str", required=True),
|
target=dict(type="str", required=True),
|
||||||
@ -1256,10 +1262,10 @@ OPTION_MOUNTS_VOLUMES = (
|
|||||||
tmpfs_options=dict(type="list", elements="dict"),
|
tmpfs_options=dict(type="list", elements="dict"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add_option("volumes", type="set", elements="str")
|
.add_option("volumes", value_type="set", elements="str")
|
||||||
.add_option(
|
.add_option(
|
||||||
"volume_binds",
|
"volume_binds",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="str",
|
elements="str",
|
||||||
not_an_ansible_option=True,
|
not_an_ansible_option=True,
|
||||||
copy_comparison_from="volumes",
|
copy_comparison_from="volumes",
|
||||||
@ -1270,21 +1276,21 @@ OPTION_PORTS = (
|
|||||||
OptionGroup(preprocess=_preprocess_ports)
|
OptionGroup(preprocess=_preprocess_ports)
|
||||||
.add_option(
|
.add_option(
|
||||||
"exposed_ports",
|
"exposed_ports",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="str",
|
elements="str",
|
||||||
ansible_aliases=["exposed", "expose"],
|
ansible_aliases=["exposed", "expose"],
|
||||||
)
|
)
|
||||||
.add_option("publish_all_ports", type="bool")
|
.add_option("publish_all_ports", value_type="bool")
|
||||||
.add_option(
|
.add_option(
|
||||||
"published_ports",
|
"published_ports",
|
||||||
type="dict",
|
value_type="dict",
|
||||||
ansible_type="list",
|
ansible_type="list",
|
||||||
ansible_elements="str",
|
ansible_elements="str",
|
||||||
ansible_aliases=["ports"],
|
ansible_aliases=["ports"],
|
||||||
)
|
)
|
||||||
.add_option(
|
.add_option(
|
||||||
"ports",
|
"ports",
|
||||||
type="set",
|
value_type="set",
|
||||||
elements="str",
|
elements="str",
|
||||||
not_an_ansible_option=True,
|
not_an_ansible_option=True,
|
||||||
default_comparison="ignore",
|
default_comparison="ignore",
|
||||||
|
|||||||
@ -119,12 +119,12 @@ _DEFAULT_IP_REPLACEMENT_STRING = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _get_ansible_type(type):
|
def _get_ansible_type(our_type):
|
||||||
if type == "set":
|
if our_type == "set":
|
||||||
return "list"
|
return "list"
|
||||||
if type not in ("list", "dict", "bool", "int", "float", "str"):
|
if our_type not in ("list", "dict", "bool", "int", "float", "str"):
|
||||||
raise Exception(f'Invalid type "{type}"')
|
raise Exception(f'Invalid type "{our_type}"')
|
||||||
return type
|
return our_type
|
||||||
|
|
||||||
|
|
||||||
_SENTRY = object()
|
_SENTRY = object()
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class DockerSocketHandlerBase(object):
|
|||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, type, value, tb):
|
def __exit__(self, type_, value, tb):
|
||||||
self._selector.close()
|
self._selector.close()
|
||||||
|
|
||||||
def set_block_done_callback(self, block_done_callback):
|
def set_block_done_callback(self, block_done_callback):
|
||||||
@ -204,9 +204,9 @@ class DockerSocketHandlerBase(object):
|
|||||||
self.select()
|
self.select()
|
||||||
return b"".join(stdout), b"".join(stderr)
|
return b"".join(stdout), b"".join(stderr)
|
||||||
|
|
||||||
def write(self, str):
|
def write(self, str_to_write):
|
||||||
self._write_buffer += str
|
self._write_buffer += str_to_write
|
||||||
if len(self._write_buffer) == len(str):
|
if len(self._write_buffer) == len(str_to_write):
|
||||||
self._write()
|
self._write()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -318,11 +318,11 @@ def dict_to_list(dictionary, concat="="):
|
|||||||
return [f"{k}{concat}{v}" for k, v in sorted(dictionary.items())]
|
return [f"{k}{concat}{v}" for k, v in sorted(dictionary.items())]
|
||||||
|
|
||||||
|
|
||||||
def _quote_csv(input):
|
def _quote_csv(text):
|
||||||
if input.strip() == input and all(i not in input for i in '",\r\n'):
|
if text.strip() == text and all(i not in text for i in '",\r\n'):
|
||||||
return input
|
return text
|
||||||
input = input.replace('"', '""')
|
text = text.replace('"', '""')
|
||||||
return f'"{input}"'
|
return f'"{text}"'
|
||||||
|
|
||||||
|
|
||||||
class ImageBuilder(DockerBaseClass):
|
class ImageBuilder(DockerBaseClass):
|
||||||
|
|||||||
@ -197,9 +197,9 @@ class DockerFileStore(object):
|
|||||||
Write config back out to disk.
|
Write config back out to disk.
|
||||||
"""
|
"""
|
||||||
# Make sure directory exists
|
# Make sure directory exists
|
||||||
dir = os.path.dirname(self._config_path)
|
directory = os.path.dirname(self._config_path)
|
||||||
if not os.path.exists(dir):
|
if not os.path.exists(directory):
|
||||||
os.makedirs(dir)
|
os.makedirs(directory)
|
||||||
# Write config; make sure it has permissions 0x600
|
# Write config; make sure it has permissions 0x600
|
||||||
content = json.dumps(self._config, indent=4, sort_keys=True).encode("utf-8")
|
content = json.dumps(self._config, indent=4, sort_keys=True).encode("utf-8")
|
||||||
f = os.open(self._config_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
f = os.open(self._config_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
||||||
|
|||||||
@ -15,7 +15,7 @@ from ansible_collections.community.docker.plugins.modules.docker_container_copy_
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"input, expected",
|
"value, expected",
|
||||||
[
|
[
|
||||||
("0777", 0o777),
|
("0777", 0o777),
|
||||||
("777", 0o777),
|
("777", 0o777),
|
||||||
@ -32,13 +32,13 @@ from ansible_collections.community.docker.plugins.modules.docker_container_copy_
|
|||||||
("-1", -1),
|
("-1", -1),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_parse_string(input, expected):
|
def test_parse_string(value, expected):
|
||||||
assert parse_modern(input) == expected
|
assert parse_modern(value) == expected
|
||||||
assert parse_octal_string_only(input) == expected
|
assert parse_octal_string_only(value) == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"input",
|
"value",
|
||||||
[
|
[
|
||||||
0o777,
|
0o777,
|
||||||
0o755,
|
0o755,
|
||||||
@ -47,14 +47,14 @@ def test_parse_string(input, expected):
|
|||||||
123456789012345678901234567890123456789012345678901234567890,
|
123456789012345678901234567890123456789012345678901234567890,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_parse_int(input):
|
def test_parse_int(value):
|
||||||
assert parse_modern(input) == input
|
assert parse_modern(value) == value
|
||||||
with pytest.raises(TypeError, match=f"^must be an octal string, got {input}L?$"):
|
with pytest.raises(TypeError, match=f"^must be an octal string, got {value}L?$"):
|
||||||
parse_octal_string_only(input)
|
parse_octal_string_only(value)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"input",
|
"value",
|
||||||
[
|
[
|
||||||
1.0,
|
1.0,
|
||||||
755.5,
|
755.5,
|
||||||
@ -62,23 +62,23 @@ def test_parse_int(input):
|
|||||||
{},
|
{},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_parse_bad_type(input):
|
def test_parse_bad_type(value):
|
||||||
with pytest.raises(TypeError, match="^must be an octal string or an integer, got "):
|
with pytest.raises(TypeError, match="^must be an octal string or an integer, got "):
|
||||||
parse_modern(input)
|
parse_modern(value)
|
||||||
with pytest.raises(TypeError, match="^must be an octal string, got "):
|
with pytest.raises(TypeError, match="^must be an octal string, got "):
|
||||||
parse_octal_string_only(input)
|
parse_octal_string_only(value)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"input",
|
"value",
|
||||||
[
|
[
|
||||||
"foo",
|
"foo",
|
||||||
"8",
|
"8",
|
||||||
"9",
|
"9",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_parse_bad_value(input):
|
def test_parse_bad_value(value):
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
parse_modern(input)
|
parse_modern(value)
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
parse_octal_string_only(input)
|
parse_octal_string_only(value)
|
||||||
|
|||||||
@ -14,7 +14,7 @@ from ansible_collections.community.docker.plugins.modules.docker_image_build imp
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"input, expected",
|
"value, expected",
|
||||||
[
|
[
|
||||||
("", ""),
|
("", ""),
|
||||||
(" ", '" "'),
|
(" ", '" "'),
|
||||||
@ -23,5 +23,5 @@ from ansible_collections.community.docker.plugins.modules.docker_image_build imp
|
|||||||
('\rhello, "hi" !\n', '"\rhello, ""hi"" !\n"'),
|
('\rhello, "hi" !\n', '"\rhello, ""hi"" !\n"'),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test__quote_csv(input, expected):
|
def test__quote_csv(value, expected):
|
||||||
assert _quote_csv(input) == expected
|
assert _quote_csv(value) == expected
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user