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

Add check for native provider upgrade #150

Merged
merged 2 commits into from
Jan 22, 2023

Conversation

sergenyalcin
Copy link
Member

@sergenyalcin sergenyalcin commented Jan 19, 2023

Description of your changes

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added 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.

  • Created a ResourceGroup in azure 3.8.0 version
  • Then the provider version was upgraded to 3.38.0
  • Then checked everything is okay.

Copy link
Collaborator

@ulucinar ulucinar left a 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.

pkg/terraform/files.go Outdated Show resolved Hide resolved
pkg/terraform/store.go Outdated Show resolved Hide resolved
pkg/terraform/files.go Outdated Show resolved Hide resolved
pkg/terraform/files.go Outdated Show resolved Hide resolved
pkg/terraform/files.go Outdated Show resolved Hide resolved
pkg/terraform/files.go Outdated Show resolved Hide resolved
pkg/terraform/store.go Outdated Show resolved Hide resolved
pkg/terraform/store.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@ulucinar ulucinar left a comment

Choose a reason for hiding this comment

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

Thanks @sergenyalcin, lgtm.

@sergenyalcin sergenyalcin merged commit 5d0efcc into crossplane:main Jan 22, 2023
@sergenyalcin sergenyalcin deleted the provider-upgrade branch January 22, 2023 18:49
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