small pixel drawing of a pufferfish chtf

Misc cleanup
Jes Olson j3s@c3f.net
Sun, 17 Jul 2022 11:14:17 -0500
commit

5422426a09e56346ec782adcab526c1a6e7fd83a

parent

f9dee28f2f80717106302dd3c70e77962d736fd0

2 files changed, 16 insertions(+), 13 deletions(-)

jump to
M READMEREADME

@@ -1,19 +1,19 @@

`~* chtf *~` - chtf is a simple shell script + chtf is a ~30 line posix shell script that manages terraform versions. - i made it because the existing - solutions were way too big for - what i thought was a simple problem. + i made it because existing solutions + seemed way too big for what i thought + was a simple problem. ??? deps+install ??? to install chtf, just put it anywhere in - your $PATH. i put it in ~/bin personally. + your $PATH. i recommend ~/bin - you'll need to install these deps: + you'll need these deps: - curl - unzip

@@ -22,9 +22,6 @@ the beginning somewhere, since chtf relies

on symlinking ~/bin/terraform to the proper version. - most distros will have everything you need - out of the box. - !!! demo !!!

@@ -41,7 +38,7 @@ $ chtf 0.11.1

$ chtf 0.11.1* 0.12.1 - $ terraform version + $ ~/bin/terraform version Terraform v0.11.1 # download a new version and make it active

@@ -49,6 +46,12 @@

$ chtf 1.2.5 terraform version not found downloading https://releases.hashicorp.com/terraform/1.2.5/terraform_1.2.5_linux_amd64.zip - $ terraform version + $ ~/bin/terraform version Terraform v1.2.5 on linux_amd64 + + + todo: + - [ ] add arm support + - [ ] add auto-switching based on .terraform-version file + - [ ] add refuse to run if doesn't match .terraform-version file
M chtfchtf

@@ -26,7 +26,7 @@ mkdir -p "$tf_install_dir"

if [ -z "$tf_version" ]; then [ -e "$tf_link_name" ] && active=$(readlink "$tf_link_name" | xargs basename) - for i in $(ls "$tf_install_dir"); do + for i in "$tf_install_dir"/*; do if [ "$i" = "$active" ]; then printf "%s*\n" "$i" else

@@ -37,7 +37,7 @@ else

if [ ! -f "${tf_install_dir}/${tf_version}" ]; then dl="https://releases.hashicorp.com/terraform/${tf_version}/terraform_${tf_version}_${os}_amd64.zip" printf "terraform version not found\ndownloading %s\n" "$dl" - curl -sS --location --fail --output /tmp/tf.zip "$dl" 2>&1 >/dev/null + curl -sS --location --fail --output /tmp/tf.zip "$dl" unzip /tmp/tf.zip -d /tmp >/dev/null mv /tmp/terraform "${tf_install_dir}/${tf_version}" rm /tmp/tf.zip