Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_format_env():
key = "name"
value = "hello"
assert utils.format_env(key, value) == "name=hello"
key = "name"
value = None
assert utils.format_env(key, value) == "name"
key = "name"
value = b"hello"
assert utils.format_env(key, value) == "name=hello"
def test_format_env():
key = "name"
value = "hello"
assert utils.format_env(key, value) == "name=hello"
key = "name"
value = None
assert utils.format_env(key, value) == "name"
key = "name"
value = b"hello"
assert utils.format_env(key, value) == "name=hello"
def test_format_env():
key = "name"
value = "hello"
assert utils.format_env(key, value) == "name=hello"
key = "name"
value = None
assert utils.format_env(key, value) == "name"
key = "name"
value = b"hello"
assert utils.format_env(key, value) == "name=hello"
Returns:
a dict with info of the created service
"""
if "Image" not in task_template["ContainerSpec"]:
raise KeyError("Missing mandatory Image key in ContainerSpec")
if auth and registry is None:
raise KeyError(
"When auth is specified you need to specifiy also the registry"
)
# from {"key":"value"} to ["key=value"]
if "Env" in task_template["ContainerSpec"]:
task_template["ContainerSpec"]["Env"] = [
format_env(k, v)
for k, v in task_template["ContainerSpec"]["Env"].items()
]
headers = None
if auth:
headers = {"X-Registry-Auth": compose_auth_header(auth, registry)}
config = {
"TaskTemplate": task_template,
"Name": name,
"Labels": labels,
"Mode": mode,
"UpdateConfig": update_config,
"RollbackConfig": rollback_config,
"Networks": clean_networks(networks),
"EndpointSpec": endpoint_spec,