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: Download terraform versions using >= and ~> specifiers #1776

Merged
merged 13 commits into from
Nov 21, 2022

Conversation

fblgit
Copy link
Contributor

@fblgit fblgit commented Aug 27, 2021

Implements tfswitch libs and semver to parse properly the terraform files version, then compares against the available terraform releases and returns version.Version object with the right value.

This is the first PR, let me know if I'm missing something here.

Libraries

Closes

@fblgit fblgit requested a review from a team as a code owner August 27, 2021 23:10
@fblgit
Copy link
Contributor Author

fblgit commented Aug 28, 2021

?   	github.com/runatlantis/atlantis	[no test files]
ok  	github.com/runatlantis/atlantis/cmd	(cached)
ok  	github.com/runatlantis/atlantis/server	(cached)
ok  	github.com/runatlantis/atlantis/server/controllers	(cached)
ok  	github.com/runatlantis/atlantis/server/controllers/events	(cached)
?   	github.com/runatlantis/atlantis/server/controllers/templates	[no test files]
ok  	github.com/runatlantis/atlantis/server/core/db	(cached)
ok  	github.com/runatlantis/atlantis/server/core/locking	(cached)
ok  	github.com/runatlantis/atlantis/server/core/runtime	(cached)
ok  	github.com/runatlantis/atlantis/server/core/runtime/cache	(cached)
?   	github.com/runatlantis/atlantis/server/core/runtime/models	[no test files]
ok  	github.com/runatlantis/atlantis/server/core/runtime/policy	(cached)
ok  	github.com/runatlantis/atlantis/server/core/terraform	(cached)
ok  	github.com/runatlantis/atlantis/server/events	1.760s
?   	github.com/runatlantis/atlantis/server/events/matchers	[no test files]
ok  	github.com/runatlantis/atlantis/server/events/models	(cached)
?   	github.com/runatlantis/atlantis/server/events/models/fixtures	[no test files]
ok  	github.com/runatlantis/atlantis/server/events/runtime/common	(cached)
ok  	github.com/runatlantis/atlantis/server/events/vcs	(cached)
ok  	github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud	(cached)
ok  	github.com/runatlantis/atlantis/server/events/vcs/bitbucketserver	(cached)
ok  	github.com/runatlantis/atlantis/server/events/vcs/common	(cached)
?   	github.com/runatlantis/atlantis/server/events/vcs/fixtures	[no test files]
ok  	github.com/runatlantis/atlantis/server/events/webhooks	(cached)
ok  	github.com/runatlantis/atlantis/server/events/yaml	(cached)
ok  	github.com/runatlantis/atlantis/server/events/yaml/raw	(cached)
ok  	github.com/runatlantis/atlantis/server/events/yaml/valid	(cached)
ok  	github.com/runatlantis/atlantis/server/logging	(cached)
ok  	github.com/runatlantis/atlantis/server/recovery	(cached) [no tests to run]
?   	github.com/runatlantis/atlantis/testdrive	[no test files]

Tests looking good, but in the way it is.. it will require to keep up-to-date these tests as the latest version of terraform may get updated at some point then instead of 1.0.5 probably it will return at some point 1.1.0 which I think is the one in progress

@chenrui333 chenrui333 changed the title Refactor TFVersion from Dir with tfswitch lib refactor: TFVersion from Dir with tfswitch lib Nov 20, 2021
@jamengual jamengual added feature New functionality/enhancement waiting-on-response Waiting for a response from the user labels May 13, 2022
@jamengual
Copy link
Contributor

@fblgit any updates on this? Thanks for the contribution

@mustafa89
Copy link

are there any updates for this?

@jamengual
Copy link
Contributor

No activity for more than 30 days. closing

@jamengual jamengual closed this Jul 7, 2022
@pszypowicz
Copy link

Can I help with this PR? This seems to be almost finished and would bring great value.

@nitrocode nitrocode reopened this Nov 10, 2022
@nitrocode
Copy link
Member

@fblgit @pszypowicz yes please feel free to take over if you think this PR has value.

@nitrocode
Copy link
Member

@fblgit @pszypowicz i went ahead and fixed the conflicts in case anyone would like to take over by branching off this branch or updating the existing one

@nitrocode nitrocode changed the title refactor: TFVersion from Dir with tfswitch lib Detect terraform versions using >= and ~> specifiers Nov 21, 2022
@llamahunter
Copy link
Contributor

thank you!!

@grimm26
Copy link
Contributor

grimm26 commented Dec 7, 2022

I assume terraform_version in atlantis.yaml takes precedent?

@nitrocode
Copy link
Member

This should only affect tf root modules with required_version set

@grimm26
Copy link
Contributor

grimm26 commented Dec 7, 2022

I have required_version set in my terraform config but I also specify terraform_version in my atlantis.yaml.

@nitrocode
Copy link
Member

Unsure how it will interact. Please let us know and help contribute docs for the website. We want to make sure everything is as clear as possible.

@grimm26
Copy link
Contributor

grimm26 commented Dec 7, 2022

I just did a test with required_version = "~> 1.2" in my terraform config and terraform_version: v1.2.5 in my atlantis.yaml and it ran with terraform v.1.2.5, so it seems that a required_version specified in atlantis.yaml takes precedent, which is what makes sense. I'll look for where to notate this in the docs.

krrrr38 pushed a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
…#1776)

* Refactor TFVersion from Dir with tfswitch lib

* Added tests and cleaned up code

* linted fmtd

* fixed conflict go.mod

* bumped to tf1.0.6

* bumped go.mod

* Update project_command_context_builder.go

* Bump warrensbox/terraform-switcher

* Fix tests

* rm redundant mocks library import

Co-authored-by: xmurias <xmurias@gmail.com>
Co-authored-by: Xavier <77047592+xavipanda@users.noreply.github.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
@nitrocode nitrocode added this to the 0.21.0 milestone Jan 13, 2023
@nitrocode nitrocode changed the title Detect terraform versions using >= and ~> specifiers feat: Download terraform versions using >= and ~> specifiers Jan 25, 2023
@nitrocode nitrocode mentioned this pull request Sep 5, 2023
1 task
@nitrocode nitrocode mentioned this pull request Mar 11, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement waiting-on-response Waiting for a response from the user
Projects
None yet
10 participants