How to use the aiodocker.utils.format_env function in aiodocker

To help you get started, we’ve selected a few aiodocker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / aiodocker / tests / test_utils.py View on Github external
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"
github aio-libs / aiodocker / tests / test_utils.py View on Github external
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"
github aio-libs / aiodocker / tests / test_utils.py View on Github external
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"
github aio-libs / aiodocker / aiodocker / services.py View on Github external
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,