Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change set display doesn't follow --output flag #1180

Closed
dboitnot opened this issue Dec 5, 2021 · 4 comments
Closed

Change set display doesn't follow --output flag #1180

dboitnot opened this issue Dec 5, 2021 · 4 comments

Comments

@dboitnot
Copy link
Contributor

dboitnot commented Dec 5, 2021

Change set display doesn't follow --output flag

Despite being referenced in update.py, it appears that the ChangeSet display does not use the setting from the --output flag.

Your environment

  • Sceptre, version 2.7.0
  • Python 3.8.2
  • Environment: python:3.8.2-slim docker image

Steps to reproduce

sceptre --output=yaml update -c ban/banner-app-image-build.yaml
[2021-12-05 16:45:57] - ban/banner-app-image-build - Successfully initiated creation of Change Set 'change-set-d167800455ea11ec86ff0242ac110002'
{'ChangeSetName': 'change-set-d167800455ea11ec86ff0242ac110002', 'StackName': 's-ban-banner-app-image-build', 'CreationTime': datetime.datetime(2021, 12, 5, 16, 45, 57, 184000, tzinfo=tzlocal()), 'ExecutionStatus': 'AVAILABLE', 'Status': 'CREATE_COMPLETE', 'Changes': [{'ResourceChange': {'Action': 'Modify', 'LogicalResourceId': 'CodeBuildProject', 'PhysicalResourceId': 'banner-app', 'ResourceType': 'AWS::CodeBuild::Project', 'Replacement': 'Conditional', 'Scope': ['Properties']}}]}

Expected behaviour

ChangeSet should be displayed in YAML format.

Actual behaviour

ChangeSet is displayed in JSON format.

Notes

The output flag is clearly being parsed, because if a malformed value is provided we get an error:

$ sceptre --output=yamll update -c ban/banner-app-image-build.yaml
Usage: sceptre [OPTIONS] COMMAND [ARGS]...
Try 'sceptre --help' for help.

Error: Invalid value for '--output': 'yamll' is not one of 'text', 'yaml', 'json'.

Further, since this is an interactive process, we don't expect this output to be machine-parsed. I'd therefore think that YAML, being vastly more readable, would be a better default.

Possibly, I'm misunderstanding the purpose of the --output flag, because if I force the value to yaml in update.py I still get JSON output:

            # 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, 'yaml')

For what it's worth, I made the following patch:

            # 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('-'*80,'text')
                write(yaml.dump(description), 'text')
                write('-'*80,'text')

I think the output is an improvement:

sceptre  update -c ban/banner-app-image-build.yaml                                             [17:19:43]
[2021-12-05 17:19:53] - ban/banner-app-image-build - Successfully initiated creation of Change Set 'change-set-8efdd8f855ef11ec8b790242ac110002'
--------------------------------------------------------------------------------
ChangeSetName: change-set-8efdd8f855ef11ec8b790242ac110002
Changes:
- ResourceChange:
    Action: Modify
    LogicalResourceId: CodeBuildProject
    PhysicalResourceId: banner-app
    Replacement: Conditional
    ResourceType: AWS::CodeBuild::Project
    Scope:
    - Properties
CreationTime: 2021-12-05 17:19:53.227000+00:00
ExecutionStatus: AVAILABLE
StackName: sig-ban-banner-app-image-build
Status: CREATE_COMPLETE

--------------------------------------------------------------------------------
Proceed with stack update? [y/N]:
@zaro0508
Copy link
Contributor

zaro0508 commented Dec 5, 2021

could you please propose your patch as a PR @dboitnot?

@dboitnot
Copy link
Contributor Author

dboitnot commented Dec 9, 2021

Added PR #1183

dboitnot added a commit to dboitnot/sceptre that referenced this issue Dec 9, 2021
@jfalkenstein
Copy link
Contributor

This seems related to #1173

@dboitnot
Copy link
Contributor Author

This is no longer an issue in the current version of Sceptre.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants