Ejemplo n.º 1
0
def generate_docker_credential(docker_info):

    username = docker_info[ "docker_username" ] and str(docker_info[ "docker_username" ])
    passwd = docker_info[ "docker_password" ] and str(docker_info[ "docker_password" ])

    if username and passwd:
        credential = linux_shell.execute_shell_with_output(
            "cat ~/.docker/config.json",
            "Failed to get the docker's config.json"
        )
    else:
        credential = "{}"

    docker_info["credential"] = credential
Ejemplo n.º 2
0
def generate_secret_base64code(docker_info):

    domain = docker_info[ "docker_registry_domain" ] and str(docker_info[ "docker_registry_domain" ])
    username = docker_info[ "docker_username" ] and str(docker_info[ "docker_username" ])
    passwd = docker_info[ "docker_password" ] and str(docker_info[ "docker_password" ])

    if domain == "public":
        domain = ""

    if username and passwd:
        login_docker_registry( domain, username, passwd )

        base64code = linux_shell.execute_shell_with_output(
            "cat ~/.docker/config.json | base64",
            "Failed to base64 the docker's config.json"
        )
    else:
        logger.info("docker registry authentication not provided")

        base64code = "{}".encode("base64")

    docker_info["base64code"] = base64code.replace("\n", "")