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 support for reading global configuration files #71

Closed
dcl opened this issue Mar 31, 2020 · 6 comments
Closed

Add support for reading global configuration files #71

dcl opened this issue Mar 31, 2020 · 6 comments
Assignees
Labels
new feature New feature or request

Comments

@dcl
Copy link

dcl commented Mar 31, 2020

Currently, .tfswitch.toml (and the backwards-compatible .tfswitchrc) is read only from the current working directory. This is useless for most practical applications.

To resolve this, the application should read options from ~/.tfswitch.toml when those options are not present in a .tfswitch.toml file in the current directory.

@warrensbox warrensbox self-assigned this Apr 16, 2020
@warrensbox warrensbox added the new feature New feature or request label Apr 16, 2020
@odbaeu
Copy link

odbaeu commented Apr 20, 2020

.tfswitch.toml from the local directory should have a higher priority than ~/.tfswitch.toml.

@warrensbox
Copy link
Owner

Let's say you have multiple projects with different terraform versions for each project, you can specify each terraform version in it's local/current directory.

.
├── terraform-project-1
│   └── version-tf-11.13
├── terraform-project-2
│   └── version-tf-11.14
└── terraform-project-3
    └── version-tf-12.24

If you want ~/.tfswitch.toml in the home directory ~, how do you manage the different versions of terraform for each project?
Are you only using one terraform version for all your project(s)?
@odbaeu @dcl can you please provide more information?

@odbaeu
Copy link

odbaeu commented Apr 22, 2020

Thank you so much for your quick reaction!

I try to keep most of my terraform projects on one version. That's why I think this is a good feature request. But I absolutely agree that it is best practice to have one .tfswitch.toml in each terraform project. This helps other team members to use the correct terraform version.

But back to the feature request: Let’s say I have the following structure:

~/.tfswitch.toml
~/projects/A
~/projects/B
~/projects/B/.tfswitch.toml
~/projects/C

In case the project has a .tfswitch.toml in the project’s directory, this should be picked. If it's not there, tfswitch would look for ~/.tfswitch.toml. In this case ~/.tfswitch.toml would be valid for project A and C.

This also means that ~/.tfswitch.toml is the default configuration and I can overwrite it.

@jurrehart
Copy link

I would expand on that and would like to see the following path for version identification stopping at the first match

  1. look for required_version in the .TF files
  2. look for .tfswitch.toml in current work directory
  3. look for .tfswitch.toml in users home directory

@fdamstra
Copy link

fdamstra commented Oct 6, 2020

I would add that if you're doing hierarchical modules, it would be really nice for it to search parent directories. My company's code is organized in terragrunt fashion, like:

~/projects/A
~/projects/A/prod
~/projects/A/prod/vpcs
~/projects/A/prod/instances
~/projects/A/test/vpcs
~/projects/A/test/instances

And then repeat for project B and so forth. It would be extremely useful to look for the .tfswitch.toml in the present directory, then work up the parent directories until either we're in ~ or /.

This would let me use a new version of tf in test while retaining the known-good version in prod, but not have to have dozens (no exageration) of hidden .tfswitch.toml files lying around.

@warrensbox
Copy link
Owner

will release soon with : #113

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

No branches or pull requests

5 participants