You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
getopt.StringVarLong(¶ms.DefaultVersion, "default", 'd', "Default to this version in case no other versions could be detected. Ex: tfswitch --default 1.2.4")
37
37
getopt.BoolVarLong(¶ms.HelpFlag, "help", 'h', "Displays help message")
getopt.StringVarLong(¶ms.InstallPath, "install", 'i', "Custom install path. Ex: tfswitch -i /Users/username. The binaries will be in the sub installDir directory e.g. /Users/username/"+lib.InstallDir)
getopt.StringVarLong(¶ms.LatestStable, "latest-stable", 's', "Latest implicit version based on a constraint. Ex: tfswitch --latest-stable 0.13.0 downloads 0.13.7 and 0.13 downloads 0.15.5 (latest)")
Copy file name to clipboardExpand all lines: www/docs/usage/ci-cd.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
## Set a default TF version for CI/CD pipeline
2
+
2
3
1. When using a CI/CD pipeline, you may want a default or fallback version to avoid the pipeline from hanging.
3
4
2. Ex: `tfswitch -d 1.2.3` or `tfswitch --default 1.2.3` installs version `1.2.3` when no other versions could be detected.
4
5
[Also, see CICD example](../continuous-integration)
@@ -34,12 +35,14 @@ load-tfswitch() {
34
35
add-zsh-hook chpwd load-tfswitch
35
36
load-tfswitch
36
37
```
38
+
37
39
> NOTE: if you see an error like this: `command not found: add-zsh-hook`, then you might be on an older version of zsh (see below), or you simply need to load `add-zsh-hook` by adding this to your `.zshrc`:
38
40
> ```
39
41
> autoload -U add-zsh-hook
40
42
> ```
41
43
42
44
### Older version of zsh
45
+
43
46
```sh
44
47
cd(){
45
48
builtin cd "$@";
@@ -49,6 +52,7 @@ cd(){
49
52
fi
50
53
}
51
54
```
55
+
52
56
## Automatically switch with fish shell
53
57
54
58
Add the following to the end of your `~/.config/fish/config.fish` file:
By default `tfswitch` will download the Terraform binary to the user home directory under this path: `/Users/warrenveerasingam/.terraform.versions`
79
+
By default `tfswitch` will download the Terraform binary to the user home directory under this path: `$HOME/.terraform.versions`
81
80
82
81
If you want to install the binaries outside of the home directory then you can provide the `-i` or `--install` to install Terraform binaries to a non-standard path. Useful if you want to install versions of Terraform that can be shared with multiple users.
Copy file name to clipboardExpand all lines: www/docs/usage/config-files.md
+19-8Lines changed: 19 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,17 @@
1
1
## Get the version from a subdirectory
2
-
While using the file configuration it might be necessary to change the working directory. You can do that with the `--chdir` or `-c` parameter.
2
+
3
+
While using the file configuration it might be necessary to change the working directory. You can do that with the `--chdir` or `-c` parameter.
4
+
3
5
```bash
4
6
tfswitch --chdir terraform_dir
5
7
tfswitch -c terraform_dir
6
8
```
7
9
8
10
## Use version.tf file
11
+
9
12
If a .tf file with the terraform constraints is included in the current directory, it should automatically download or switch to that terraform version.
10
13
For example, the following should automatically switch terraform to the lastest version:
1. Create a `.tfswitchrc` file containing the desired version
@@ -31,23 +36,27 @@ terraform {
31
36
*Instead of a `.tfswitchrc` file, a `.terraform-version` file may be used for compatibility with [`tfenv`](https://github.com/tfutils/tfenv#terraform-version-file) and other tools which use it*
32
37
33
38
## Use .tfswitch.toml file (For non-admin - users with limited privilege on their computers)
39
+
34
40
This is similiar to using a .tfswitchrc file, but you can specify a custom binary path for your terraform installation
35
41
36
42

37
43

38
44
39
-
1. Create a custom binary path. Ex: `mkdir /Users/warrenveerasingam/bin` (replace warrenveerasingam with your username)
40
-
2. Add the path to your PATH. Ex: `export PATH=$PATH:/Users/warrenveerasingam/bin` (add this to your bash profile or zsh profile)
41
-
3. Pass -b or --bin parameter with your custom path to install terraform. Ex: `tfswitch -b /Users/warrenveerasingam/bin/terraform 0.10.8 `
45
+
1. Create a custom binary path. Ex: `mkdir $HOME/bin`
46
+
2. Add the path to your PATH. Ex: `export PATH=$PATH:$HOME/bin` (add this to your bash profile or zsh profile)
47
+
3. Pass -b or --bin parameter with your custom path to install terraform. Ex: `tfswitch -b $HOME/bin/terraform 0.10.8 `
42
48
4. Optionally, you can create a `.tfswitch.toml` file in your terraform directory(current directory) OR in your home directory(~/.tfswitch.toml). The toml file in the current directory has a higher precedence than toml file in the home directory
43
49
5. Your `.tfswitch.toml` file should look like this:
50
+
44
51
```ruby
45
-
bin ="/Users/warrenveerasingam/bin/terraform"
52
+
bin ="$HOME/bin/terraform"
46
53
version ="0.11.3"
47
54
```
48
-
4. Run `tfswitch` and it should automatically install the required terraform version in the specified binary path
49
55
50
-
**NOTE**
56
+
6. Run `tfswitch` and it should automatically install the required terraform version in the specified binary path
57
+
58
+
**NOTE**
59
+
51
60
1. For linux users that do not have write permission to `/usr/local/bin/`, `tfswitch` will attempt to install terraform at `$HOME/bin`. Run `export PATH=$PATH:$HOME/bin` to append bin to PATH
52
61
2. For windows host, `tfswitch` need to be run under `Administrator` mode, and `$HOME/.tfswitch.toml` with `bin` must be defined (with a valid path) as minimum, below is an example for `$HOME/.tfswitch.toml` on windows
53
62
@@ -56,8 +65,10 @@ bin = "C:\\Users\\<%USRNAME%>\\bin\\terraform.exe"
56
65
```
57
66
58
67
## Use terragrunt.hcl file
68
+
59
69
If a terragrunt.hcl file with the terraform constraint is included in the current directory, it should automatically download or switch to that terraform version.
60
-
For example, the following should automatically switch terraform to the lastest version 0.13:
70
+
For example, the following should automatically switch terraform to the lastest version 0.13:
0 commit comments