def process()

in deploy/patch_deployment.py [0:0]


def process(config: object):
    filename = os.path.dirname(os.path.realpath(__file__)) + '/deploy-all.yaml'
    if config.input:
        filename = config.input

    with open(filename) as f:
        docs = list(yaml.load_all(f, Loader=yaml.FullLoader))

    operator = None
    for doc in docs:
        if doc["kind"] == "Deployment" and doc["metadata"]["name"] == "mysql-operator":
            operator = doc

    if not operator:
        raise Exception(f"Input {filename} contains no operator deployment!")

    container_spec = operator["spec"]["template"]["spec"]["containers"][0]
    container_spec["imagePullPolicy"] = config.pull_policy
    if config.prefix:
        container_spec["image"] = container_spec["image"].replace("container-registry.oracle.com/mysql", config.prefix, 1)
        if config.prefix != "mysql":
            add_env(container_spec, "MYSQL_OPERATOR_DEFAULT_REPOSITORY", config.prefix)

    if config.debug:
        add_env(container_spec, "MYSQL_OPERATOR_DEFAULT_DEBUG", "1")

    if config.pull_secret:
        operator["spec"]["template"]["spec"]["imagePullSecrets"] = [{"name": config.pull_secret}]

    if config.source_volume:
        container_spec["volumeMounts"].append({
            "mountPath": "/usr/lib/mysqlsh/python-packages/mysqloperator",
            "name": "operator-source-volume"
        })
        operator["spec"]["template"]["spec"]["volumes"].append({
            "name": "operator-source-volume",
            "hostPath": {
                  "path": config.source_volume,
                  "type": "Directory"
            }
        })

    return docs