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

Lint and format the MMv1 resource definition YAML files in magic-modules/mmv1/products/ #13841

Open
mmizutani opened this issue Feb 25, 2023 · 0 comments

Comments

@mmizutani
Copy link

mmizutani commented Feb 25, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

There are some errors and lots of inconsistencies of syntax in the YAML files for the MMv1 resources under the directory magic-modules/mmv1/products.

For example, running yamllint in the magic-modules/mmv1 directory emits the following counts of syntax errors and warnings:

  • key-duplicates errors: 17
    • Example: [error] duplication of key "readReplicasMode" in mapping
  • indentation warnings: 515
    • Example: [warning] wrong indentation: expected 15 but found 14
  • trailing-space warnings: 625
    • Example: [warning] trailing spaces

Although some of them are non-harmful for the production provider code, such errors and inconsistencies in the YAML code syntax should be regularly and automatically checked to prevent generation of unintended provider code, avoid noisy diff in pull requests, and reduce non-essential discussions over stylistic choices during code review.

Proposal

It would be nice to have a YAML linter in the CI workflows of magic-modules.
I am thinking of the introducing a YAML linter in the magic-modules repository by splitting the changes in the following three steps:

  1. Setup yamllint
    • Install the yamllint CLI in the gcr.io/graphite-docker-images/downstream-builder container image.
    • Fine-tune the existing yamllint configuration file .yamllint to ignore or temporarily suppress some non-critical errors.
    • Fix only critical errors in YAML files.
  2. Partially enforce yamllint
    • Un-suppress the non-critical errors and fix them.
    • Enable yamllint in a CI workflow, but make the workflow fail only when lint errors are emitted, ignoring warnings.
  3. Fully enforce yamllint
    • Address yamllint warning items
    • Make the yamllnt CI workflow to fail if a warning or an error occurs

We will need to be careful when correcting the following duplicate-key YAML syntax errors so that it will not alter or break the currently generated provider code.

./products/resourcemanager/api.yaml:253:9: [error] duplication of key "output" in mapping (key-duplicates)
./products/kms/api.yaml:300:9: [error] duplication of key "required" in mapping (key-duplicates)
./products/kms/terraform.yaml:142:7: [error] duplication of key "createTime" in mapping (key-duplicates)
./products/networkservices/terraform.yaml:153:7: [error] duplication of key "routing.pathMatchers.routeRules.routeAction.cdnPolicy.cacheKeyPolicy.includeProtocol" in mapping (key-duplicates)
./products/networkservices/terraform.yaml:165:7: [error] duplication of key "logConfig.enable" in mapping (key-duplicates)
./products/redis/terraform.yaml:124:7: [error] duplication of key "readReplicasMode" in mapping (key-duplicates)
./products/secretmanager/terraform.yaml:48:7: [error] duplication of key "custom_import" in mapping (key-duplicates)
./products/storage/api.yaml:62:9: [error] duplication of key "item_type" in mapping (key-duplicates)
./products/compute/api.yaml:9572:13: [error] duplication of key "name" in mapping (key-duplicates)
./products/compute/api.yaml:9573:13: [error] duplication of key "description" in mapping (key-duplicates)
./products/compute/terraform.yaml:394:7: [error] duplication of key "backends.group" in mapping (key-duplicates)
./products/compute/terraform.yaml:1006:7: [error] duplication of key "region" in mapping (key-duplicates)
./products/dlp/terraform.yaml:72:7: [error] duplication of key "deidentifyConfig.recordTransformations.fieldTransformations.primitiveTransformation.replaceConfig.newValue.timestampValue" in mapping (key-duplicates)
./products/bigquerydatatransfer/terraform.yaml:40:5: [error] duplication of key "custom_code" in mapping (key-duplicates)
./products/datacatalog/api.yaml:403:5: [error] duplication of key "self_link" in mapping (key-duplicates)catemanager/terraform.yaml:43:5: [error] duplication of key "examples" in mapping (key-duplicates)

Affected Resource(s)

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

Successfully merging a pull request may close this issue.

2 participants