Skip to content

[TF-24744] Terraform Version Arm Support #1714

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

Draft
wants to merge 11 commits into
base: kelsi-hoyle/TF-24744/arm-toolversion-support
Choose a base branch
from

Conversation

kelsi-hoyle
Copy link
Collaborator

Description

  • Adds arm support to tfe terraform version
  • Updates the tfe_terraform_version resource to have archs
    • Validation on architecture fields
      • url and sha OR archs is required
      • conflicting message if both are provided
  • sends archs on update/create opts (if present)

Remember to:

Testing plan

  1. Describe how to replicate
  2. the conditions
  3. under which your code performs its purpose,
  4. including example Terraform configs where necessary.

External links

Include any links here that might be helpful for people reviewing your PR. If there are none, feel free to delete this section.

Output from acceptance tests

Please run applicable acceptance tests locally and include the output here. See testing.md to learn how to run acceptance tests.

If you are an external contributor, your contribution(s) will first be reviewed before running them against the project's CI pipeline.

$ TESTARGS="-run TestAccTFEWorkspace" make testacc

...

Copy link
Collaborator

@natalie-todd natalie-todd left a comment

Choose a reason for hiding this comment

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

This looks good. Almost all of my comments are about the same thing - I'm thinking we should let Atlas handle top level URL/SHA vs Archs decisions. That being said, I could be convinced of otherwise. Let me know your thoughts. This could have been clearer in the ticket so apologies there.

I added a bullet point to the A/C for a deprecation message.

Type: schema.TypeString,
Optional: true,
Default: nil,
ConflictsWith: []string{"archs"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I am understanding ConflictsWith properly, it cannot be used w/ "archs" at all, right? I think it should be allowed to be used w/ archs because maybe there are url, sha, and arm64 arch fields or url, sha, and matching amd64 fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, I can definitely update this validation. I added this when I was having weird behavior with the api. But with TFDN-842 this behavior should be taken care of

Optional: true,
Default: nil,
ConflictsWith: []string{"archs"},
RequiredWith: []string{"sha"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

For PATCH requests, a SHA does not have to be present w/ a URL and the other way around. Will this interfere with that?

Optional: true,
Default: nil,
ConflictsWith: []string{"url", "sha"},
AtLeastOneOf: []string{"archs", "url", "sha"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still wondering about the PATCH here. Let me know if you want me to do any manual testing around this.

Comment on lines 121 to 128
} else {
url, urlOk := d.GetOk("url")
sha, shaOk := d.GetOk("sha")
if urlOk && shaOk {
opts.URL = tfe.String(url.(string))
opts.Sha = tfe.String(sha.(string))
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can see why you have an else because we want to get away from relying on URL and SHA but I wonder if we should set the URL and SHA if present regardless of Archs because then the user will get the 422 if they don't match. It might be confusing for them to send these values and not get any acknowledgement of them.

Copy link
Collaborator Author

@kelsi-hoyle kelsi-hoyle May 2, 2025

Choose a reason for hiding this comment

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

Ok, the reason that I had conditionally set these was because of this warning that is returned that may be confusing (but may also be acceptable, I am not familiar with providers 😅 )

This was how I set the tfe_terraform_version:

resource "tfe_terraform_version" "test" {
  version = "9.9.9"
  deprecated = false
  enabled = true
  official = false
  beta = false

  archs {
    url = "https://releases.hashicorp.com/terraform/1.11.0-alpha20241211/terraform_1.11.0-alpha20241211_linux_amd64.zip"
    sha = "dd68a600989c122c5e2ca9fd055f071bfbff8fa7047b48349489e4290b62b8c1"
    os = "linux"
    arch = "amd64"
  }

  archs {
    url = "https://releases.hashicorp.com/terraform/1.11.0-alpha20241211/terraform_1.11.0-alpha20241211_linux_amd64.zip"
    sha = "dd68a600989c122c5e2ca9fd055f071bfbff8fa7047b48349489e4290b62b8c9"
    os = "linux"
    arch = "arm64"
  }
}

Since the tool_version url and sha are sent back at the read, it set's both of those values in state and returns this warning:

2025-05-02T10:14:31.067-0600 [WARN]  Provider "provider[\"registry.terraform.io/hashicorp/tfe\"]" produced an unexpected new value for tfe_terraform_version.test, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .url: was null, but now cty.StringVal("https://releases.hashicorp.com/terraform/1.11.0-alpha20241211/terraform_1.11.0-alpha20241211_linux_amd64.zip")
      - .sha: was null, but now cty.StringVal("dd68a600989c122c5e2ca9fd055f071bfbff8fa7047b48349489e4290b62b8c1")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated to just set it each time, since it is a lot cleaner. But curious on your thoughts!

Comment on lines 113 to 114
d.Set("url", v.URL)
d.Set("sha", v.Sha)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if we should leave these and realizing I should not have included details like "replace" in the ticket. I'll fix that.

d.Set("url", nil)
d.Set("sha", nil)
} else {
d.Set("archs", nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
d.Set("archs", nil)

This will default to nil

Comment on lines 173 to 174
d.Set("url", nil)
d.Set("sha", nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we populate these and let Atlas handle it.

Comment on lines 129 to 130
URL: tfe.String(d.Get("url").(string)),
Sha: tfe.String(d.Get("sha").(string)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as lines 78, 79.

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