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

feat: Add --autoplan-file-list server flag. #1475

Merged
merged 5 commits into from
Apr 22, 2021

Conversation

Omicron7
Copy link
Contributor

This adds a new server flag that allows modifying the list of files that trigger default project planning.

We use terraform/atlantis to build AWS AMI's using packer and ansible. We wanted changes to the packer (*.pkr.hcl) and ansible (*.yml) files to trigger an autoplan when modified in a commit. It looked like we could do this with an atlantis.yml file (Workflow), but we have a large repo with 100's of small projects and rely on the default atlantis workflow. Defining atlantis.yml would require us to define every existing project, and all new projects in that workflow.

Instead, I added a server flag/ENV that would allow modifying/overriding the list of file patterns that trigger an autoplan.

--autoplan-file-list uses the same dockeringore syntax as Custom workflows autoplan when_modified. This allows for overriding the default list, adding more file types, and file exclusions.

Examples:

  • Default: --autoplan-file-list="**/*.tf,**/*.tfvars,**/*.tfvars.json"
  • Add packer and YML files: --autoplan-file-list="**/*.tf,**/*.tfvars,**/*.tfvars.json,**/*.pkr.hcl,**/*.yml"
  • ENV var: ATLANTIS_AUTOPLAN_FILE_LIST="**/*.tf,**/*.hcl"

@Omicron7 Omicron7 requested a review from a team as a code owner March 26, 2021 17:14
@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #1475 (da2f3c3) into master (921ebbc) will decrease coverage by 0.00%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1475      +/-   ##
==========================================
- Coverage   70.23%   70.23%   -0.01%     
==========================================
  Files          94       94              
  Lines        6441     6457      +16     
==========================================
+ Hits         4524     4535      +11     
- Misses       1533     1536       +3     
- Partials      384      386       +2     
Impacted Files Coverage Δ
server/user_config.go 100.00% <ø> (ø)
server/events/project_command_builder.go 81.74% <50.00%> (-0.56%) ⬇️
server/events/project_finder.go 88.09% <70.00%> (-2.82%) ⬇️
cmd/server.go 79.55% <100.00%> (+0.46%) ⬆️
server/server.go 64.65% <100.00%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 921ebbc...da2f3c3. Read the comment docs.

Copy link
Contributor

@nishkrishnan nishkrishnan left a comment

Choose a reason for hiding this comment

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

Nice work I'm in favor of the change just a couple questions/comments.

server/events/project_finder.go Outdated Show resolved Hide resolved
server/events/project_finder.go Outdated Show resolved Hide resolved
server/events/project_finder.go Outdated Show resolved Hide resolved
@Omicron7
Copy link
Contributor Author

@nishkrishnan I've updated the PR to set the default value in cmd/server.go and added **/terragrunt.hcl to the list. This also adds pattern validation at startup which removes the need for error checking/catching in the project finder.

@Omicron7
Copy link
Contributor Author

make test passes for me locally, not sure why circleci failed on the invalid pattern test.

@Omicron7
Copy link
Contributor Author

Omicron7 commented Apr 9, 2021

@nishkrishnan I rebased this on latest master and fixed logging issue. Any help tracking down the failing test would be appreciated. make test succeeds locally for me. I'm not knowledgeable enough with go and circleci to figure out whats going on. I'm guessing a module version difference.

@nishkrishnan nishkrishnan merged commit f290780 into runatlantis:master Apr 22, 2021
@Omicron7 Omicron7 deleted the autoplan-file-list branch April 28, 2021 17:36
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.

2 participants