Пример #1
0
def process_local_config(config, app_names, get_dependencies, set_image_tag, processed_apps=None):
    k8s_list = {
        "kind": "List",
        "apiVersion": "v1",
        "metadata": {},
        "items": [],
    }

    if not processed_apps:
        processed_apps = set()

    apps_cfg = {a["name"]: a for a in config["apps"]}

    image_tag_overrides = split_equals(set_image_tag)

    for app_name in set(app_names):
        if app_name not in apps_cfg:
            raise ValueError("app %s not found in local config" % app_name)
        log.info("processing app '%s'", app_name)
        _process_app(
            app_name,
            apps_cfg,
            config,
            k8s_list,
            get_dependencies,
            image_tag_overrides,
            processed_apps,
        )

    return k8s_list
Пример #2
0
def _get_app_config(apps, src_env, ref_env, set_template_ref, set_image_tag,
                    get_dependencies, namespace):
    try:
        template_ref_overrides = split_equals(set_template_ref)
        image_tag_overrides = split_equals(set_image_tag)
    except ValueError as err:
        _error(str(err))
    apps_config = get_apps_config(
        apps.split(","),
        src_env,
        ref_env,
        template_ref_overrides,
        image_tag_overrides,
        get_dependencies,
        namespace,
    )
    return apps_config
Пример #3
0
def _validate_set_parameter(ctx, param, value):
    try:
        split_value = split_equals(value)
        if split_value:
            # check that values unpack properly
            for param_path, value in split_value.items():
                app_name, component_name, param_name = param_path.split("/")
        return split_value
    except ValueError:
        raise click.BadParameter("format must be '<app>/<component>/<param>=<value>'")
Пример #4
0
def _validate_set_template_ref(ctx, param, value):
    try:
        split_value = split_equals(value)
        if split_value:
            # check that values unpack properly
            for app_component, value in split_value.items():
                app_name, component_name = app_component.split("/")
        return split_value
    except ValueError:
        raise click.BadParameter("format must be '<app>/<component>=<ref>'")
Пример #5
0
def _create_pod(namespace, pod_name, env):
    pod = _get_base_pod_cfg()

    pod["metadata"]["name"] = pod_name
    env_vars = split_equals(env, allow_null=True)
    if env_vars:
        pod_env_vars = pod["spec"]["containers"][0]["env"]
        for key, val in env_vars.items():
            if val:
                pod_env_vars.append({"name": key, "value": val})

    oc("create", f="-", n=namespace, _in=json.dumps(pod))
Пример #6
0
def _validate_set_template_ref(ctx, param, value):
    try:
        split_value = split_equals(value)
        if split_value:
            # check that values unpack properly
            for app_component, value in split_value.items():
                # TODO: remove once app name syntax fully deprecated
                split = app_component.split("/")
                if len(split) == 2:
                    warnings.warn(
                        ("--set-template-ref: <app>/<component>=<ref> syntax is deprecated, "
                         "use <component>=<ref>"),
                        DeprecationWarning,
                    )
                elif len(split) > 2:
                    raise ValueError
        return split_value
    except ValueError:
        raise click.BadParameter("format must be '<component>=<ref>'")
Пример #7
0
def _validate_set_parameter(ctx, param, value):
    try:
        split_value = split_equals(value)
        if split_value:
            # check that values unpack properly
            for param_path, value in split_value.items():
                # TODO: remove once app name syntax fully deprecated
                split = param_path.split("/")
                if len(split) == 3:
                    warnings.warn(
                        ("--set-parameter: <app>/<component>/<param>=<value> syntax is "
                         "deprecated, use <component>/<param>=<value>"),
                        DeprecationWarning,
                    )
                elif len(split) < 2 or len(split) > 3:
                    raise ValueError
        return split_value
    except ValueError:
        raise click.BadParameter(
            "format must be '<component>/<param>=<value>'")
Пример #8
0
def _validate_set_image_tag(ctx, param, value):
    try:
        return split_equals(value)
    except ValueError:
        raise click.BadParameter("format must be '<image uri>=<tag>'")