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

Support changing the version file for terraform and opentofu #2602

Open
hinricht opened this issue Sep 18, 2024 · 0 comments
Open

Support changing the version file for terraform and opentofu #2602

hinricht opened this issue Sep 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@hinricht
Copy link

Describe the bug

Right now, mise with the plugins terraform or opentofu will correctly parse the tool version from the
required_version directive in the main.tf / main.tofu file.
Both plugins support env vars to change the name of the file to parse (ASDF_HASHICORP_TERRAFORM_VERSION_FILE / ASDF_OPENTOFU_VERSION_FILE) (see i.e. https://github.com/asdf-community/asdf-hashicorp?tab=readme-ov-file#usage):

ASDF_HASHICORP_TERRAFORM_VERSION_FILE: Which .tf-file to examine for version constraints when using the legacy_version_file option in ~/.asdfrc. Defaults to main.tf

But when setting this env var to an existing file containing a required_version directive, mise doesn't parse this file.

To Reproduce

$ mkdir test
mise terraform@1.5.0 
$ cd test 
mise terraform@1.5.0
$ echo -e "terraform {\n  required_version = \"1.7.1\" \n}" > main.tf
mise terraform@1.7.1   
$ mise config         
Path                       Plugins            
/tmp/test/main.tf          terraform          
~/.config/mise/config.toml opentofu, terraform
mise terraform@1.7.1  

$ mv main.tf versions.tf
mise terraform@1.5.0  
$ export ASDF_HASHICORP_TERRAFORM_VERSION_FILE=versions.tf
mise terraform@1.5.0                                                                
/tmp/test $ mise config                                             
Path                       Plugins            
~/.config/mise/config.toml opentofu, terraform
mise terraform@1.5.0 

Expected behavior

When I export ASDF_HASHICORP_TERRAFORM_VERSION_FILE=versions.tf and have a versions.tf file with a required_version directive, mise should pin the terraform/tofu version to this version.

mise doctor output

version: 2024.9.5 linux-x64 (1f0f03e 2024-09-17)
activated: yes
shims_on_path: yes

build_info: 
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Tue, 17 Sep 2024 13:42:22 +0000
  Rust Version: rustc 1.81.0 (eeb90cda1 2024-09-04)
  Profile: release

shell: 
  /usr/bin/zsh
  zsh 5.9 (x86_64-pc-linux-gnu)

dirs: 
  data: ~/.local/share/mise
  config: ~/.config/mise
  cache: ~/.cache/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files: 
  ~/.config/mise/config.toml

backends: 
  cargo
  core
  go
  npm
  pipx
  spm
  ubi
  vfox

plugins: 
  terraform  https://github.com/asdf-community/asdf-hashicorp.git#22eb1c4

toolset: 
  terraform@1.5.0  

env_vars: 
  MISE_SHELL=zsh

settings: 
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf = true
  asdf_compat = false
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  disable_hints = []
  disable_tools = ["opentofu"]
  experimental = true
  go_default_packages_file = "~/.default-go-packages"
  go_download_mirror = "https://dl.google.com/go"
  go_repo = "https://github.com/golang/go"
  go_set_gopath = false
  go_set_goroot = true
  go_skip_checksum = false
  http_timeout = 30
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  libgit2 = true
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  pipx_uvx = false
  plugin_autoupdate_last_check_duration = "7d"
  python_default_packages_file = "~/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  use_versions_host = true
  verbose = false
  vfox = false
  yes = false
  ci = false
  debug = false
  trace = false
  log_level = "info"
  python_venv_auto_create = false

  [status]
  missing_tools = "if_other_versions_installed"
  show_env = false
  show_tools = true

No warnings found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant