-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add check for native provider upgrade #150
Conversation
Signed-off-by: Sergen Yalçın <[email protected]>
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.
Thanks @sergenyalcin for working on this. I think we are good to go with this PR after handling one error case mentioned in the comments.
Just to have discussed some alternatives:
One thing to consider is previously, if main.tf.json
becomes corrupt, we are able to recover as we are overwriting it. But now, we will not be able to recover. I think we have preferred to parse the provider version from main.tf.json
because we have the JSON unmarshaler at our disposal.
One alternative is to parse the version from the .terraform.lock.hcl
file. But this file is in HCL syntax. Running something like grep version .terraform.lock.hcl
is sufficient but how robust is this and we had better avoid a new fork with each workspace reconciliation. If HCL parsing libraries are at our disposal in the repo, then we can easily & reliably parse the locked version from the lock file.
Another alternative is to run:
❯ terraform version -json
{
"terraform_version": "1.2.1",
"platform": "darwin_arm64",
"provider_selections": {
"registry.terraform.io/hashicorp/azurerm": "3.38.0"
},
"terraform_outdated": true
}
, and to parse the version from the output JSON document. But, again this involves another fork at each workspace reconciliation, which we had better avoid.
Signed-off-by: Sergen Yalçın <[email protected]>
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.
Thanks @sergenyalcin, lgtm.
Description of your changes
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
This PR was tested on provider-azure by using this change.