Пример #1
0
def build_image(verbose, **kwargs):
    ci_image_params = BuildParams(filter_out_none(**kwargs))
    is_cached, value = check_cache_and_write_if_not_cached(
        "PYTHON_MAJOR_MINOR_VERSION", ci_image_params.python_version)
    if is_cached:
        ci_image_params.python_version = value
    cmd = construct_docker_command(ci_image_params)
    output = run_command(cmd, verbose=verbose, text=True)
    console.print(f"[blue]{output}")
Пример #2
0
def get_cached_params(user_params) -> Dict:
    updated_params = dict(user_params)
    for param in PARAMS_IN_CACHE:
        if param in user_params:
            param_name = PARAMS_IN_CACHE[param]
            user_param_value = user_params[param]
            if user_param_value is not None:
                write_to_cache_file(param_name, user_param_value)
            else:
                param_value = getattr(global_constants, DEFAULT_VALUES_FOR_PARAM[param])
                _, user_param_value = check_cache_and_write_if_not_cached(param_name, param_value)
            updated_params[param] = user_param_value
    return updated_params
Пример #3
0
def get_image_build_params(parameters_passed: Dict[str, str]):
    cacheable_parameters = {"python_version": 'PYTHON_MAJOR_MINOR_VERSION'}
    ci_image_params = BuildParams(**parameters_passed)
    for parameter, cache_key in cacheable_parameters.items():
        value_from_parameter = parameters_passed.get(parameter)
        if value_from_parameter:
            write_to_cache_file(cache_key, value_from_parameter, check_allowed_values=True)
            setattr(ci_image_params, parameter, value_from_parameter)
        else:
            is_cached, value = check_cache_and_write_if_not_cached(
                cache_key, getattr(ci_image_params, parameter)
            )
            if is_cached:
                setattr(ci_image_params, parameter, value)
    return ci_image_params