def main()

in 02_bootstrap-scripts-python/bootstrap/bootstrap.py [0:0]


def main() -> None:
    parser = init_argparse()
    args = parser.parse_args()
    helm_exe = Helm()
    helm_context = HelmValuesBuilder()
    command_instance = helm_exe.get_command_instance()
    values_file = None
    if args.values is not None:
        values_file = args.values
    if args.upgrade:
        command_instance.set_main_arg("upgrade")
        command_instance.set_release(args.release)
        command_instance.add_args("-i")
    elif args.template:
        command_instance.set_main_arg("template")
    if args.chart is not None:
        command_instance.set_chart(args.chart)
        if values_file is None:
            values_file = path.join(args.chart, "values.yaml")
        helm_context.add_context(
                FileContext(values_file, {'type': 'yaml'}))
        f = None
    else:
        chart_path, f = helm_exe.pullHelmChart(
            environ.get("HELM_IMAGE_TAG", default="latest"))
        command_instance.set_chart(chart_path)
        if values_file is None:
            values_file = path.join(chart_path, "values.yaml")
        helm_context.add_context(
                FileContext(values_file, {'type': 'yaml'}))
        addHelmValues(args.json, args.artifact, helm_context)

    if args.helm_arg is not None:
        print("printing arguments")
        argumentList = []
        for argument in args.helm_arg:
            argumentList.extend(argument[0].split())
        print(argumentList)
        command_instance.add_args(*argumentList)
    if args.context is not None:
        for context in args.context:
            helm_context.add_context_from_string(context[0])
    values = helm_context.get_values()
    if args.print_values:
        print("Using Values:")
        print_values_yaml(values)
    v_path = helm_exe.generate_values_file(values)
    print("Using values file at: " + v_path)
    command_instance.set_values(v_path)
    command_instance.run(force_output=True)
    if f is not None:
        f.cleanup()
    sys.exit(command_instance.exit_code)