From d6fe90407e0fe60677f95b090710a8c659559738 Mon Sep 17 00:00:00 2001 From: Dhruv Gupta <114940443+Dhruvnotfound@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:04:42 +0530 Subject: [PATCH 1/6] Update README.md Signed-off-by: Dhruvnotfound --- README.md | 197 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 130 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 6237c23..5cba443 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,85 @@ -[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8816/badge)](https://www.bestpractices.dev/projects/8816) -[![Github release](https://img.shields.io/github/v/release/tofuutils/tofuenv)](https://github.com/tofuutils/tofuenv/releases) [![Contributors](https://img.shields.io/github/contributors/tofuutils/tofuenv)](https://github.com/tofuutils/tofuenv/graphs/contributors) ![maintenance status](https://img.shields.io/maintenance/yes/2024.svg) +[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8816/badge)](https://www.bestpractices.dev/projects/8816) [![Github release](https://img.shields.io/github/v/release/tofuutils/tofuenv)](https://github.com/tofuutils/tofuenv/releases) [![Contributors](https://img.shields.io/github/contributors/tofuutils/tofuenv)](https://github.com/tofuutils/tofuenv/graphs/contributors) ![maintenance status](https://img.shields.io/maintenance/yes/2024.svg) + +

tofuenv

+ +

OpenTofu version manager inspired by tfenv

+ +### Table of Content +
+ Important Notice • + Supported OS • + Installation • + Install dependencies • + Usage • + Upgrading • + Uninstalling • + License +
+ +### Important Notice +Many people have asked about Terraform support, and we are finally ready to announce a successor for **tfenv** and **tofuenv**: tenv 🚀 written in Golang. tenv is able to handle Terraform binaries as well as OpenTofu binaries. 🎉 + +Please contribute to tenv and award us stars⭐. + +## Supported OS + +Currently, **tofuenv** supports the following operating systems: + +
+ macOS + +
+
+ Linux + +
+
+ Windows (Only tested in git-bash - currently presumed failing due to symlink issues in git-bash) + +
-# tofuenv - -[OpenTofu](https://opentofu.org/) version manager inspired by [tfenv](https://github.com/tfutils/tfenv) - -## Important notice - -Many people have asked about Terraform support, and we are finally ready to announce a successor for tfenv and tofuenv: [tenv](https://github.com/tofuutils/tenv) written in Golang. tenv is able to handle Terraform binaries as well as OpenTofu binaries. - -Please contribute to [tenv](https://github.com/tofuutils/tenv) and award us stars. - -## Support - -Currently tofuenv supports the following operating systems: - -- macOS - - 64bit - - Arm (Apple Silicon) -- Linux - - 64bit - - Arm -- Windows (64bit) - only tested in git-bash - currently presumed failing due to symlink issues in git-bash ## Installation ### Automatic -Install via Homebrew +
Install via Homebrew -```console -brew tap tofuutils/tap -brew install tofuenv -``` + ```console + brew tap tofuutils/tap + brew install tofuenv + ``` +
-Install via Arch User Repository (AUR) +
Install via Arch User Repository (AUR) ```console git clone https://aur.archlinux.org/tofuenv.git cd tofuenv makepkg -si ``` +
+ -Install via Arch User Repository (AUR) via yay +
Install via Arch User Repository (AUR) via yay ```console yay --sync tofuenv ``` +
-### Manual (Linux and MacOS) - +### Manual +
Linux and MacOS + 1. Check out tofuenv into any path (here is `${HOME}/.tofuenv`) ```console @@ -89,7 +118,10 @@ ln -s ~/.tofuenv/bin/* ~/.local/bin which tofuenv ``` -### Manual (Windows) +
+ +
Windows + 1. Install Git-Bash ```console winget install --id Git.Git -e --source winget @@ -117,25 +149,34 @@ echo 'export PATH=$PATH:$HOME/.tofuenv/bin' >> ~/.bashrc which tofuenv ``` +
+ ## Install dependencies -Install jq (required) and GnuPG (optional, in case you want to enable GPG verification during OpenTofu installation) -### MacOS +Install **jq** (required) and **GnuPG** (optional, in case you want to enable GPG verification during OpenTofu installation) + +
MacOs + ```console brew install jq gnupg grep ``` +
-### Linux +
Linux + ```console sudo apt-get update -y sudo apt-get install -y jq gnupg ``` +
-### Windows (git-bash) +
Windows (git-bash) Install jq package into git-bash default installation folder: + ```console curl -L -o /usr/bin/jq.exe https://github.com/jqlang/jq/releases/latest/download/jq-win64.exe ``` +
## Usage @@ -213,20 +254,21 @@ terraform { } ``` -### Environment Variables - -#### TOFUENV +## Environment Variables -##### `TOFUENV_GITHUB_TOKEN` +### TOFUENV +
TOFUENV_GITHUB_TOKEN
+ String (Default: "") Specify GitHub token. Because of OpenTofu binares placed in the GitHub you may encounter with rate limit problem. Using a personal access token dramatically increases rate limit. [GitHub Rate limits for the REST API](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api) +
-##### `TOFUENV_ARCH` - +
TOFUENV_ARCH
+ String (Default: `amd64`) Specify architecture. Architecture other than the default amd64 can be specified with the `TOFUENV_ARCH` environment variable @@ -236,9 +278,10 @@ Note: Default changes to `arm64` for versions that have arm64 builds available w ```console TOFUENV_ARCH=arm64 tofuenv install 0.7.9 ``` +
-##### `TOFUENV_AUTO_INSTALL` - +
TOFUENV_AUTO_INSTALL
+ String (Default: true) Should tofuenv automatically install tofu if the version specified by defaults or a .opentofu-version file is not currently installed. @@ -253,8 +296,9 @@ Example: use 1.6.0-beta3 version that is not installed, and auto installation is $ TOFUENV_AUTO_INSTALL=false tofuenv use 1.6.0-beta3 No installed versions of opentofu matched '^1.6.0-beta3$'. TOFUENV_AUTO_INSTALL is set to false, so exiting. ``` +
-##### `TOFUENV_CURL_OUTPUT` +
TOFUENV_CURL_OUTPUT
Integer (Default: 2) @@ -263,8 +307,9 @@ Set the mechanism used for displaying download progress when downloading tofu ve * 2: v1 Behaviour: Pass `-#` to curl * 1: Use curl default * 0: Pass `-s` to curl +
-##### `TOFUENV_DEBUG` +
TOFUENV_DEBUG
Integer (Default: 0) @@ -274,8 +319,9 @@ Set the debug level for tofuenv. * 1: Simple debug output * 2: Extended debug output, with source file names and interactive debug shells on error * 3: Debug level 2 + Bash execution tracing +
-##### `TOFUENV_REMOTE` +
TOFUENV_REMOTE
String (Default: https://github.com/opentofu/opentofu/releases) @@ -284,8 +330,9 @@ To install from a remote other than the default ```console TOFUENV_REMOTE=https://example.jfrog.io/artifactory/opentofu ``` +
-##### `TOFUENV_REVERSE_REMOTE` +
TOFUENV_REVERSE_REMOTE
Integer (Default: 0) @@ -299,8 +346,9 @@ functionality will be restored. ```console TOFUENV_REVERSE_REMOTE=1 tofuenv list-remote ``` +
-##### `TOFUENV_SKIP_LIST_REMOTE` +
TOFUENV_SKIP_LIST_REMOTE
Integer (Default: 0) @@ -312,8 +360,9 @@ Enable: any other value ```console TOFUENV_SKIP_LIST_REMOTE=1 tofuenv install 1.6.0-rc1 ``` +
-##### `TOFUENV_CONFIG_DIR` +
TOFUENV_CONFIG_DIR
Path (Default: `$TOFUENV_ROOT`) @@ -322,8 +371,9 @@ The path to a directory where the local tofu versions and configuration files ex ```console TOFUENV_CONFIG_DIR="$XDG_CONFIG_HOME/tofuenv" ``` +
-##### `TOFUENV_TOFU_VERSION` +
TOFUENV_TOFU_VERSION
String (Default: "") @@ -336,8 +386,9 @@ e.g. ```console TOFUENV_TOFU_VERSION=latest:^0.11. tofu --version ``` +
-##### `TOFUENV_NETRC_PATH` +
TOFUENV_NETRC_PATH
String (Default: "") @@ -348,18 +399,20 @@ e.g. ```console TOFUENV_NETRC_PATH="$PWD/.netrc.tofuenv" ``` +
+--- -#### Bashlog Logging Library +### Bashlog Logging Library -##### `BASHLOG_COLOURS` +
BASHLOG_COLOURS
Integer (Default: 1) To disable colouring of console output, set to 0. +
- -##### `BASHLOG_DATE_FORMAT` +
BASHLOG_DATE_FORMAT
String (Default: +%F %T) @@ -367,16 +420,18 @@ The display format for the date as passed to the `date` binary to generate a dat * `FILE` type log file lines. * Each console output line when `BASHLOG_EXTRA=1` +
-##### `BASHLOG_EXTRA` +
BASHLOG_EXTRA
Integer (Default: 0) By default, console output from tofuenv does not print a date stamp or log severity. To enable this functionality, making normal output equivalent to FILE log output, set to 1. +
-##### `BASHLOG_FILE` +
BASHLOG_FILE
Integer (Default: 0) @@ -392,14 +447,16 @@ BASHLOG_FILE=1 tofuenv use latest ``` will log to `/tmp/tofuenv-use.log` +
-##### `BASHLOG_FILE_PATH` +
BASHLOG_FILE_PATH
String (Default: /tmp/$(basename ${0}).log) To specify a single file as the target for all FILE type logging regardless of the executing script. +
-##### `BASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX` +
BASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX
String (Default: "") @@ -413,8 +470,9 @@ e.g. BASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX='echo "${$$} "' ``` will prefix every log line with the calling process' PID. +
-##### `BASHLOG_JSON` +
BASHLOG_JSON
Integer (Default: 0) @@ -434,14 +492,16 @@ will log in JSON format to `/tmp/tofuenv-use.log.json` JSON log content: `{"timestamp":"","level":"","message":""}` +
-##### `BASHLOG_JSON_PATH` +
BASHLOG_JSON_PATH
String (Default: /tmp/$(basename ${0}).log.json) To specify a single file as the target for all JSON type logging regardless of the executing script. +
-##### `BASHLOG_SYSLOG` +
BASHLOG_SYSLOG
Integer (Default: 0) @@ -455,22 +515,25 @@ local facility="${BASHLOG_SYSLOG_FACILITY:-local0}"; local pid="${$}"; logger --id="${pid}" -t "${tag}" -p "${facility}.${severity}" "${syslog_line}" ``` +
-##### `BASHLOG_SYSLOG_FACILITY` +
BASHLOG_SYSLOG_FACILITY
String (Default: local0) The syslog facility to specify when using SYSLOG type logging. +
-##### `BASHLOG_SYSLOG_TAG` +
BASHLOG_SYSLOG_TAG
String (Default: $(basename $0)) The syslog tag to specify when using SYSLOG type logging. Defaults to the PID of the calling process. +
- +--- ### tofuenv use [version] From 6ad594d2f5f4d19d1e0232e69abbba52323536b0 Mon Sep 17 00:00:00 2001 From: Dhruv Gupta <114940443+Dhruvnotfound@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:32:40 +0530 Subject: [PATCH 2/6] Added Contributing/Community/Authors sections Signed-off-by: Dhruvnotfound --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 5cba443..7598f1f 100644 --- a/README.md +++ b/README.md @@ -660,6 +660,34 @@ git --git-dir=~/.tofuenv/.git pull rm -rf /some/path/to/tofuenv ``` +## Contributing + +Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. + +Check out our [contributing guide](CONTRIBUTING.md) to get started. + +Don't forget to give the project a star! Thanks again! + +## Community +Have questions or suggestions? Reach out to us via: + +* [GitHub Issues](https://github.com/tofuutils/tofuenv/issues) +* User/Developer Group: Join github community to get update of Harbor's news, features, releases, or to provide suggestion and feedback. +* Slack: Join tofuutils's community for discussion and ask questions: OpenTofu, channel: #tofuutils + +## Authors + This project was made possible by the help of these awesome contributors: + + + + + + + + Star History Chart + + + ## LICENSE - [tofuenv itself](https://github.com/tofuutils/tofuenv/blob/main/LICENSE) From 3221d1021e394650a6dc0a65432c4706b8272290 Mon Sep 17 00:00:00 2001 From: Dhruv Gupta <114940443+Dhruvnotfound@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:46:38 +0530 Subject: [PATCH 3/6] updated table of content Signed-off-by: Dhruvnotfound --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7598f1f..e016cee 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,14 @@ Important NoticeSupported OSInstallation • - Install dependencies • + Install dependenciesUsage • + Environment VariablesUpgradingUninstalling • + Contributing • + Community • + AuthorsLicense From 0845102ea446724e63d48f45188549299d7425dd Mon Sep 17 00:00:00 2001 From: Dhruv Gupta <114940443+Dhruvnotfound@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:19:31 +0530 Subject: [PATCH 4/6] corrected href tag Signed-off-by: Dhruvnotfound --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e016cee..6fee3a2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

tofuenv

-

OpenTofu version manager inspired by tfenv

+

OpenTofu version manager inspired by tfenv

### Table of Content
@@ -22,9 +22,9 @@
### Important Notice -Many people have asked about Terraform support, and we are finally ready to announce a successor for **tfenv** and **tofuenv**: tenv 🚀 written in Golang. tenv is able to handle Terraform binaries as well as OpenTofu binaries. 🎉 +Many people have asked about Terraform support, and we are finally ready to announce a successor for **tfenv** and **tofuenv**: tenv 🚀 written in Golang. tenv is able to handle Terraform binaries as well as OpenTofu binaries. 🎉 -Please contribute to tenv and award us stars⭐. +Please contribute to tenv and award us stars⭐. ## Supported OS From 49029e84ebd20aaa02ea3c7c50bce272ffc0af20 Mon Sep 17 00:00:00 2001 From: Dhruv Gupta <114940443+Dhruvnotfound@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:55:40 +0530 Subject: [PATCH 5/6] Added `id` attributes to environment variables for easier referencing Signed-off-by: Dhruvnotfound --- README.md | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 6fee3a2..90fecd0 100644 --- a/README.md +++ b/README.md @@ -262,7 +262,7 @@ terraform { ### TOFUENV -
TOFUENV_GITHUB_TOKEN
+
TOFUENV_GITHUB_TOKEN
String (Default: "") @@ -271,7 +271,7 @@ Using a personal access token dramatically increases rate limit. [GitHub Rate limits for the REST API](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api)
-
TOFUENV_ARCH
+
TOFUENV_ARCH
String (Default: `amd64`) @@ -284,7 +284,7 @@ TOFUENV_ARCH=arm64 tofuenv install 0.7.9 ```
-
TOFUENV_AUTO_INSTALL
+
TOFUENV_AUTO_INSTALL
String (Default: true) @@ -302,7 +302,7 @@ No installed versions of opentofu matched '^1.6.0-beta3$'. TOFUENV_AUTO_INSTALL ```
-
TOFUENV_CURL_OUTPUT
+
TOFUENV_CURL_OUTPUT
Integer (Default: 2) @@ -313,7 +313,7 @@ Set the mechanism used for displaying download progress when downloading tofu ve * 0: Pass `-s` to curl
-
TOFUENV_DEBUG
+
TOFUENV_DEBUG
Integer (Default: 0) @@ -325,7 +325,7 @@ Set the debug level for tofuenv. * 3: Debug level 2 + Bash execution tracing
-
TOFUENV_REMOTE
+
TOFUENV_REMOTE
String (Default: https://github.com/opentofu/opentofu/releases) @@ -336,7 +336,7 @@ TOFUENV_REMOTE=https://example.jfrog.io/artifactory/opentofu ```
-
TOFUENV_REVERSE_REMOTE
+
TOFUENV_REVERSE_REMOTE
Integer (Default: 0) @@ -352,7 +352,7 @@ TOFUENV_REVERSE_REMOTE=1 tofuenv list-remote ```
-
TOFUENV_SKIP_LIST_REMOTE
+
TOFUENV_SKIP_LIST_REMOTE
Integer (Default: 0) @@ -366,7 +366,7 @@ TOFUENV_SKIP_LIST_REMOTE=1 tofuenv install 1.6.0-rc1 ```
-
TOFUENV_CONFIG_DIR
+
TOFUENV_CONFIG_DIR
Path (Default: `$TOFUENV_ROOT`) @@ -377,7 +377,7 @@ TOFUENV_CONFIG_DIR="$XDG_CONFIG_HOME/tofuenv" ```
-
TOFUENV_TOFU_VERSION
+
TOFUENV_TOFU_VERSION
String (Default: "") @@ -392,7 +392,7 @@ TOFUENV_TOFU_VERSION=latest:^0.11. tofu --version ```
-
TOFUENV_NETRC_PATH
+
TOFUENV_NETRC_PATH
String (Default: "") @@ -409,14 +409,14 @@ TOFUENV_NETRC_PATH="$PWD/.netrc.tofuenv" ### Bashlog Logging Library -
BASHLOG_COLOURS
+
BASHLOG_COLOURS
Integer (Default: 1) To disable colouring of console output, set to 0.
-
BASHLOG_DATE_FORMAT
+
BASHLOG_DATE_FORMAT
String (Default: +%F %T) @@ -426,7 +426,7 @@ The display format for the date as passed to the `date` binary to generate a dat * Each console output line when `BASHLOG_EXTRA=1`
-
BASHLOG_EXTRA
+
BASHLOG_EXTRA
Integer (Default: 0) @@ -435,7 +435,7 @@ By default, console output from tofuenv does not print a date stamp or log sever To enable this functionality, making normal output equivalent to FILE log output, set to 1.
-
BASHLOG_FILE
+
BASHLOG_FILE
Integer (Default: 0) @@ -453,14 +453,14 @@ BASHLOG_FILE=1 tofuenv use latest will log to `/tmp/tofuenv-use.log`
-
BASHLOG_FILE_PATH
+
BASHLOG_FILE_PATH
String (Default: /tmp/$(basename ${0}).log) To specify a single file as the target for all FILE type logging regardless of the executing script.
-
BASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX
+
BASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX
String (Default: "") @@ -476,7 +476,7 @@ BASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX='echo "${$$} "' will prefix every log line with the calling process' PID.
-
BASHLOG_JSON
+
BASHLOG_JSON
Integer (Default: 0) @@ -498,14 +498,14 @@ JSON log content: `{"timestamp":"","level":"","message":""}`
-
BASHLOG_JSON_PATH
+
BASHLOG_JSON_PATH
String (Default: /tmp/$(basename ${0}).log.json) To specify a single file as the target for all JSON type logging regardless of the executing script.
-
BASHLOG_SYSLOG
+
BASHLOG_SYSLOG
Integer (Default: 0) @@ -521,14 +521,14 @@ logger --id="${pid}" -t "${tag}" -p "${facility}.${severity}" "${syslog_line}" ```
-
BASHLOG_SYSLOG_FACILITY
+
BASHLOG_SYSLOG_FACILITY
String (Default: local0) The syslog facility to specify when using SYSLOG type logging.
-
BASHLOG_SYSLOG_TAG
+
BASHLOG_SYSLOG_TAG
String (Default: $(basename $0)) From 3000987c91ce883e368759d9434c79326cccf178 Mon Sep 17 00:00:00 2001 From: Dhruv Gupta <114940443+Dhruvnotfound@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:00:40 +0530 Subject: [PATCH 6/6] corrected numbering in Windows section of installation Signed-off-by: Dhruvnotfound --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 90fecd0..aeb20b0 100644 --- a/README.md +++ b/README.md @@ -136,19 +136,19 @@ winget install --id Git.Git -e --source winget "C:\Program Files\Git\bin\sh.exe" ``` -2. Check out tofuenv into any path (here is ${HOME}/.tofuenv) +3. Check out tofuenv into any path (here is ${HOME}/.tofuenv) ```console git clone --depth=1 https://github.com/tofuutils/tofuenv.git ~/.tofuenv ``` -2. Add ~/.tofuenv/bin to your $PATH +4. Add ~/.tofuenv/bin to your $PATH ```console echo 'export PATH=$PATH:$HOME/.tofuenv/bin' >> ~/.bashrc ``` -4. Relaunch git-bash environment for the changes to be applied (you can do it via ```exit``` command). +5. Relaunch git-bash environment for the changes to be applied (you can do it via ```exit``` command). -5. Verify installation by executing: +6. Verify installation by executing: ```console which tofuenv ```