mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
Sanitize labels. (#985)
This commit is contained in:
@@ -248,6 +248,8 @@ from ansible_collections.community.docker.plugins.module_utils.compose_v2 import
|
||||
common_compose_argspec_ex,
|
||||
)
|
||||
|
||||
from ansible_collections.community.docker.plugins.module_utils.util import sanitize_labels
|
||||
|
||||
|
||||
class ExecManager(BaseComposeManager):
|
||||
def __init__(self, client):
|
||||
@@ -416,6 +418,7 @@ def main():
|
||||
needs_api_version=False,
|
||||
**argspec_ex
|
||||
)
|
||||
sanitize_labels(client.module.params['labels'], 'labels', client)
|
||||
|
||||
try:
|
||||
manager = ExecManager(client)
|
||||
|
||||
@@ -212,6 +212,7 @@ from ansible_collections.community.docker.plugins.module_utils.common import (
|
||||
from ansible_collections.community.docker.plugins.module_utils.util import (
|
||||
DockerBaseClass,
|
||||
compare_generic,
|
||||
sanitize_labels,
|
||||
)
|
||||
from ansible.module_utils.common.text.converters import to_native, to_bytes
|
||||
|
||||
@@ -414,6 +415,7 @@ def main():
|
||||
min_docker_api_version='1.30',
|
||||
option_minimal_versions=option_minimal_versions,
|
||||
)
|
||||
sanitize_labels(client.module.params['labels'], 'labels', client)
|
||||
|
||||
try:
|
||||
results = dict(
|
||||
|
||||
@@ -284,6 +284,7 @@ from ansible_collections.community.docker.plugins.module_utils.util import (
|
||||
DockerBaseClass,
|
||||
DifferenceTracker,
|
||||
clean_dict_booleans_for_docker_api,
|
||||
sanitize_labels,
|
||||
)
|
||||
from ansible_collections.community.docker.plugins.module_utils._api.errors import DockerException
|
||||
|
||||
@@ -698,6 +699,7 @@ def main():
|
||||
# "The docker server >= 1.10.0"
|
||||
option_minimal_versions=option_minimal_versions,
|
||||
)
|
||||
sanitize_labels(client.module.params['labels'], 'labels', client)
|
||||
|
||||
try:
|
||||
cm = DockerNetworkManager(client)
|
||||
|
||||
@@ -153,6 +153,7 @@ from ansible_collections.community.docker.plugins.module_utils.common import (
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
|
||||
from ansible_collections.community.docker.plugins.module_utils.swarm import AnsibleDockerSwarmClient
|
||||
from ansible_collections.community.docker.plugins.module_utils.util import sanitize_labels
|
||||
|
||||
|
||||
class TaskParameters(DockerBaseClass):
|
||||
@@ -172,6 +173,8 @@ class TaskParameters(DockerBaseClass):
|
||||
for key, value in client.module.params.items():
|
||||
setattr(self, key, value)
|
||||
|
||||
sanitize_labels(self.labels, "labels", client)
|
||||
|
||||
|
||||
class SwarmNodeManager(DockerBaseClass):
|
||||
|
||||
|
||||
@@ -204,6 +204,7 @@ from ansible_collections.community.docker.plugins.module_utils.common import (
|
||||
from ansible_collections.community.docker.plugins.module_utils.util import (
|
||||
DockerBaseClass,
|
||||
compare_generic,
|
||||
sanitize_labels,
|
||||
)
|
||||
from ansible.module_utils.common.text.converters import to_native, to_bytes
|
||||
|
||||
@@ -384,6 +385,7 @@ def main():
|
||||
mutually_exclusive=mutually_exclusive,
|
||||
min_docker_version='2.1.0',
|
||||
)
|
||||
sanitize_labels(client.module.params['labels'], 'labels', client)
|
||||
|
||||
try:
|
||||
results = dict(
|
||||
|
||||
@@ -324,6 +324,7 @@ from ansible_collections.community.docker.plugins.module_utils.common import (
|
||||
)
|
||||
from ansible_collections.community.docker.plugins.module_utils.util import (
|
||||
DifferenceTracker,
|
||||
sanitize_labels,
|
||||
)
|
||||
|
||||
from ansible_collections.community.docker.plugins.module_utils.swarm import AnsibleDockerSwarmClient
|
||||
@@ -714,6 +715,7 @@ def main():
|
||||
min_docker_version='1.10.0',
|
||||
option_minimal_versions=option_minimal_versions,
|
||||
)
|
||||
sanitize_labels(client.module.params['labels'], 'labels', client)
|
||||
|
||||
try:
|
||||
results = dict(
|
||||
|
||||
@@ -954,6 +954,7 @@ from ansible_collections.community.docker.plugins.module_utils.util import (
|
||||
convert_duration_to_nanosecond,
|
||||
parse_healthcheck,
|
||||
clean_dict_booleans_for_docker_api,
|
||||
sanitize_labels,
|
||||
)
|
||||
|
||||
from ansible.module_utils.basic import human_to_bytes
|
||||
@@ -1531,10 +1532,9 @@ class DockerService(DockerBaseClass):
|
||||
secret_ids,
|
||||
config_ids,
|
||||
network_ids,
|
||||
docker_api_version,
|
||||
docker_py_version,
|
||||
client,
|
||||
):
|
||||
s = DockerService(docker_api_version, docker_py_version)
|
||||
s = DockerService(client.docker_api_version, client.docker_py_version)
|
||||
s.image = image_digest
|
||||
s.args = ap['args']
|
||||
s.endpoint_mode = ap['endpoint_mode']
|
||||
@@ -1546,7 +1546,9 @@ class DockerService(DockerBaseClass):
|
||||
s.hosts = ap['hosts']
|
||||
s.tty = ap['tty']
|
||||
s.labels = ap['labels']
|
||||
sanitize_labels(s.labels, 'labels', client)
|
||||
s.container_labels = ap['container_labels']
|
||||
sanitize_labels(s.container_labels, 'container_labels', client)
|
||||
s.sysctls = ap['sysctls']
|
||||
s.mode = ap['mode']
|
||||
s.stop_signal = ap['stop_signal']
|
||||
@@ -2488,8 +2490,7 @@ class DockerServiceManager(object):
|
||||
secret_ids,
|
||||
config_ids,
|
||||
network_ids,
|
||||
self.client.docker_api_version,
|
||||
self.client.docker_py_version
|
||||
self.client,
|
||||
)
|
||||
except Exception as e:
|
||||
return self.client.fail(
|
||||
|
||||
@@ -127,6 +127,7 @@ from ansible_collections.community.docker.plugins.module_utils.common_api import
|
||||
from ansible_collections.community.docker.plugins.module_utils.util import (
|
||||
DockerBaseClass,
|
||||
DifferenceTracker,
|
||||
sanitize_labels,
|
||||
)
|
||||
from ansible_collections.community.docker.plugins.module_utils._api.errors import (
|
||||
APIError,
|
||||
@@ -296,6 +297,7 @@ def main():
|
||||
supports_check_mode=True,
|
||||
# "The docker server >= 1.9.0"
|
||||
)
|
||||
sanitize_labels(client.module.params['labels'], 'labels', client)
|
||||
|
||||
try:
|
||||
cm = DockerVolumeManager(client)
|
||||
|
||||
Reference in New Issue
Block a user