Skip to content

INTMDB-249: [Terraform] Lint and fix linting for examples #1221

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

Merged
merged 37 commits into from
Jun 15, 2023

Conversation

andreaangiolillo
Copy link
Collaborator

@andreaangiolillo andreaangiolillo commented Jun 8, 2023

Description

Ticket: INTMDB-249
This PR updates the example action to use the tflint.sh script and fixed linting errors

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code

Further comments

@andreaangiolillo andreaangiolillo marked this pull request as ready for review June 8, 2023 16:07
@andreaangiolillo andreaangiolillo requested a review from a team as a code owner June 8, 2023 16:07
Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

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

is this working? one of the reasons it was commented was because of the number of errors found

@andreaangiolillo
Copy link
Collaborator Author

This is the action 9408128097: looking at the log it seems working. I will add a fmt error to one of terraform file and see if it fails

@andreaangiolillo andreaangiolillo requested a review from gssbzn June 12, 2023 18:31
--enable-rule=terraform_required_version
popd
done
- name: tf-validate
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have divided the original job into two separate jobs, each with a specific purpose:

  • tf-validate:
    • This job executes three Terraform commands: terraform init, terraform fmt, and terraform validate
    • It is necessary to replace the provider with mongodbatlas-dev in this job. This is because new resources are not available until the next release.
    • It is important to note that when using mongodbatlas-dev as the provider, the version attribute cannot be specified for the dev provider. However, tflint mandates that the version must be set for all providers in the Terraform configuration. This discrepancy is the reason for dividing the initial job.
  • tflint: this job runs tflint

@andreaangiolillo andreaangiolillo requested a review from a team June 12, 2023 18:38
@@ -72,7 +72,7 @@ lint:
tools: ## Install dev tools
@echo "==> Installing dependencies..."
go install github.com/client9/misspell/cmd/misspell@latest
go install github.com/terraform-linters/tflint@v0.31.0
go install github.com/terraform-linters/tflint@v0.46.1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated tflint to latest version

@Zuhairahmed
Copy link
Contributor

Zuhairahmed commented Jun 12, 2023

Looks like only versions.tf and variables.tf files had updates. Surprised there were no linting issues with any of the main.tf files in examples, is this just a coincidence?

@andreaangiolillo
Copy link
Collaborator Author

@Zuhairahmed We were already running terraform init, terraform fmt and terraform validate for all the examples. See examples.yml#L54

Copy link
Collaborator

@gssbzn gssbzn 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 all the fixes

@Zuhairahmed Zuhairahmed requested a review from themantissa June 14, 2023 04:25
@andreaangiolillo andreaangiolillo merged commit 15b0026 into master Jun 15, 2023
@andreaangiolillo andreaangiolillo deleted the INTMDB-249 branch July 17, 2023 14:52
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.

3 participants