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

For non-geodesic users, allow command templates or auto search for popular directory formats #441

Open
nitrocode opened this issue Oct 19, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@nitrocode
Copy link
Member

Describe the Feature

Currently we can use hard coded values

components:
  abc:
    command: "/bin/terraform-1"

This works if you're using geodesic or nix or similar but it doesn't work if devs want to use native binaries.

The native binaries may be installed via asdf or tfenv or tfswitch.

  • asdf /Users/user/.asdf/installs/terraform/{version}/bin/terraform
  • tfenv /home/user/.tfenv/versions/{version}/terraform
  • tfswitch /home/user/.terraform.versions/terraform_{version}

Expected Behavior

An improved templating system

Use Case

Allow using asdf, tfsec, tfenv or any terraform version manager by supplying command templates. This also removes hard coding binaries in the yaml leaving only the input that matters which is the version.

Describe Ideal Solution

It would be nice in atmos.yaml to allow adding formats to check for

terraform:
  command_templates:
    - "/Users/user/.asdf/installs/terraform/{version}/bin/terraform"
    - "/home/user/.tfenv/versions/{version}/terraform"
    - "/home/user/.terraform.versions/terraform_{version}"

then for components, we can use something like this

components:
  abc:
    # should resolve to latest binary installed locally if available
    # e.g. `/Users/user/.asdf/installs/terraform/1.6.2/bin/terraform`
    command_version: "1"
    # should resolve to latest binary installed locally if available
    # e.g. `/Users/user/.asdf/installs/terraform/1.5.7/bin/terraform`
    command_version: "1.5"
    # should resolve to exact binary installed locally if available
    # e.g. `/Users/user/.asdf/installs/terraform/1.6.2/bin/terraform`
    command_version: "1.6.2"

Alternatives Considered

No response

Additional Context

No response

@osterman
Copy link
Member

@nitrocode why not just write:

components:
  abc:
    command: "terraform"

Then it should use your search path, and be compatible with tools like asdf

@nitrocode
Copy link
Member Author

The way asdf works is by auto switching to the tool version using a direnv-like .tool-versions file within a directory.

This file can be added in the components/terraform/abc/.tool-versions by doing the following

asdf plugin add terraform
asdf install terraform 1.2.3
cd components/terraform/abc
asdf local terraform 1.2.3
✗ cat .tool-versions
terraform 1.2.3

But then you have an issue if you have multiple instantiations of abc that use different terraform versions.

components:
  abc:
    command: "terraform"

components:
  abc/legacy:
    command: "terraform0.12"

Today, we can do explicitly set these but then it's only compatible with a single tool asdf or tfenv or tfswitch due to the path structure.

components:
  abc:
    command: /Users/user/.asdf/installs/terraform/1.6.2/bin/terraform

components:
  abc/legacy:
    command: /Users/user/.asdf/installs/terraform/0.12.5/bin/terraform

@osterman osterman added the enhancement New feature or request label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants