-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: customize atlantis.yaml file name in server side config #2798
feat: customize atlantis.yaml file name in server side config #2798
Conversation
1038812
to
98d0c7e
Compare
98d0c7e
to
d2f3ce9
Compare
d2f3ce9
to
6a74630
Compare
fbfd285
to
7f058ea
Compare
Nice addition! Let me ping the other @runatlantis/maintainers to get a review. I've reviewed this and the changes seem straight forward. |
hahahah 2 years ago I implemented this same feature ( not as good as this PR) I'm glad to see it coming so complete @krrrr38 thanks for the work. I have a question: how is this possible? |
Like followings.
atlantis-staging.yaml exampleversion: 3
projects:
- name: project
branch: /staging/
dir: infrastructure/staging atlantis-production.yaml exampleversion: 3
projects:
- name: project
branch: /production/
dir: infrastructure/production Actually, the above case can be handled by one atlantis server with following config 😬 . But we can separate them into multiple atlantis servers for reasons such as the server's IAM. version: 3
projects:
- name: project1
branch: /staging/
dir: infrastructure/staging
- name: project2
branch: /production/
dir: infrastructure/production |
Ah, but in this case with base branch |
Undestood, I was doing something similar before. you might want this too: https://www.runatlantis.io/docs/server-configuration.html#vcs-status-name and a well documented example in docs will be wonderful. |
Another way this could be done ( not in this PR) is using a github action that can route the call to the specified atlantis server without having to have two webhooks in the same project. if the atlantis command could be configured to pass a name like this is me just thinking out loud and I like your aproach more because it supports all the VCSs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR, it would be nice to see some ways to auto-trigger "silence-no-projects" if a custom Atlantis YAML is set but it is not trivial. I generally would like us to try and reduce the number of flags we have but outside the scope of this PR :)
|
||
:::tip Notes | ||
* If `no projects` comments are annoying, set [--silence-no-projects](server-configuration.html#silence-no-projects). | ||
* When using different atlantis server vcs users such as `@atlantis-staging`, you can call `@atlantis-staging plan` instead `atlantis plan` to call `stating-server` only. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know this usage, but we can call one of atlantis-server by using vcs user. (BTW run apply
is dangerous and useless...?)
atlantis/server/events/comment_parser.go
Lines 98 to 109 in 585ce1e
// Valid commands contain: | |
// - The initial "executable" name, 'run' or 'atlantis' or '@GithubUser' | |
// where GithubUser is the API user Atlantis is running as. | |
// - Then a command: 'plan', 'apply', 'unlock', 'version, 'approve_policies', | |
// or 'help'. | |
// - Then optional flags, then an optional separator '--' followed by optional | |
// extra flags to be appended to the terraform plan/apply command. | |
// | |
// Examples: | |
// - atlantis help | |
// - run apply | |
// - @GithubUser plan -w staging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a nice call out, and something I learned today. @krrrr38 Are you asking a question about run apply
or pointing out that its dangerous and useless? I think it should be removed, but we don't know any other use cases by users. It seems to just be an alias for atlantis.
atlantis/server/events/comment_parser.go
Lines 147 to 150 in 585ce1e
executableNames := []string{"run", atlantisExecutable, "@" + vcsUser} | |
if !e.stringInSlice(args[0], executableNames) { | |
return CommentParseResult{Ignore: true} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discuss it in the other PR, too. I'm worry about that almost users don't know it and it might execute unintentional apply.
But currently this feature is already provided and we might be better to discuss it in the next major release and so on, not in this PR.
3a67819
to
0e86e38
Compare
e3070b1
to
f7ce09c
Compare
Thank you again @krrrr38 ! These contributions are very helpful! |
Thank you for your high quality and quickly review, too. |
what
repos.yaml
can acceptrepo_config_file
configuration for customizingatlantis.yaml
why
Currently
atlantis.yaml
file must be put on the repository root. We can use this feature in the following situations.frontend
,backend
andinfrastructure
atlantis.yaml
intoinfrastructure/terraform/atlantis.yaml
, not repository root.config_repo_file
.Workaround
references