Ejemplo n.º 1
0
def main():
    """
    Main entry point for CLI
    :return: status code
    """
    parser = main_parser()
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit()
    args = parser.parse_args()
    LOG.debug(args)
    settings = ComposeXSettings(**vars(args))
    settings.set_bucket_name_from_account_id()
    settings.set_azs_from_api()
    LOG.debug(settings)

    if settings.deploy and not settings.upload:
        LOG.warning(
            "You must update the templates in order to deploy. We won't be deploying."
        )
        settings.deploy = False

    root_stack = generate_full_template(settings)
    process_stacks(root_stack, settings)

    if settings.deploy:
        deploy(settings, root_stack)
    return 0
Ejemplo n.º 2
0
def main():
    parser = main_parser()
    args = parser.parse_args()

    kwargs = vars(args)
    content = load_composex_file(kwargs[XFILE_DEST])
    validate_vpc_input(vars(args))
    validate_cluster_input(vars(args))

    print("Arguments: " + str(args._))
    templates_and_params = generate_full_template(content, **kwargs)

    render_final_template(templates_and_params[0])
    cfn_config = build_config_template_file(config={},
                                            parameters=templates_and_params[1])
    if keyisset("CfnConfigFile", vars(args)):
        config_file_name = args.CfnConfigFile
    else:
        config_file_name = f"{args.output_file.split('.')[0]}.config.json"
    config_file = FileArtifact(config_file_name,
                               content=cfn_config,
                               **vars(args))
    params_file = FileArtifact(
        f"{args.output_file.split('.')[0]}.params.json",
        content=templates_and_params[1],
        **vars(args),
    )
    template_file = FileArtifact(args.output_file,
                                 template=templates_and_params[0],
                                 **vars(args))
    template_file.create()
    params_file.create()
    config_file.create()
Ejemplo n.º 3
0
def main():
    """
    Main entry point for CLI
    :return: status code
    """
    parser = main_parser()
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit()
    args = parser.parse_args()
    LOG.debug(args)
    settings = ComposeXSettings(**vars(args))
    settings.set_bucket_name_from_account_id()
    LOG.debug(settings)

    if settings.deploy and not settings.upload:
        LOG.warning(
            "You must update the templates in order to deploy. We won't be deploying."
        )
        settings.deploy = False
    evaluate_docker_configs(settings)
    scan_results = evaluate_ecr_configs(settings)
    if scan_results and not settings.ignore_ecr_findings:
        warnings.warn("SCAN Images failed for instructed images. Failure")
        return 1
    root_stack = generate_full_template(settings)
    process_stacks(root_stack, settings)

    if settings.deploy:
        deploy(settings, root_stack)
    elif settings.plan:
        plan(settings, root_stack)
    return 0
Ejemplo n.º 4
0
def step_impl(context):

    cases_path = [
        path.abspath(f"{here()}/../../../{file_name}")
        for file_name in context.files
    ]
    print(cases_path)
    with raises(Exception):
        context.settings = ComposeXSettings(
            profile_name=getattr(context, "profile_name") if hasattr(
                context, "profile_name") else None,
            **{
                ComposeXSettings.name_arg: "test",
                ComposeXSettings.command_arg: ComposeXSettings.render_arg,
                ComposeXSettings.input_file_arg: cases_path,
                ComposeXSettings.format_arg: "yaml",
            },
        )
        context.settings.set_bucket_name_from_account_id()
        generate_full_template(context.settings)
Ejemplo n.º 5
0
def step_impl(context):
    context.root_stack = generate_full_template(context.settings)
Ejemplo n.º 6
0
def step_impl(context):
    with raises((ValueError, KeyError, ComposeBaseException)):
        context.root_stack = generate_full_template(context.settings)
Ejemplo n.º 7
0
def set_impl(context):
    if not hasattr(context, "root_stack"):
        context.root_stack = generate_full_template(context.settings)
    process_stacks(context.root_stack, context.settings)