tfswitch

module
v2.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: MPL-2.0

README

tfswitch

BuildStatus Go Report Card PkgGoDev

Motivation

tfutils/tfenv: Terraform version manager is great tool for switching the terraform version used in local.

However, There is an issue that it takes extra time to execute the command. (This is referred by terraform executions delayed by ~ 1 second · Issue #196 · tfutils/tfenv). If you want to display the terraform version in the prompt, you will have to wait almost a second every time the it is updated.

This tool can also switch the terraform version. This installs binary from https://releases.hashicorp.com/terraform/ if specified version does not found in your machine. tfenv runs own script instead of binary, but this tool runs binary directly.

How to use

Install
$ go install github.com/cappyzawa/tfswitch/v2/cmd/tfswitch@latest

or download from Releases · cappyzawa/tfswitch.

Use
$ tfswitch -h
Usage: tfswitch [--version] [--help] <command> [<args>]

Available commands are:
    local-list     display available terraform versions in local.
    remote-list    display available terraform versions in remote. (https://releases.hashicorp.com/terraform/)
    use            use specified terraform version.
$ tfswitch use [version]
# e.g., If you want to use 0.14.4
$ tfswitch use 0.14.4
Switched terraform version to 0.14.4

# This tool creates or replaces symbolic links.
$ ls -l `which terraform`
lrwxr-xr-x  1 cappyzawa  admin  54 Jan 14 20:14 /usr/local/bin/terraform@ -> /Users/cappyzawa/.local/share/tfswitch/terraform_0.14.4
$ tfswitch 0.14.3
$ ls -l `which terraform`
lrwxr-xr-x  1 cappyzawa  admin  54 Jan 14 20:18 /usr/local/bin/terraform@ -> /Users/cappyzawa/.local/share/tfswitch/terraform_0.14.3
Available Environments
  • XDG_DATA_HOME (Default: ~/.local/share): The specified version of terraform will be saved as $XDG_DATA_HOME/tfswitch/terraform_[version]
Interactive switch
# from remote-list
$ tfswitch remote-list | fzf --reverse | xargs tfswitch use

# from local-list
$ tfswitch local-list | fzf --reverse | xargs tfswitch use

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL