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

Format policy_templates.json #2760

Merged
merged 3 commits into from
Dec 22, 2022

Conversation

mustafa-sadiq
Copy link
Contributor

Issue #, if available

None I can find

Description of changes

The policy_templates.json has many formatting discrepancies. For example

CloudWatchDescribeAlarmHistoryPolicy has

"Parameters": {},

where as others have a empty block with white space

"Parameters": {

      },

RekognitionFacesManagementPolicy has not been formated with array object like other Statement objects

"Statement": [{
          "Effect": "Allow",
          "Action": [
            "rekognition:IndexFaces",
            "rekognition:DeleteFaces",
            "rekognition:SearchFaces",
            "rekognition:SearchFacesByImage",
            "rekognition:ListFaces"
          ],

Description of how you validated changes

policy_templates.json is still valid JSON

cat samtranslator/policy_templates_data/policy_templates.json | jq .

Checklist

Examples?

Please reach out in the comments if you want to add an example. Examples will be
added to sam init through aws/aws-sam-cli-app-templates.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mustafa-sadiq mustafa-sadiq requested a review from a team as a code owner December 21, 2022 08:02
@mustafa-sadiq mustafa-sadiq changed the title Format policy_tempaltes.json Format policy_templates.json Dec 21, 2022
Copy link
Contributor

@aahung aahung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this up. Can you also add this file to CI check so its format can be enforced? Thanks:

related code:

bin/json-format.py --check tests integration

- added policy_templates.json to Makefile json-format.py
- formatted it using json-format.py
@mustafa-sadiq
Copy link
Contributor Author

thank you for the review! added it to Makefile black json-format.py and also formatted it using it

Looks like it was not previously added to it as it formats it with regards to layout as well (e.g. "Version" at the end of the file instead of at the beginning) which not be the behavior we want. I can revert this change if you want.

@ssenchenko
Copy link
Contributor

Consistent automated formatting is better than a fancy but manual one. I'd say it stays.

Copy link
Contributor

@aahung aahung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified with

bin/json-format.py --write samtranslator/policy_templates_data/policy_templates.json
reformatted samtranslator/policy_templates_data/policy_templates.json
1 file(s) scanned.
1 file(s) reformatted.
All done! ✨ 🍰 ✨
(samtranslator37) ~/P/serverless-application-model ❯❯❯ cp samtranslator/policy_templates_data/policy_templates.json policy_templates.bak.json
(samtranslator37) ~/P/serverless-application-model ❯❯❯ git co -- .
(samtranslator37) ~/P/serverless-application-model ❯❯❯ g remote add mustafa-sadiq-icf [email protected]:mustafa-sadiq-icf/serverless-application-model.git
(samtranslator37) ~/P/serverless-application-model ❯❯❯ g fetch mustafa-sadiq-icf
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 21 (delta 12), reused 18 (delta 9), pack-reused 0
Unpacking objects: 100% (21/21), 5.87 KiB | 176.00 KiB/s, done.
From github.com:mustafa-sadiq-icf/serverless-application-model
 * [new branch]        develop                                    -> mustafa-sadiq-icf/develop
 * [new branch]        feat/sam-canary                            -> mustafa-sadiq-icf/feat/sam-canary
 * ....
(samtranslator37) ~/P/serverless-application-model ❯❯❯ g co policy-template/formatting
branch 'policy-template/formatting' set up to track 'mustafa-sadiq-icf/policy-template/formatting' by rebasing.
Switched to a new branch 'policy-template/formatting'
(samtranslator37) ~/P/serverless-application-model ❯❯❯ diff samtranslator/policy_templates_data/policy_templates.json policy_templates.bak.json
(empty)

@aahung aahung merged commit 28489f2 into aws:develop Dec 22, 2022
aahung pushed a commit to aahung/serverless-application-model that referenced this pull request Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants