How to use the sceptre.cli.helpers.write function in sceptre

To help you get started, we’ve selected a few sceptre examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Sceptre / sceptre / tests / test_cli.py View on Github external
def test_write_formats(
        self, mock_echo, output_format, no_colour, expected_output
    ):
        write({"stack": "CREATE_COMPLETE"}, output_format, no_colour)
        mock_echo.assert_called_once_with(expected_output)
github Sceptre / sceptre / tests / test_cli.py View on Github external
def test_write_status_without_colour(self, mock_echo):
        write("stack: CREATE_COMPLETE", no_colour=True)
        mock_echo.assert_called_once_with('{\n    "stack": "CREATE_COMPLETE"\n}')
github Sceptre / sceptre / sceptre / cli / update.py View on Github external
change_set_name = "-".join(["change-set", uuid1().hex])
        plan.create_change_set(change_set_name)
        try:
            # Wait for change set to be created
            statuses = plan.wait_for_cs_completion(change_set_name)
            # Exit if change set fails to create
            for status in list(statuses.values()):
                if status != StackChangeSetStatus.READY:
                    exit(1)

            # Describe changes
            descriptions = plan.describe_change_set(change_set_name)
            for description in list(descriptions.values()):
                if not verbose:
                    description = simplify_change_set_description(description)
                write(description, context.output_format)

            # Execute change set if happy with changes
            if yes or click.confirm("Proceed with stack update?"):
                plan.execute_change_set(change_set_name)
        except Exception as e:
            raise e
        finally:
            # Clean up by deleting change set
            plan.delete_change_set(change_set_name)
    else:
        confirmation("update", yes, command_path=path)
        responses = plan.update()
        exit(stack_status_exit_code(responses.values()))
github Sceptre / sceptre / sceptre / cli / describe.py View on Github external
:type path: str
    """
    context = SceptreContext(
        command_path=path,
        project_path=ctx.obj.get("project_path"),
        user_variables=ctx.obj.get("user_variables"),
        options=ctx.obj.get("options"),
        output_format=ctx.obj.get("output_format"),
        no_colour=ctx.obj.get("no_colour"),
        ignore_dependencies=ctx.obj.get("ignore_dependencies")
    )

    plan = SceptrePlan(context)
    responses = plan.get_policy()
    for response in responses.values():
        write(
            response,
            context.output_format,
            context.no_colour
        )
github Sceptre / sceptre / sceptre / cli / template.py View on Github external
command_path=path,
        project_path=ctx.obj.get("project_path"),
        user_variables=ctx.obj.get("user_variables"),
        options=ctx.obj.get("options"),
        output_format=ctx.obj.get("output_format"),
        ignore_dependencies=ctx.obj.get("ignore_dependencies")
    )

    plan = SceptrePlan(context)
    responses = plan.validate()

    for stack, response in responses.items():
        if response['ResponseMetadata']['HTTPStatusCode'] == 200:
            del response['ResponseMetadata']
            click.echo("Template {} is valid. Template details:\n".format(stack.name))
        write(response, context.output_format)
github Sceptre / sceptre / sceptre / cli / list.py View on Github external
plan = SceptrePlan(context)
    responses = [
        response for response
        in plan.describe_outputs().values() if response
    ]

    if export == "envvar":
        for response in responses:
            for stack in response.values():
                for output in stack:
                    write("export SCEPTRE_{0}='{1}'".format(
                        output.get("OutputKey"),
                        output.get("OutputValue")
                    ), 'text')
    else:
        write(responses, context.output_format)
github Sceptre / sceptre / sceptre / cli / describe.py View on Github external
project_path=ctx.obj.get("project_path"),
        user_variables=ctx.obj.get("user_variables"),
        options=ctx.obj.get("options"),
        output_format=ctx.obj.get("output_format"),
        no_colour=ctx.obj.get("no_colour"),
        ignore_dependencies=ctx.obj.get("ignore_dependencies")
    )

    plan = SceptrePlan(context)

    responses = plan.describe_change_set(change_set_name)
    for response in responses.values():
        description = response
        if not verbose:
            description = simplify_change_set_description(description)
        write(description, context.output_format, context.no_colour)
github Sceptre / sceptre / sceptre / cli / template.py View on Github external
:param path: Path to execute the command on.
    :type path: str
    """
    context = SceptreContext(
        command_path=path,
        project_path=ctx.obj.get("project_path"),
        user_variables=ctx.obj.get("user_variables"),
        options=ctx.obj.get("options"),
        output_format=ctx.obj.get("output_format"),
        ignore_dependencies=ctx.obj.get("ignore_dependencies")
    )

    plan = SceptrePlan(context)
    responses = plan.generate()
    output = [template for template in responses.values()]
    write(output, context.output_format)
github Sceptre / sceptre / sceptre / cli / list.py View on Github external
command_path=path,
        project_path=ctx.obj.get("project_path"),
        user_variables=ctx.obj.get("user_variables"),
        output_format=ctx.obj.get("output_format"),
        options=ctx.obj.get("options"),
        ignore_dependencies=ctx.obj.get("ignore_dependencies")
    )

    plan = SceptrePlan(context)
    responses = [
        response for response
        in plan.list_change_sets().values() if response
    ]

    for response in responses:
        write(response, context.output_format)
github Sceptre / sceptre / sceptre / cli / list.py View on Github external
context = SceptreContext(
        command_path=path,
        project_path=ctx.obj.get("project_path"),
        user_variables=ctx.obj.get("user_variables"),
        options=ctx.obj.get("options"),
        output_format=ctx.obj.get("output_format"),
        ignore_dependencies=ctx.obj.get("ignore_dependencies")
    )
    plan = SceptrePlan(context)

    responses = [
        response for response
        in plan.describe_resources().values() if response
    ]

    write(responses, context.output_format)