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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OpenTofu auto download #4339

Open
8 tasks
nitrocode opened this issue Mar 11, 2024 · 1 comment
Open
8 tasks

Support OpenTofu auto download #4339

nitrocode opened this issue Mar 11, 2024 · 1 comment
Labels
feature New functionality/enhancement

Comments

@nitrocode
Copy link
Member

nitrocode commented Mar 11, 2024

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Describe the user story

Please support downloading of the opentf terraform fork instead of hashicorp terraform

https://github.com/opentffoundation/opentf

This may already be supported using --tf-download-url but it would be nice to have this officially documented so people can start using opentf instead of terraform for future releases.

https://www.runatlantis.io/docs/server-configuration.html#tf-download-url

Describe the solution you'd like

See above

Describe the drawbacks of your solution

N/A

Describe alternatives you've considered

N/A



DefaultTFDownloadURL = "https://releases.hashicorp.com"

terraformClient, err := terraform.NewClient(

func NewClient(
log logging.SimpleLogging,
binDir string,
cacheDir string,
tfeToken string,
tfeHostname string,
defaultVersionStr string,
defaultVersionFlagName string,
tfDownloadURL string,
tfDownloader Downloader,
tfDownloadAllowed bool,
usePluginCache bool,
projectCmdOutputHandler jobs.ProjectCommandOutputHandler,
) (*DefaultClient, error) {
return NewClientWithDefaultVersion(

_, err = ensureVersion(log, c.downloader, c.versions, v, c.binDir, c.downloadBaseURL, c.downloadAllowed)

log.Info("Could not find terraform version %s in PATH or %s, downloading from %s", v.String(), binDir, downloadURL)
urlPrefix := fmt.Sprintf("%s/terraform/%s/terraform_%s", downloadURL, v.String(), v.String())
binURL := fmt.Sprintf("%s_%s_%s.zip", urlPrefix, runtime.GOOS, runtime.GOARCH)
checksumURL := fmt.Sprintf("%s_SHA256SUMS", urlPrefix)
fullSrcURL := fmt.Sprintf("%s?checksum=file:%s", binURL, checksumURL)
if err := dl.GetFile(dest, fullSrcURL); err != nil {
return "", errors.Wrapf(err, "downloading terraform version %s at %q", v.String(), fullSrcURL)
}

binFile := "terraform" + v.String()

Listing versions

versions, err := lib.GetTFList(url, true)


The terraform url is constructed

  • url = https://releases.hashicorp.com
  • format string = %s/terraform/%s/terraform_%s, prefix, version, version
  • %s_%s_%s.zip, prefix, os, arch
  • full url https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_darwin_amd64.zip

Opentofu

  • url = https://github.com/opentofu/opentofu/releases
  • format string = %s/download/%s/tofu_%s, prefix, version, version
  • %s_%s_%s.zip, prefix, os, arch
  • full url https://github.com/opentofu/opentofu/releases/download/v1.6.0-alpha4/tofu_1.6.0-alpha4_darwin_amd64.zip

Seems like the following changes are needed

@janosdebugs
Copy link

@nitrocode this may be helpful: opentofu/get.opentofu.org#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement
Projects
None yet
Development

No branches or pull requests

2 participants