diff --git a/.circleci/config.yml b/.circleci/config.yml index 7dd98d51..7a5e3841 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,7 +13,16 @@ jobs: - checkout - run: command: | - set +e + set +e + echo "Building website" + sudo apt-get install python3 + sudo apt-get install python3-pip + pip3 install mkdocs-material + cd www + mkdocs gh-deploy --force + cd .. + + echo "Building application" go get -v -t -d ./... go vet -tests=false ./... go test -v ./... @@ -51,7 +60,11 @@ workflows: build_and_test: jobs: - - build + - build: + filters: + branches: + ignore: + - gh-pages - release: requires: - build diff --git a/.gitignore b/.gitignore index 3de84fc4..50898570 100644 --- a/.gitignore +++ b/.gitignore @@ -29,10 +29,7 @@ docs/.bundle/** .sass-cache -.tfswitchrc - tfswitch* build-script.sh -.tfswitch.toml \ No newline at end of file diff --git a/README.md b/README.md index ea8e8704..c6d795bd 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,6 @@ If you do not have a particular version of terraform installed, `tfswitch` will The installation is minimal and easy. Once installed, simply select the version you require from the dropdown and start using terraform. -See installation guide here: [tfswitch installation](https://warrensbox.github.io/terraform-switcher/) - ## Installation `tfswitch` is available for MacOS and Linux based operating systems. @@ -28,7 +26,7 @@ Installation for MacOS is the easiest with Homebrew. [If you do not have homebre brew install warrensbox/tap/tfswitch ``` -### Linux +### General Linux Installation for other linux operation systems. @@ -36,13 +34,21 @@ Installation for other linux operation systems. curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash ``` +### Snapcraft for CentOS, Ubuntu, Linux Mint, RHEL, Debian, Fedora + +```sh +sudo snap install tfswitch +``` + ### Install from source Alternatively, you can install the binary from source [here](https://github.com/warrensbox/terraform-switcher/releases) +[Having trouble installing](https://tfswitch.warrensbox.com/Troubleshoot/). + ## How to use: ### Use dropdown menu to select version -drawing +drawing 1. You can switch between different versions of terraform by typing the command `tfswitch` on your terminal. 2. Select the version of terraform you require by using the up and down arrow. @@ -51,22 +57,22 @@ Alternatively, you can install the binary from source [here](https://github.com/ The most recently selected versions are presented at the top of the dropdown. ### Supply version on command line -drawing +drawing 1. You can also supply the desired version as an argument on the command line. 2. For example, `tfswitch 0.10.5` for version 0.10.5 of terraform. 3. Hit **Enter** to switch. ### See all versions including beta, alpha and release candidates(rc) -drawing +drawing 1. Display all versions including beta, alpha and release candidates(rc). 2. For example, `tfswitch -l` or `tfswitch --list-all` to see all versions. 3. Hit **Enter** to select the desired version. ### Use version.tf file -If a .tf file with the terraform constrain is included in the current directory, it should automatically download or switch to that terraform version. For example, the following should automatically switch terraform to version `0.12.24`: -``` +If a .tf file with the terraform constrain is included in the current directory, it should automatically download or switch to that terraform version. For example, the following should automatically switch terraform to the lastest version: +```ruby terraform { required_version = ">= 0.12.9" @@ -76,28 +82,29 @@ terraform { } } ``` -drawing +drawing ### Use .tfswitch.toml file (For non-admin - users with limited privilege on their computers) This is similiar to using a .tfswitchrc file, but you can specify a custom binary path for your terraform installation -drawing -drawing +drawing + +drawing 1. Create a custom binary path. Ex: `mkdir /Users/warrenveerasingam/bin` (replace warrenveerasingam with your username) 2. Add the path to your PATH. Ex: `export PATH=$PATH:/Users/warrenveerasingam/bin` (add this to your bash profile or zsh profile) 3. Pass -b or --bin parameter with your custom path to install terraform. Ex: `tfswitch -b /Users/warrenveerasingam/bin/terraform 0.10.8 ` -4. Optionally, you can create a `.tfswitch.toml` file in your terraform directory. +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 5. Your `.tfswitch.toml` file should look like this: -``` +```ruby bin = "/Users/warrenveerasingam/bin/terraform" version = "0.11.3" ``` 4. Run `tfswitch` and it should automatically install the required terraform version in the specified binary path ### Use .tfswitchrc file -drawing +drawing 1. Create a `.tfswitchrc` file containing the desired version 2. For example, `echo "0.10.5" >> .tfswitchrc` for version 0.10.5 of terraform @@ -110,7 +117,7 @@ version = "0.11.3" Add the following to the end of your `~/.bashrc` file: (Use either `.tfswitchrc` or `.tfswitch.toml` or `.terraform-version`) -``` +```sh cdtfswitch(){ builtin cd "$@"; cdir=$PWD; @@ -125,7 +132,7 @@ alias cd='cdtfswitch' Add the following to the end of your `~/.zshrc` file: -``` +```sh load-tfswitch() { local tfswitchrc_path=".tfswitchrc" @@ -142,7 +149,7 @@ load-tfswitch > ``` *older version of zsh* -``` +```sh cd(){ builtin cd "$@"; cdir=$PWD; @@ -152,23 +159,101 @@ cd(){ } ``` +**Automatically switch with fish shell** + +Add the following to the end of your `~/.config/fish/config.fish` file: + +```sh +function switch_terraform --on-event fish_postexec + string match --regex '^cd\s' "$argv" > /dev/null + set --local is_command_cd $status + + if test $is_command_cd -eq 0 + if count *.tf > /dev/null + + grep -c "required_version" *.tf > /dev/null + set --local tf_contains_version $status + + if test $tf_contains_version -eq 0 + command tfswitch + end + end + end +end +``` + ### Jenkins setup drawing -``` +```sh #!/bin/bash echo "Installing tfswitch locally" -wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh -chmod 755 install.sh -./install.sh -b bin-directory +wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh #Get the installer on to your machine + +chmod 755 install.sh #Make installer executable + +./install.sh -b `pwd`/.bin #Install tfswitch in a location you have permission + +CUSTOMBIN=`pwd`/.bin #set custom bin path + +export PATH=$PATH:$CUSTOMBIN #Add custom bin path to PATH environment + +$CUSTOMBIN/tfswitch -b $CUSTOMBIN/terraform 0.11.7 #or simply tfswitch -b $CUSTOMBIN/terraform 0.11.7 -./bin-directory/tfswitch +terraform -v #testing version ``` +### Circle CI setup + +drawing + + +Example config yaml +```yaml +version: 2 +jobs: + build: + docker: + - image: ubuntu + + working_directory: /go/src/github.com/warrensbox/terraform-switcher + + steps: + - checkout + - run: + command: | + set +e + apt-get update + apt-get install -y wget + rm -rf /var/lib/apt/lists/* + + echo "Installing tfswitch locally" + + wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh #Get the installer on to your machine + + chmod 755 install.sh #Make installer executable + + ./install.sh -b `pwd`/.bin #Install tfswitch in a location you have permission + + CUSTOMBIN=`pwd`/.bin #set custom bin path + + export PATH=$PATH:$CUSTOMBIN #Add custom bin path to PATH environment + + $CUSTOMBIN/tfswitch -b $CUSTOMBIN/terraform 0.11.7 #or simply tfswitch -b $CUSTOMBIN/terraform 0.11.7 + + terraform -v #testing version +``` + +## How to contribute +An open source project becomes meaningful when people collaborate to improve the code. +Feel free to look at the code, critique and make suggestions. Lets make `tfswitch` better! + +See step-by-step instructions on how to contribute here: [Contribute](https://tfswitch.warrensbox.com/How-to-Contribute/) + ## Additional Info -See how to *upgrade*, *uninstall*, *troubleshoot* here: [More info](https://warrensbox.github.io/terraform-switcher/additional) +See how to *upgrade*, *uninstall*, *troubleshoot* here: [More info](https://tfswitch.warrensbox.com/Upgrade-or-Uninstall/) ## Issues diff --git a/docs/Gemfile b/docs/Gemfile deleted file mode 100644 index 8215629a..00000000 --- a/docs/Gemfile +++ /dev/null @@ -1,10 +0,0 @@ -source 'https://rubygems.org' -gem 'github-pages', group: :jekyll_plugins -gem "minima" - -gem "commonmarker" - -gem "ffi", ">= 1.9.24" -gem "rubyzip", ">= 1.2.2" -gem "jekyll", ">= 3.7.4" -gem "nokogiri", ">= 1.8.5" \ No newline at end of file diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock deleted file mode 100644 index c604714a..00000000 --- a/docs/Gemfile.lock +++ /dev/null @@ -1,254 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - activesupport (4.2.10) - i18n (~> 0.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.11.1) - colorator (1.1.0) - commonmarker (0.17.13) - ruby-enum (~> 0.5) - concurrent-ruby (1.1.4) - dnsruby (1.61.2) - addressable (~> 2.5) - em-websocket (0.5.1) - eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) - ethon (0.12.0) - ffi (>= 1.3.0) - eventmachine (1.2.7) - execjs (2.7.0) - faraday (0.15.4) - multipart-post (>= 1.2, < 3) - ffi (1.10.0) - forwardable-extended (2.6.0) - gemoji (3.0.0) - github-pages (193) - activesupport (= 4.2.10) - github-pages-health-check (= 1.8.1) - jekyll (= 3.7.4) - jekyll-avatar (= 0.6.0) - jekyll-coffeescript (= 1.1.1) - jekyll-commonmark-ghpages (= 0.1.5) - jekyll-default-layout (= 0.1.4) - jekyll-feed (= 0.11.0) - jekyll-gist (= 1.5.0) - jekyll-github-metadata (= 2.9.4) - jekyll-mentions (= 1.4.1) - jekyll-optional-front-matter (= 0.3.0) - jekyll-paginate (= 1.1.0) - jekyll-readme-index (= 0.2.0) - jekyll-redirect-from (= 0.14.0) - jekyll-relative-links (= 0.5.3) - jekyll-remote-theme (= 0.3.1) - jekyll-sass-converter (= 1.5.2) - jekyll-seo-tag (= 2.5.0) - jekyll-sitemap (= 1.2.0) - jekyll-swiss (= 0.4.0) - jekyll-theme-architect (= 0.1.1) - jekyll-theme-cayman (= 0.1.1) - jekyll-theme-dinky (= 0.1.1) - jekyll-theme-hacker (= 0.1.1) - jekyll-theme-leap-day (= 0.1.1) - jekyll-theme-merlot (= 0.1.1) - jekyll-theme-midnight (= 0.1.1) - jekyll-theme-minimal (= 0.1.1) - jekyll-theme-modernist (= 0.1.1) - jekyll-theme-primer (= 0.5.3) - jekyll-theme-slate (= 0.1.1) - jekyll-theme-tactile (= 0.1.1) - jekyll-theme-time-machine (= 0.1.1) - jekyll-titles-from-headings (= 0.5.1) - jemoji (= 0.10.1) - kramdown (= 1.17.0) - liquid (= 4.0.0) - listen (= 3.1.5) - mercenary (~> 0.3) - minima (= 2.5.0) - nokogiri (>= 1.8.2, < 2.0) - rouge (= 2.2.1) - terminal-table (~> 1.4) - github-pages-health-check (1.8.1) - addressable (~> 2.3) - dnsruby (~> 1.60) - octokit (~> 4.0) - public_suffix (~> 2.0) - typhoeus (~> 1.3) - html-pipeline (2.10.0) - activesupport (>= 2) - nokogiri (>= 1.4) - http_parser.rb (0.6.0) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - jekyll (3.7.4) - addressable (~> 2.4) - colorator (~> 1.0) - em-websocket (~> 0.5) - i18n (~> 0.7) - jekyll-sass-converter (~> 1.0) - jekyll-watch (~> 2.0) - kramdown (~> 1.14) - liquid (~> 4.0) - mercenary (~> 0.3.3) - pathutil (~> 0.9) - rouge (>= 1.7, < 4) - safe_yaml (~> 1.0) - jekyll-avatar (0.6.0) - jekyll (~> 3.0) - jekyll-coffeescript (1.1.1) - coffee-script (~> 2.2) - coffee-script-source (~> 1.11.1) - jekyll-commonmark (1.2.0) - commonmarker (~> 0.14) - jekyll (>= 3.0, < 4.0) - jekyll-commonmark-ghpages (0.1.5) - commonmarker (~> 0.17.6) - jekyll-commonmark (~> 1) - rouge (~> 2) - jekyll-default-layout (0.1.4) - jekyll (~> 3.0) - jekyll-feed (0.11.0) - jekyll (~> 3.3) - jekyll-gist (1.5.0) - octokit (~> 4.2) - jekyll-github-metadata (2.9.4) - jekyll (~> 3.1) - octokit (~> 4.0, != 4.4.0) - jekyll-mentions (1.4.1) - html-pipeline (~> 2.3) - jekyll (~> 3.0) - jekyll-optional-front-matter (0.3.0) - jekyll (~> 3.0) - jekyll-paginate (1.1.0) - jekyll-readme-index (0.2.0) - jekyll (~> 3.0) - jekyll-redirect-from (0.14.0) - jekyll (~> 3.3) - jekyll-relative-links (0.5.3) - jekyll (~> 3.3) - jekyll-remote-theme (0.3.1) - jekyll (~> 3.5) - rubyzip (>= 1.2.1, < 3.0) - jekyll-sass-converter (1.5.2) - sass (~> 3.4) - jekyll-seo-tag (2.5.0) - jekyll (~> 3.3) - jekyll-sitemap (1.2.0) - jekyll (~> 3.3) - jekyll-swiss (0.4.0) - jekyll-theme-architect (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-cayman (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-dinky (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-hacker (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-leap-day (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-merlot (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-midnight (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-minimal (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-modernist (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-primer (0.5.3) - jekyll (~> 3.5) - jekyll-github-metadata (~> 2.9) - jekyll-seo-tag (~> 2.0) - jekyll-theme-slate (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-tactile (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-time-machine (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-titles-from-headings (0.5.1) - jekyll (~> 3.3) - jekyll-watch (2.1.2) - listen (~> 3.0) - jemoji (0.10.1) - gemoji (~> 3.0) - html-pipeline (~> 2.2) - jekyll (~> 3.0) - kramdown (1.17.0) - liquid (4.0.0) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - mercenary (0.3.6) - mini_portile2 (2.4.0) - minima (2.5.0) - jekyll (~> 3.5) - jekyll-feed (~> 0.9) - jekyll-seo-tag (~> 2.1) - minitest (5.11.3) - multipart-post (2.0.0) - nokogiri (1.10.8) - mini_portile2 (~> 2.4.0) - octokit (4.13.0) - sawyer (~> 0.8.0, >= 0.5.3) - pathutil (0.16.2) - forwardable-extended (~> 2.6) - public_suffix (2.0.5) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) - ffi (~> 1.0) - rouge (2.2.1) - ruby-enum (0.7.2) - i18n - ruby_dep (1.5.0) - rubyzip (1.3.0) - safe_yaml (1.0.4) - sass (3.7.3) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sawyer (0.8.1) - addressable (>= 2.3.5, < 2.6) - faraday (~> 0.8, < 1.0) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) - thread_safe (0.3.6) - typhoeus (1.3.1) - ethon (>= 0.9.0) - tzinfo (1.2.5) - thread_safe (~> 0.1) - unicode-display_width (1.4.1) - -PLATFORMS - ruby - -DEPENDENCIES - commonmarker - ffi (>= 1.9.24) - github-pages - jekyll (>= 3.7.4) - minima - nokogiri (>= 1.8.5) - rubyzip (>= 1.2.2) - -BUNDLED WITH - 1.16.2 diff --git a/docs/_config.yml b/docs/_config.yml deleted file mode 100644 index 11dd5e3e..00000000 --- a/docs/_config.yml +++ /dev/null @@ -1,11 +0,0 @@ -theme: jekyll-theme-minimal -#github: [metadata] -repository: warrensbox/terraform-switcher -logo: /assets/img/logo.png -title: tfswitch - -show_downloads: true - -exclude: [vendor] - -#github: [metadata] diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html deleted file mode 100644 index 9ba0968e..00000000 --- a/docs/_layouts/default.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - -{% seo %} - - - - - - - - - - - -
-
- - - -

- Logo -

- -

{{ site.description | default: site.github.project_tagline }}

- - Travis - Go Report - -
- - {% if site.show_downloads %} - - {% endif %} - - -Star -
-
- - {{ content }} - {% if site.github.is_project_page %} -

This project is maintained by {{ site.github.owner_name }}

- {% endif %} -
- -
- - {% if site.google_analytics %} - - - - {% endif %} - - \ No newline at end of file diff --git a/docs/_site/Gemfile b/docs/_site/Gemfile deleted file mode 100644 index 8215629a..00000000 --- a/docs/_site/Gemfile +++ /dev/null @@ -1,10 +0,0 @@ -source 'https://rubygems.org' -gem 'github-pages', group: :jekyll_plugins -gem "minima" - -gem "commonmarker" - -gem "ffi", ">= 1.9.24" -gem "rubyzip", ">= 1.2.2" -gem "jekyll", ">= 3.7.4" -gem "nokogiri", ">= 1.8.5" \ No newline at end of file diff --git a/docs/_site/Gemfile.lock b/docs/_site/Gemfile.lock deleted file mode 100644 index c604714a..00000000 --- a/docs/_site/Gemfile.lock +++ /dev/null @@ -1,254 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - activesupport (4.2.10) - i18n (~> 0.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.11.1) - colorator (1.1.0) - commonmarker (0.17.13) - ruby-enum (~> 0.5) - concurrent-ruby (1.1.4) - dnsruby (1.61.2) - addressable (~> 2.5) - em-websocket (0.5.1) - eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) - ethon (0.12.0) - ffi (>= 1.3.0) - eventmachine (1.2.7) - execjs (2.7.0) - faraday (0.15.4) - multipart-post (>= 1.2, < 3) - ffi (1.10.0) - forwardable-extended (2.6.0) - gemoji (3.0.0) - github-pages (193) - activesupport (= 4.2.10) - github-pages-health-check (= 1.8.1) - jekyll (= 3.7.4) - jekyll-avatar (= 0.6.0) - jekyll-coffeescript (= 1.1.1) - jekyll-commonmark-ghpages (= 0.1.5) - jekyll-default-layout (= 0.1.4) - jekyll-feed (= 0.11.0) - jekyll-gist (= 1.5.0) - jekyll-github-metadata (= 2.9.4) - jekyll-mentions (= 1.4.1) - jekyll-optional-front-matter (= 0.3.0) - jekyll-paginate (= 1.1.0) - jekyll-readme-index (= 0.2.0) - jekyll-redirect-from (= 0.14.0) - jekyll-relative-links (= 0.5.3) - jekyll-remote-theme (= 0.3.1) - jekyll-sass-converter (= 1.5.2) - jekyll-seo-tag (= 2.5.0) - jekyll-sitemap (= 1.2.0) - jekyll-swiss (= 0.4.0) - jekyll-theme-architect (= 0.1.1) - jekyll-theme-cayman (= 0.1.1) - jekyll-theme-dinky (= 0.1.1) - jekyll-theme-hacker (= 0.1.1) - jekyll-theme-leap-day (= 0.1.1) - jekyll-theme-merlot (= 0.1.1) - jekyll-theme-midnight (= 0.1.1) - jekyll-theme-minimal (= 0.1.1) - jekyll-theme-modernist (= 0.1.1) - jekyll-theme-primer (= 0.5.3) - jekyll-theme-slate (= 0.1.1) - jekyll-theme-tactile (= 0.1.1) - jekyll-theme-time-machine (= 0.1.1) - jekyll-titles-from-headings (= 0.5.1) - jemoji (= 0.10.1) - kramdown (= 1.17.0) - liquid (= 4.0.0) - listen (= 3.1.5) - mercenary (~> 0.3) - minima (= 2.5.0) - nokogiri (>= 1.8.2, < 2.0) - rouge (= 2.2.1) - terminal-table (~> 1.4) - github-pages-health-check (1.8.1) - addressable (~> 2.3) - dnsruby (~> 1.60) - octokit (~> 4.0) - public_suffix (~> 2.0) - typhoeus (~> 1.3) - html-pipeline (2.10.0) - activesupport (>= 2) - nokogiri (>= 1.4) - http_parser.rb (0.6.0) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - jekyll (3.7.4) - addressable (~> 2.4) - colorator (~> 1.0) - em-websocket (~> 0.5) - i18n (~> 0.7) - jekyll-sass-converter (~> 1.0) - jekyll-watch (~> 2.0) - kramdown (~> 1.14) - liquid (~> 4.0) - mercenary (~> 0.3.3) - pathutil (~> 0.9) - rouge (>= 1.7, < 4) - safe_yaml (~> 1.0) - jekyll-avatar (0.6.0) - jekyll (~> 3.0) - jekyll-coffeescript (1.1.1) - coffee-script (~> 2.2) - coffee-script-source (~> 1.11.1) - jekyll-commonmark (1.2.0) - commonmarker (~> 0.14) - jekyll (>= 3.0, < 4.0) - jekyll-commonmark-ghpages (0.1.5) - commonmarker (~> 0.17.6) - jekyll-commonmark (~> 1) - rouge (~> 2) - jekyll-default-layout (0.1.4) - jekyll (~> 3.0) - jekyll-feed (0.11.0) - jekyll (~> 3.3) - jekyll-gist (1.5.0) - octokit (~> 4.2) - jekyll-github-metadata (2.9.4) - jekyll (~> 3.1) - octokit (~> 4.0, != 4.4.0) - jekyll-mentions (1.4.1) - html-pipeline (~> 2.3) - jekyll (~> 3.0) - jekyll-optional-front-matter (0.3.0) - jekyll (~> 3.0) - jekyll-paginate (1.1.0) - jekyll-readme-index (0.2.0) - jekyll (~> 3.0) - jekyll-redirect-from (0.14.0) - jekyll (~> 3.3) - jekyll-relative-links (0.5.3) - jekyll (~> 3.3) - jekyll-remote-theme (0.3.1) - jekyll (~> 3.5) - rubyzip (>= 1.2.1, < 3.0) - jekyll-sass-converter (1.5.2) - sass (~> 3.4) - jekyll-seo-tag (2.5.0) - jekyll (~> 3.3) - jekyll-sitemap (1.2.0) - jekyll (~> 3.3) - jekyll-swiss (0.4.0) - jekyll-theme-architect (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-cayman (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-dinky (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-hacker (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-leap-day (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-merlot (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-midnight (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-minimal (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-modernist (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-primer (0.5.3) - jekyll (~> 3.5) - jekyll-github-metadata (~> 2.9) - jekyll-seo-tag (~> 2.0) - jekyll-theme-slate (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-tactile (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-time-machine (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-titles-from-headings (0.5.1) - jekyll (~> 3.3) - jekyll-watch (2.1.2) - listen (~> 3.0) - jemoji (0.10.1) - gemoji (~> 3.0) - html-pipeline (~> 2.2) - jekyll (~> 3.0) - kramdown (1.17.0) - liquid (4.0.0) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - mercenary (0.3.6) - mini_portile2 (2.4.0) - minima (2.5.0) - jekyll (~> 3.5) - jekyll-feed (~> 0.9) - jekyll-seo-tag (~> 2.1) - minitest (5.11.3) - multipart-post (2.0.0) - nokogiri (1.10.8) - mini_portile2 (~> 2.4.0) - octokit (4.13.0) - sawyer (~> 0.8.0, >= 0.5.3) - pathutil (0.16.2) - forwardable-extended (~> 2.6) - public_suffix (2.0.5) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) - ffi (~> 1.0) - rouge (2.2.1) - ruby-enum (0.7.2) - i18n - ruby_dep (1.5.0) - rubyzip (1.3.0) - safe_yaml (1.0.4) - sass (3.7.3) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sawyer (0.8.1) - addressable (>= 2.3.5, < 2.6) - faraday (~> 0.8, < 1.0) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) - thread_safe (0.3.6) - typhoeus (1.3.1) - ethon (>= 0.9.0) - tzinfo (1.2.5) - thread_safe (~> 0.1) - unicode-display_width (1.4.1) - -PLATFORMS - ruby - -DEPENDENCIES - commonmarker - ffi (>= 1.9.24) - github-pages - jekyll (>= 3.7.4) - minima - nokogiri (>= 1.8.5) - rubyzip (>= 1.2.2) - -BUNDLED WITH - 1.16.2 diff --git a/docs/_site/additional.html b/docs/_site/additional.html deleted file mode 100644 index 463734ce..00000000 --- a/docs/_site/additional.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - -tfswitch | A command line tool to switch between different versions of terraform (with homebrew and more) - - - - - - - - - - - - - - - - - - - - -
-
- - - -

- Logo -

- -

A command line tool to switch between different versions of terraform (with homebrew and more)

- - Travis - Go Report - -
- - - - - - -Star -
-
- - -

Back to main

- -

Upgrade:

- -

Homebrew

- -
brew upgrade warrensbox/tap/tfswitch
-
-

Linux

- -

Rerun:

- -
curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash
-
- -

Uninstall:

- -

Homebrew

- -
brew uninstall warrensbox/tap/tfswitch
-
-

Linux

- -

Rerun:

- -
rm /usr/local/bin/tfswitch
-
- -

Troubleshoot:

- -

Common issues:

-
install: can't change permissions of /usr/local/bin: Operation not permitted
-
- -
"Unable to remove symlink. You must have SUDO privileges"
-
- -
"Unable to create symlink. You must have SUDO privileges"
-
-

You probably need to have sudo privileges to install tfswitch.

- -

Back to top
-Back to main

- - -

This project is maintained by warrensbox

- -
- -
- - - - \ No newline at end of file diff --git a/docs/_site/additional.md b/docs/_site/additional.md deleted file mode 100644 index 36174332..00000000 --- a/docs/_site/additional.md +++ /dev/null @@ -1,51 +0,0 @@ - -[Back to main](index) - -## Upgrade: - -### Homebrew - -```ruby -brew upgrade warrensbox/tap/tfswitch -``` -### Linux - -Rerun: - -```sh -curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash -``` - -## Uninstall: - -### Homebrew - -```ruby -brew uninstall warrensbox/tap/tfswitch -``` -### Linux - -Rerun: - -```sh -rm /usr/local/bin/tfswitch -``` - -## Troubleshoot: - -Common issues: -```ruby -install: can't change permissions of /usr/local/bin: Operation not permitted -``` - -```ruby -"Unable to remove symlink. You must have SUDO privileges" -``` - -```ruby -"Unable to create symlink. You must have SUDO privileges" -``` -You probably need to have **sudo** privileges to install *tfswitch*. - -[Back to top](#upgrade) -[Back to main](index) \ No newline at end of file diff --git a/docs/_site/assets/css/style.css b/docs/_site/assets/css/style.css deleted file mode 100644 index 4517e30e..00000000 --- a/docs/_site/assets/css/style.css +++ /dev/null @@ -1,214 +0,0 @@ -@font-face { font-family: 'Noto Sans'; font-weight: 400; font-style: normal; src: url("../fonts/Noto-Sans-regular/Noto-Sans-regular.eot"); src: url("../fonts/Noto-Sans-regular/Noto-Sans-regular.eot?#iefix") format("embedded-opentype"), local("Noto Sans"), local("Noto-Sans-regular"), url("../fonts/Noto-Sans-regular/Noto-Sans-regular.woff2") format("woff2"), url("../fonts/Noto-Sans-regular/Noto-Sans-regular.woff") format("woff"), url("../fonts/Noto-Sans-regular/Noto-Sans-regular.ttf") format("truetype"), url("../fonts/Noto-Sans-regular/Noto-Sans-regular.svg#NotoSans") format("svg"); } -@font-face { font-family: 'Noto Sans'; font-weight: 700; font-style: normal; src: url("../fonts/Noto-Sans-700/Noto-Sans-700.eot"); src: url("../fonts/Noto-Sans-700/Noto-Sans-700.eot?#iefix") format("embedded-opentype"), local("Noto Sans Bold"), local("Noto-Sans-700"), url("../fonts/Noto-Sans-700/Noto-Sans-700.woff2") format("woff2"), url("../fonts/Noto-Sans-700/Noto-Sans-700.woff") format("woff"), url("../fonts/Noto-Sans-700/Noto-Sans-700.ttf") format("truetype"), url("../fonts/Noto-Sans-700/Noto-Sans-700.svg#NotoSans") format("svg"); } -@font-face { font-family: 'Noto Sans'; font-weight: 400; font-style: italic; src: url("../fonts/Noto-Sans-italic/Noto-Sans-italic.eot"); src: url("../fonts/Noto-Sans-italic/Noto-Sans-italic.eot?#iefix") format("embedded-opentype"), local("Noto Sans Italic"), local("Noto-Sans-italic"), url("../fonts/Noto-Sans-italic/Noto-Sans-italic.woff2") format("woff2"), url("../fonts/Noto-Sans-italic/Noto-Sans-italic.woff") format("woff"), url("../fonts/Noto-Sans-italic/Noto-Sans-italic.ttf") format("truetype"), url("../fonts/Noto-Sans-italic/Noto-Sans-italic.svg#NotoSans") format("svg"); } -@font-face { font-family: 'Noto Sans'; font-weight: 700; font-style: italic; src: url("../fonts/Noto-Sans-700italic/Noto-Sans-700italic.eot"); src: url("../fonts/Noto-Sans-700italic/Noto-Sans-700italic.eot?#iefix") format("embedded-opentype"), local("Noto Sans Bold Italic"), local("Noto-Sans-700italic"), url("../fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff2") format("woff2"), url("../fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff") format("woff"), url("../fonts/Noto-Sans-700italic/Noto-Sans-700italic.ttf") format("truetype"), url("../fonts/Noto-Sans-700italic/Noto-Sans-700italic.svg#NotoSans") format("svg"); } -.highlight table td { padding: 5px; } - -.highlight table pre { margin: 0; } - -.highlight .cm { color: #999988; font-style: italic; } - -.highlight .cp { color: #999999; font-weight: bold; } - -.highlight .c1 { color: #999988; font-style: italic; } - -.highlight .cs { color: #999999; font-weight: bold; font-style: italic; } - -.highlight .c, .highlight .cd { color: #999988; font-style: italic; } - -.highlight .err { color: #a61717; background-color: #e3d2d2; } - -.highlight .gd { color: #000000; background-color: #ffdddd; } - -.highlight .ge { color: #000000; font-style: italic; } - -.highlight .gr { color: #aa0000; } - -.highlight .gh { color: #999999; } - -.highlight .gi { color: #000000; background-color: #ddffdd; } - -.highlight .go { color: #888888; } - -.highlight .gp { color: #555555; } - -.highlight .gs { font-weight: bold; } - -.highlight .gu { color: #aaaaaa; } - -.highlight .gt { color: #aa0000; } - -.highlight .kc { color: #000000; font-weight: bold; } - -.highlight .kd { color: #000000; font-weight: bold; } - -.highlight .kn { color: #000000; font-weight: bold; } - -.highlight .kp { color: #000000; font-weight: bold; } - -.highlight .kr { color: #000000; font-weight: bold; } - -.highlight .kt { color: #445588; font-weight: bold; } - -.highlight .k, .highlight .kv { color: #000000; font-weight: bold; } - -.highlight .mf { color: #009999; } - -.highlight .mh { color: #009999; } - -.highlight .il { color: #009999; } - -.highlight .mi { color: #009999; } - -.highlight .mo { color: #009999; } - -.highlight .m, .highlight .mb, .highlight .mx { color: #009999; } - -.highlight .sb { color: #d14; } - -.highlight .sc { color: #d14; } - -.highlight .sd { color: #d14; } - -.highlight .s2 { color: #d14; } - -.highlight .se { color: #d14; } - -.highlight .sh { color: #d14; } - -.highlight .si { color: #d14; } - -.highlight .sx { color: #d14; } - -.highlight .sr { color: #009926; } - -.highlight .s1 { color: #d14; } - -.highlight .ss { color: #990073; } - -.highlight .s { color: #d14; } - -.highlight .na { color: #008080; } - -.highlight .bp { color: #999999; } - -.highlight .nb { color: #0086B3; } - -.highlight .nc { color: #445588; font-weight: bold; } - -.highlight .no { color: #008080; } - -.highlight .nd { color: #3c5d5d; font-weight: bold; } - -.highlight .ni { color: #800080; } - -.highlight .ne { color: #990000; font-weight: bold; } - -.highlight .nf { color: #990000; font-weight: bold; } - -.highlight .nl { color: #990000; font-weight: bold; } - -.highlight .nn { color: #555555; } - -.highlight .nt { color: #000080; } - -.highlight .vc { color: #008080; } - -.highlight .vg { color: #008080; } - -.highlight .vi { color: #008080; } - -.highlight .nv { color: #008080; } - -.highlight .ow { color: #000000; font-weight: bold; } - -.highlight .o { color: #000000; font-weight: bold; } - -.highlight .w { color: #bbbbbb; } - -.highlight { background-color: #f8f8f8; } - -body { background-color: #fff; padding: 50px; font: 14px/1.5 "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; color: #727272; font-weight: 400; } - -h1, h2, h3, h4, h5, h6 { color: #222; margin: 0 0 20px; } - -p, ul, ol, table, pre, dl { margin: 0 0 20px; } - -h1, h2, h3 { line-height: 1.1; } - -h1 { font-size: 28px; } - -h2 { color: #393939; } - -h3, h4, h5, h6 { color: #494949; } - -a { color: #267CB9; text-decoration: none; } - -a:hover, a:focus { color: #069; font-weight: bold; } - -a small { font-size: 11px; color: #777; margin-top: -0.3em; display: block; } - -a:hover small { color: #777; } - -.wrapper { width: 860px; margin: 0 auto; } - -blockquote { border-left: 1px solid #e5e5e5; margin: 0; padding: 0 0 0 20px; font-style: italic; } - -code, pre { font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal, Consolas, Liberation Mono, DejaVu Sans Mono, Courier New, monospace; color: #333; } - -pre { padding: 8px 15px; background: #f8f8f8; border-radius: 5px; border: 1px solid #e5e5e5; overflow-x: auto; } - -table { width: 100%; border-collapse: collapse; } - -th, td { text-align: left; padding: 5px 10px; border-bottom: 1px solid #e5e5e5; } - -dt { color: #444; font-weight: 700; } - -th { color: #444; } - -img { max-width: 100%; } - -header { width: 270px; float: left; position: fixed; -webkit-font-smoothing: subpixel-antialiased; } - -header ul { list-style: none; height: 40px; padding: 0; background: #f4f4f4; border-radius: 5px; border: 1px solid #e0e0e0; width: 270px; } - -header li { width: 89px; float: left; border-right: 1px solid #e0e0e0; height: 40px; } - -header li:first-child a { border-radius: 5px 0 0 5px; } - -header li:last-child a { border-radius: 0 5px 5px 0; } - -header ul a { line-height: 1; font-size: 11px; color: #676767; display: block; text-align: center; padding-top: 6px; height: 34px; } - -header ul a:hover, header ul a:focus { color: #675C5C; font-weight: bold; } - -header ul a:active { background-color: #f0f0f0; } - -strong { color: #222; font-weight: 700; } - -header ul li + li + li { border-right: none; width: 89px; } - -header ul a strong { font-size: 14px; display: block; color: #222; } - -section { width: 500px; float: right; padding-bottom: 50px; } - -small { font-size: 11px; } - -hr { border: 0; background: #e5e5e5; height: 1px; margin: 0 0 20px; } - -footer { width: 270px; float: left; position: fixed; bottom: 50px; -webkit-font-smoothing: subpixel-antialiased; } - -@media print, screen and (max-width: 960px) { div.wrapper { width: auto; margin: 0; } - header, section, footer { float: none; position: static; width: auto; } - header { padding-right: 320px; } - section { border: 1px solid #e5e5e5; border-width: 1px 0; padding: 20px 0; margin: 0 0 20px; } - header a small { display: inline; } - header ul { position: absolute; right: 50px; top: 52px; } } -@media print, screen and (max-width: 720px) { body { word-wrap: break-word; } - header { padding: 0; } - header ul, header p.view { position: static; } - pre, code { word-wrap: normal; } } -@media print, screen and (max-width: 480px) { body { padding: 15px; } - header ul { width: 99%; } - header li, header ul li + li + li { width: 33%; } } -@media print { body { padding: 0.4in; font-size: 12pt; color: #444; } } diff --git a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.eot b/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.eot deleted file mode 100755 index 03bf93fe..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.eot and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.svg b/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.svg deleted file mode 100755 index 925fe474..00000000 --- a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.svg +++ /dev/null @@ -1,336 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.ttf b/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.ttf deleted file mode 100755 index 4599e3ca..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.ttf and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff b/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff deleted file mode 100755 index 9d0b78df..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff2 b/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff2 deleted file mode 100755 index 55fc44bc..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-700/Noto-Sans-700.woff2 and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.eot b/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.eot deleted file mode 100755 index cb97b2b4..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.eot and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.svg b/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.svg deleted file mode 100755 index abdafc0f..00000000 --- a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.svg +++ /dev/null @@ -1,334 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.ttf b/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.ttf deleted file mode 100755 index 6640dbeb..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.ttf and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff b/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff deleted file mode 100755 index 209739ee..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff2 b/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff2 deleted file mode 100755 index f5525aa2..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-700italic/Noto-Sans-700italic.woff2 and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.eot b/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.eot deleted file mode 100755 index a9973499..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.eot and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.svg b/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.svg deleted file mode 100755 index dcd8fc89..00000000 --- a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.svg +++ /dev/null @@ -1,337 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.ttf b/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.ttf deleted file mode 100755 index 7f75a2d9..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.ttf and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff b/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff deleted file mode 100755 index 6dce67ce..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff2 b/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff2 deleted file mode 100755 index a9c14c49..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-italic/Noto-Sans-italic.woff2 and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.eot b/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.eot deleted file mode 100755 index 15fc8bfc..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.eot and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.svg b/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.svg deleted file mode 100755 index bd2894d6..00000000 --- a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.svg +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.ttf b/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.ttf deleted file mode 100755 index a83bbf9f..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.ttf and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff b/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff deleted file mode 100755 index 17c85006..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff and /dev/null differ diff --git a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff2 b/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff2 deleted file mode 100755 index a87d9cd7..00000000 Binary files a/docs/_site/assets/fonts/Noto-Sans-regular/Noto-Sans-regular.woff2 and /dev/null differ diff --git a/docs/_site/assets/img/logo.png b/docs/_site/assets/img/logo.png deleted file mode 100644 index 93e608e4..00000000 Binary files a/docs/_site/assets/img/logo.png and /dev/null differ diff --git a/docs/_site/assets/js/scale.fix.js b/docs/_site/assets/js/scale.fix.js deleted file mode 100644 index 911d33c3..00000000 --- a/docs/_site/assets/js/scale.fix.js +++ /dev/null @@ -1,27 +0,0 @@ -(function(document) { - var metas = document.getElementsByTagName('meta'), - changeViewportContent = function(content) { - for (var i = 0; i < metas.length; i++) { - if (metas[i].name == "viewport") { - metas[i].content = content; - } - } - }, - initialize = function() { - changeViewportContent("width=device-width, minimum-scale=1.0, maximum-scale=1.0"); - }, - gestureStart = function() { - changeViewportContent("width=device-width, minimum-scale=0.25, maximum-scale=1.6"); - }, - gestureEnd = function() { - initialize(); - }; - - - if (navigator.userAgent.match(/iPhone/i)) { - initialize(); - - document.addEventListener("touchstart", gestureStart, false); - document.addEventListener("touchend", gestureEnd, false); - } -})(document); diff --git a/docs/_site/index.html b/docs/_site/index.html deleted file mode 100644 index 1521bd87..00000000 --- a/docs/_site/index.html +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - - - - - - - - -Terraform Switcher | tfswitch - - - - - - - - - - - - - - - - - - - - -
-
- - - -

- Logo -

- -

A command line tool to switch between different versions of terraform (with homebrew and more)

- - Travis - Go Report - -
- - - - - - -Star -
-
- -

Terraform Switcher

- -

The tfswitch command line tool lets you switch between different versions of terraform. -If you do not have a particular version of terraform installed, tfswitch will download the version you desire. -The installation is minimal and easy. -Once installed, simply select the version you require from the dropdown and start using terraform.

- -
- -

Installation

- -

tfswitch is available for MacOS and Linux based operating systems.

- -

Homebrew

- -

Installation for MacOS is the easiest with Homebrew. If you do not have homebrew installed, click here.

- -
brew install warrensbox/tap/tfswitch
-
- -

Linux

- -

Installation for Linux operation systems.

- -
curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash
-
- -

Install from source

- -

Alternatively, you can install the binary from the source here

- -
- -

How to use:

-

Use dropdown menu to select version

-

drawing

- -
    -
  1. You can switch between different versions of terraform by typing the command tfswitch on your terminal.
  2. -
  3. Select the version of terraform you require by using the up and down arrow.
  4. -
  5. Hit Enter to select the desired version.
  6. -
- -

The most recently selected versions are presented at the top of the dropdown.

- -

Supply version on command line

-

drawing

- -
    -
  1. You can also supply the desired version as an argument on the command line.
  2. -
  3. For example, tfswitch 0.10.5 for version 0.10.5 of terraform.
  4. -
  5. Hit Enter to switch.
  6. -
- -

See all versions including beta, alpha and release candidates(rc)

-

drawing

- -
    -
  1. Display all versions including beta, alpha and release candidates(rc).
  2. -
  3. For example, tfswitch -l or tfswitch --list-all to see all versions.
  4. -
  5. Hit Enter to select the desired version.
  6. -
- -

Use version.tf file

-

If a .tf file with the terraform constrain is included in the current directory, it should automatically download or switch to that terraform version. For example, the following should automatically switch terraform to version 0.12.24:

-
terraform {
-  required_version = ">= 0.12.9"
-
-  required_providers {
-    aws        = ">= 2.52.0"
-    kubernetes = ">= 1.11.1"
-  }
-}
-
-

drawing

- -

Use .tfswitch.toml file (For non-admin - users with limited privilege on their computers)

-

This is similiar to using a .tfswitchrc file, but you can specify a custom binary path for your terraform installation

- -

drawing -drawing

- -
    -
  1. Create a custom binary path. Ex: mkdir /Users/warrenveerasingam/bin (replace warrenveerasingam with your username)
  2. -
  3. Add the path to your PATH. Ex: export PATH=$PATH:/Users/warrenveerasingam/bin (add this to your bash profile or zsh profile)
  4. -
  5. Pass -b or –bin parameter with your custom path to install terraform. Ex: tfswitch -b /Users/warrenveerasingam/bin/terraform 0.10.8
  6. -
  7. Optionally, you can create a .tfswitch.toml file in your terraform directory.
  8. -
  9. Your .tfswitch.toml file should look like this: -
    bin = "/Users/warrenveerasingam/bin/terraform"
    -version = "0.11.3"
    -
    -
  10. -
  11. Run tfswitch and it should automatically install the required terraform version in the specified binary path
  12. -
- -

Use .tfswitchrc file

-

drawing

- -
    -
  1. Create a .tfswitchrc file containing the desired version.
  2. -
  3. For example, echo "0.10.5" >> .tfswitchrc for version 0.10.5 of terraform.
  4. -
  5. Run the command tfswitch in the same directory as your .tfswitchrc.
  6. -
- -

Instead of a .tfswitchrc file, a .terraform-version file may be used for compatibility with tfenv and other tools which use it

- -

Automatically switch with bash

- -

Add the following to the end of your ~/.bashrc file: -(Use either .tfswitchrc or .tfswitch.toml or .terraform-version)

- -
cdtfswitch(){
-  builtin cd "$@";
-  cdir=$PWD;
-  if [ -e "$cdir/.tfswitchrc" ]; then
-    tfswitch
-  fi
-}
-alias cd='cdtfswitch'
-
- -

Automatically switch with zsh

- -

Add the following to the end of your ~/.zshrc file:

- -
load-tfswitch() {
-  local tfswitchrc_path=".tfswitchrc"
-
-  if [ -f "$tfswitchrc_path" ]; then
-    tfswitch
-  fi
-}
-add-zsh-hook chpwd load-tfswitch
-load-tfswitch
-
-
-

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:

-
   autoload -U add-zsh-hook
-
-
- -

older version of zsh

-
cd(){
-  builtin cd "$@";
-  cdir=$PWD;
-  if [ -e "$cdir/.tfswitchrc" ]; then
-    tfswitch
-  fi
-}
-
- -

Jenkins setup

-

drawing

- -
#!/bin/bash 
-
-echo "Installing tfswitch locally"
-wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh 
-chmod 755 install.sh
-./install.sh -b bin-directory
-
-./bin-directory/tfswitch
-
- -
- -

Issues

- -

Please open issues here: New Issue

- -
- -

See how to upgrade, uninstall, troubleshoot here: -Additional Info

- - -

This project is maintained by warrensbox

- -
- -
- - - - \ No newline at end of file diff --git a/docs/_site/index.md b/docs/_site/index.md deleted file mode 100644 index 87cffb16..00000000 --- a/docs/_site/index.md +++ /dev/null @@ -1,172 +0,0 @@ -# Terraform Switcher - -The `tfswitch` command line tool lets you switch between different versions of [terraform](https://www.terraform.io/){:target="_blank"}. -If you do not have a particular version of terraform installed, `tfswitch` will download the version you desire. -The installation is minimal and easy. -Once installed, simply select the version you require from the dropdown and start using terraform. - -
- -## Installation - -`tfswitch` is available for MacOS and Linux based operating systems. - -### Homebrew - -Installation for MacOS is the easiest with Homebrew. [If you do not have homebrew installed, click here](https://brew.sh/){:target="_blank"}. - - -```ruby -brew install warrensbox/tap/tfswitch -``` - -### Linux - -Installation for Linux operation systems. - -```sh -curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash -``` - -### Install from source - -Alternatively, you can install the binary from the source [here](https://github.com/warrensbox/terraform-switcher/releases) - -
- -## How to use: -### Use dropdown menu to select version -drawing - -1. You can switch between different versions of terraform by typing the command `tfswitch` on your terminal. -2. Select the version of terraform you require by using the up and down arrow. -3. Hit **Enter** to select the desired version. - -The most recently selected versions are presented at the top of the dropdown. - -### Supply version on command line -drawing - -1. You can also supply the desired version as an argument on the command line. -2. For example, `tfswitch 0.10.5` for version 0.10.5 of terraform. -3. Hit **Enter** to switch. - -### See all versions including beta, alpha and release candidates(rc) -drawing - -1. Display all versions including beta, alpha and release candidates(rc). -2. For example, `tfswitch -l` or `tfswitch --list-all` to see all versions. -3. Hit **Enter** to select the desired version. - -### Use version.tf file -If a .tf file with the terraform constrain is included in the current directory, it should automatically download or switch to that terraform version. For example, the following should automatically switch terraform to version `0.12.24`: -``` -terraform { - required_version = ">= 0.12.9" - - required_providers { - aws = ">= 2.52.0" - kubernetes = ">= 1.11.1" - } -} -``` -drawing - - -### Use .tfswitch.toml file (For non-admin - users with limited privilege on their computers) -This is similiar to using a .tfswitchrc file, but you can specify a custom binary path for your terraform installation - -drawing -drawing - -1. Create a custom binary path. Ex: `mkdir /Users/warrenveerasingam/bin` (replace warrenveerasingam with your username) -2. Add the path to your PATH. Ex: `export PATH=$PATH:/Users/warrenveerasingam/bin` (add this to your bash profile or zsh profile) -3. Pass -b or --bin parameter with your custom path to install terraform. Ex: `tfswitch -b /Users/warrenveerasingam/bin/terraform 0.10.8 ` -4. Optionally, you can create a `.tfswitch.toml` file in your terraform directory. -5. Your `.tfswitch.toml` file should look like this: -``` -bin = "/Users/warrenveerasingam/bin/terraform" -version = "0.11.3" -``` -4. Run `tfswitch` and it should automatically install the required terraform version in the specified binary path - -### Use .tfswitchrc file -drawing - -1. Create a `.tfswitchrc` file containing the desired version. -2. For example, `echo "0.10.5" >> .tfswitchrc` for version 0.10.5 of terraform. -3. Run the command `tfswitch` in the same directory as your `.tfswitchrc`. - -*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* - -**Automatically switch with bash** - -Add the following to the end of your `~/.bashrc` file: -(Use either `.tfswitchrc` or `.tfswitch.toml` or `.terraform-version`) - -``` -cdtfswitch(){ - builtin cd "$@"; - cdir=$PWD; - if [ -e "$cdir/.tfswitchrc" ]; then - tfswitch - fi -} -alias cd='cdtfswitch' -``` - -**Automatically switch with zsh** - -Add the following to the end of your `~/.zshrc` file: - -``` -load-tfswitch() { - local tfswitchrc_path=".tfswitchrc" - - if [ -f "$tfswitchrc_path" ]; then - tfswitch - fi -} -add-zsh-hook chpwd load-tfswitch -load-tfswitch -``` -> 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`: -> ``` -> autoload -U add-zsh-hook -> ``` - -*older version of zsh* -``` -cd(){ - builtin cd "$@"; - cdir=$PWD; - if [ -e "$cdir/.tfswitchrc" ]; then - tfswitch - fi -} -``` - -### Jenkins setup -drawing - -``` -#!/bin/bash - -echo "Installing tfswitch locally" -wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh -chmod 755 install.sh -./install.sh -b bin-directory - -./bin-directory/tfswitch -``` - -
- -## Issues - -Please open *issues* here: [New Issue](https://github.com/warrensbox/terraform-switcher/issues){:target="_blank"} - -
- -See how to *upgrade*, *uninstall*, *troubleshoot* here: -[Additional Info](additional) diff --git a/docs/additional.md b/docs/additional.md deleted file mode 100644 index 36174332..00000000 --- a/docs/additional.md +++ /dev/null @@ -1,51 +0,0 @@ - -[Back to main](index) - -## Upgrade: - -### Homebrew - -```ruby -brew upgrade warrensbox/tap/tfswitch -``` -### Linux - -Rerun: - -```sh -curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash -``` - -## Uninstall: - -### Homebrew - -```ruby -brew uninstall warrensbox/tap/tfswitch -``` -### Linux - -Rerun: - -```sh -rm /usr/local/bin/tfswitch -``` - -## Troubleshoot: - -Common issues: -```ruby -install: can't change permissions of /usr/local/bin: Operation not permitted -``` - -```ruby -"Unable to remove symlink. You must have SUDO privileges" -``` - -```ruby -"Unable to create symlink. You must have SUDO privileges" -``` -You probably need to have **sudo** privileges to install *tfswitch*. - -[Back to top](#upgrade) -[Back to main](index) \ No newline at end of file diff --git a/go.mod b/go.mod index 0709ef58..99932fc4 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/manifoldco/promptui v0.2.2-0.20180308161052-c0c0d3afc6a0 github.com/mattn/go-colorable v0.0.9 // indirect github.com/mattn/go-isatty v0.0.3 // indirect + github.com/mitchellh/go-homedir v1.1.0 github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30 github.com/pelletier/go-toml v1.4.0 // indirect github.com/spf13/afero v1.2.2 // indirect diff --git a/go.sum b/go.sum index 7d6fda6f..b7f5d836 100644 --- a/go.sum +++ b/go.sum @@ -98,6 +98,8 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= @@ -214,5 +216,6 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099 h1:XJP7lxbSxWLOMNdBE4B/STaqVy6L73o0knwj2vIlxnw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= diff --git a/main.go b/main.go index c8a63951..e12f487a 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,7 @@ package main /* * Version 0.6.0 -* Compatible with Mac OS X ONLY +* Compatible with Mac OS X AND other LINUX OS ONLY */ /*** OPERATION WORKFLOW ***/ @@ -25,11 +25,12 @@ import ( "sort" "strings" - "github.com/Masterminds/semver" - // original hashicorp upstream have broken dependencies, so using fork as workaround // TODO: move back to upstream + "github.com/Masterminds/semver" "github.com/kiranjthomas/terraform-config-inspect/tfconfig" + "github.com/mitchellh/go-homedir" + // "github.com/hashicorp/terraform-config-inspect/tfconfig" "github.com/manifoldco/promptui" @@ -47,7 +48,7 @@ const ( tomlFilename = ".tfswitch.toml" ) -var version = "0.8.0\n" +var version = "0.9.0\n" func main() { @@ -60,188 +61,204 @@ func main() { getopt.Parse() args := getopt.Args() - dir, err := os.Getwd() + dir, err := os.Getwd() //get current directory if err != nil { log.Printf("Failed to get current directory %v\n", err) os.Exit(1) } - tfvfile := dir + fmt.Sprintf("/%s", tfvFilename) //settings for .terraform-version file in current directory (tfenv compatible) - rcfile := dir + fmt.Sprintf("/%s", rcFilename) //settings for .tfswitchrc file in current directory (backward compatible purpose) - configfile := dir + fmt.Sprintf("/%s", tomlFilename) //settings for .tfswitch.toml file in current directory (option to specify bin directory) + homedir, errHome := homedir.Dir() + if errHome != nil { + log.Printf("Failed to get home directory %v\n", errHome) + os.Exit(1) + } - if *versionFlag { + curr_tfvfile := dir + fmt.Sprintf("/%s", tfvFilename) //settings for .terraform-version file in current directory (tfenv compatible) + curr_rcfile := dir + fmt.Sprintf("/%s", rcFilename) //settings for .tfswitchrc file in current directory (backward compatible purpose) + curr_tomlconfigfile := dir + fmt.Sprintf("/%s", tomlFilename) //settings for .tfswitch.toml file in current directory (option to specify bin directory) + home_tomlconfigfile := homedir + fmt.Sprintf("/%s", tomlFilename) //settings for .tfswitch.toml file in home directory (option to specify bin directory) + + switch { + case *versionFlag: + //if *versionFlag { fmt.Printf("\nVersion: %v\n", version) - } else if *helpFlag { + case *helpFlag: + //} else if *helpFlag { usageMessage() - } else { - /* This block checks to see if the tfswitch toml file is provided in the current path. - * If the .tfswitch.toml file exist, it has a higher precedence than the .tfswitchrc file - * You can specify the custom binary path and the version you desire - * If you provide a custom binary path with the -b option, this will override the bin value in the toml file - * If you provide a version on the command line, this will override the version value in the toml file - */ - if _, err := os.Stat(configfile); err == nil { - fmt.Printf("Reading configuration from %s\n", tomlFilename) - tfversion := "" - binPath := *custBinPath //takes the default bin (defaultBin) if user does not specify bin path - configfileName := lib.GetFileName(tomlFilename) //get the config file - viper.SetConfigType("toml") - viper.SetConfigName(configfileName) - viper.AddConfigPath(dir) - - errs := viper.ReadInConfig() // Find and read the config file - if errs != nil { - fmt.Printf("Unable to read %s provided\n", tomlFilename) // Handle errors reading the config file - fmt.Println(err) - os.Exit(1) // exit immediately if config file provided but it is unable to read it - } - - bin := viper.Get("bin") // read custom binary location - if binPath == defaultBin && bin != nil { // if the bin path is the same as the default binary path and if the custom binary is provided in the toml file (use it) - binPath = os.ExpandEnv(bin.(string)) - } - version := viper.Get("version") //attempt to get the version if it's provided in the toml - - if len(args) == 1 { //if the version is passed in the command line - requestedVersion := args[0] - listAll := true //set list all true - all versions including beta and rc will be displayed - tflist, _ := lib.GetTFList(hashiURL, listAll) //get list of versions - exist := lib.VersionExist(requestedVersion, tflist) //check if version exist before downloading it - - if exist { - tfversion = requestedVersion // set tfversion = the version needed - } - } else if version != nil { // if the required version in the toml file is provided (use it) - tfversion = version.(string) - } - - if *listAllFlag { //show all terraform version including betas and RCs - listAll := true //set list all true - all versions including beta and rc will be displayed - installOption(listAll, &binPath) - } else if tfversion == "" { // if no version is provided, show a dropdown of available release versions - listAll := false //set list all false - only official release will be displayed - installOption(listAll, &binPath) - } else { - if lib.ValidVersionFormat(tfversion) { //check if version is correct - lib.Install(tfversion, binPath) - } else { - fmt.Println("Invalid terraform version format. Format should be #.#.# or #.#.#-@# where # is numbers and @ is word characters. For example, 0.11.7 and 0.11.9-beta1 are valid versions") - os.Exit(1) - } - } - } else if module, _ := tfconfig.LoadModule(dir); len(module.RequiredCore) >= 1 && len(args) == 0 { //if there is a version.tf file, and no commmand line arguments - - tfversion := "" - tfconstraint := module.RequiredCore[0] //we skip duplicated definitions and use only first one - listAll := true //set list all true - all versions including beta and rc will be displayed - tflist, _ := lib.GetTFList(hashiURL, listAll) //get list of versions - fmt.Printf("Reading required version from terraform file, constraint: %s\n", tfconstraint) - - constrains, err := semver.NewConstraint(tfconstraint) //NewConstraint returns a Constraints instance that a Version instance can be checked against - if err != nil { - fmt.Printf("Error parsing constraint: %s\nPlease check constrain syntax on terraform file.\n", err) - fmt.Println() - os.Exit(1) - } - versions := make([]*semver.Version, len(tflist)) - for i, tfvals := range tflist { - version, err := semver.NewVersion(tfvals) //NewVersion parses a given version and returns an instance of Version or an error if unable to parse the version. - if err != nil { - fmt.Printf("Error parsing version: %s", err) - os.Exit(1) - } - - versions[i] = version - } - - sort.Sort(sort.Reverse(semver.Collection(versions))) - - for _, element := range versions { + /* Checks if the .tfswitch.toml file exist in home or current directory + * This block checks to see if the tfswitch toml file is provided in the current path. + * If the .tfswitch.toml file exist, it has a higher precedence than the .tfswitchrc file + * You can specify the custom binary path and the version you desire + * If you provide a custom binary path with the -b option, this will override the bin value in the toml file + * If you provide a version on the command line, this will override the version value in the toml file + */ + case fileExists(curr_tomlconfigfile) || fileExists(home_tomlconfigfile): + + version := "" + binPath := *custBinPath + if fileExists(curr_tomlconfigfile) { //read from toml from current directory + version, binPath = getParamsTOML(binPath, dir) + } else { // else read from toml from home directory + version, binPath = getParamsTOML(binPath, homedir) + } - if constrains.Check(element) { // Validate a version against a constraint - tfversion = element.String() + switch { + case checkTFModuleFileExist(dir): + installTFProvidedModule(dir, &binPath) + case len(args) == 1: + installVersion(args[0], &binPath) + case *listAllFlag: + listAll := true //set list all true - all versions including beta and rc will be displayed + installOption(listAll, &binPath) + case fileExists(curr_rcfile): + readingFileMsg(rcFilename) + tfversion := retrieveFileContents(curr_rcfile) + installVersion(tfversion, &binPath) + case fileExists(curr_tfvfile): + readingFileMsg(tfvFilename) + tfversion := retrieveFileContents(curr_tfvfile) + installVersion(tfversion, &binPath) + case version != "": + installVersion(version, &binPath) + default: + listAll := false //set list all false - only official release will be displayed + installOption(listAll, &binPath) + } - fmt.Printf("Matched version: %s\n", tfversion) - if lib.ValidVersionFormat(tfversion) { //check if version format is correct - lib.Install(tfversion, *custBinPath) - } else { - fmt.Println("Invalid terraform version format. Format should be #.#.# or #.#.#-@# where # is numbers and @ is word characters. For example, 0.11.7 and 0.11.9-beta1 are valid versions") - os.Exit(1) - } - } - } + /* list all versions, //show all terraform version including betas and RCs*/ + case *listAllFlag: + installWithListAll(custBinPath) + + /* version provided on command line as arg */ + case len(args) == 1: + installVersion(args[0], custBinPath) + + /* provide an tfswitchrc file */ + case fileExists(curr_rcfile) && len(args) == 0: + readingFileMsg(rcFilename) + tfversion := retrieveFileContents(curr_rcfile) + installVersion(tfversion, custBinPath) + + /* if .terraform-version file found */ + case fileExists(curr_tfvfile) && len(args) == 0: + readingFileMsg(tfvFilename) + tfversion := retrieveFileContents(curr_tfvfile) + installVersion(tfversion, custBinPath) + + /* if versions.tf file found */ + case checkTFModuleFileExist(dir) && len(args) == 0: + installTFProvidedModule(dir, custBinPath) + + // if no arg is provided + default: + listAll := false //set list all false - only official release will be displayed + installOption(listAll, custBinPath) + } +} - fmt.Println("No version found to match constraint. Follow the README.md instructions for setup. https://github.com/warrensbox/terraform-switcher/blob/master/README.md") - os.Exit(1) +/* Helper functions */ - } else if _, err := os.Stat(rcfile); err == nil && len(args) == 0 { //if there is a .tfswitchrc file, and no commmand line arguments - fmt.Printf("Reading required terraform version %s \n", rcFilename) +// install with all possible versions, including beta and rc +func installWithListAll(custBinPath *string) { + listAll := true //set list all true - all versions including beta and rc will be displayed + installOption(listAll, custBinPath) +} - fileContents, err := ioutil.ReadFile(rcfile) - if err != nil { - fmt.Printf("Failed to read %s file. Follow the README.md instructions for setup. https://github.com/warrensbox/terraform-switcher/blob/master/README.md\n", rcFilename) - fmt.Printf("Error: %s\n", err) - os.Exit(1) - } - tfversion := strings.TrimSuffix(string(fileContents), "\n") +// install with provided version as argument +func installVersion(arg string, custBinPath *string) { + if lib.ValidVersionFormat(arg) { + requestedVersion := arg + listAll := true //set list all true - all versions including beta and rc will be displayed + tflist, _ := lib.GetTFList(hashiURL, listAll) //get list of versions + exist := lib.VersionExist(requestedVersion, tflist) //check if version exist before downloading it - if lib.ValidVersionFormat(tfversion) { //check if version is correct - lib.Install(string(tfversion), *custBinPath) - } else { - fmt.Println("Invalid terraform version format. Format should be #.#.# or #.#.#-@# where # is numbers and @ is word characters. For example, 0.11.7 and 0.11.9-beta1 are valid versions") - os.Exit(1) - } - } else if _, err := os.Stat(tfvfile); err == nil && len(args) == 0 { //if there is a .terraform-version file, and no command line arguments - fmt.Printf("Reading required terraform version %s \n", tfvFilename) + if exist { + lib.Install(requestedVersion, *custBinPath) + } else { + fmt.Println("The provided terraform version does not exist. Try `tfswitch -l` to see all available versions.") + } - fileContents, err := ioutil.ReadFile(tfvfile) - if err != nil { - fmt.Printf("Failed to read %s file. Follow the README.md instructions for setup. https://github.com/warrensbox/terraform-switcher/blob/master/README.md\n", tfvFilename) - fmt.Printf("Error: %s\n", err) - os.Exit(1) - } - tfversion := strings.TrimSuffix(string(fileContents), "\n") + } else { + printInvalidTFVersion() + fmt.Println("Args must be a valid terraform version") + usageMessage() + } +} - if lib.ValidVersionFormat(tfversion) { //check if version is correct - lib.Install(string(tfversion), *custBinPath) - } else { - fmt.Println("Invalid terraform version format. Format should be #.#.# or #.#.#-@# where # is numbers and @ is word characters. For example, 0.11.7 and 0.11.9-beta1 are valid versions") - os.Exit(1) - } - } else if len(args) == 1 { //if tf version is provided in command line - if lib.ValidVersionFormat(args[0]) { +// Print invalid TF version +func printInvalidTFVersion() { + fmt.Println("Invalid terraform version format. Format should be #.#.# or #.#.#-@# where # is numbers and @ is word characters. For example, 0.11.7 and 0.11.9-beta1 are valid versions") +} - requestedVersion := args[0] - listAll := true //set list all true - all versions including beta and rc will be displayed - tflist, _ := lib.GetTFList(hashiURL, listAll) //get list of versions - exist := lib.VersionExist(requestedVersion, tflist) //check if version exist before downloading it +//retrive file content of regular file +func retrieveFileContents(file string) string { + fileContents, err := ioutil.ReadFile(file) + if err != nil { + fmt.Printf("Failed to read %s file. Follow the README.md instructions for setup. https://github.com/warrensbox/terraform-switcher/blob/master/README.md\n", tfvFilename) + fmt.Printf("Error: %s\n", err) + os.Exit(1) + } + tfversion := strings.TrimSuffix(string(fileContents), "\n") + return tfversion +} - if exist { - lib.Install(requestedVersion, *custBinPath) - } else { - fmt.Println("The provided terraform version does not exist. Try `tfswitch -l` to see all available versions.") - } +// Print message reading file content of : +func readingFileMsg(filename string) { + fmt.Printf("Reading file %s \n", filename) +} - } else { - fmt.Println("Invalid terraform version format. Format should be #.#.# or #.#.#-@# where # is numbers and @ is word characters. For example, 0.11.7 and 0.11.9-beta1 are valid versions") - fmt.Println("Args must be a valid terraform version") - usageMessage() - } +// fileExists checks if a file exists and is not a directory before we try using it to prevent further errors. +func fileExists(filename string) bool { + info, err := os.Stat(filename) + if os.IsNotExist(err) { + return false + } + return !info.IsDir() +} - } else if *listAllFlag { - listAll := true //set list all true - all versions including beta and rc will be displayed - installOption(listAll, custBinPath) +// fileExists checks if a file exists and is not a directory before we +// try using it to prevent further errors. +func checkTFModuleFileExist(dir string) bool { - } else if len(args) == 0 { //if there are no commmand line arguments + module, _ := tfconfig.LoadModule(dir) + if len(module.RequiredCore) >= 1 { + return true + } + return false +} - listAll := false //set list all false - only official release will be displayed - installOption(listAll, custBinPath) +/* parses everything in the toml file, return required version and bin path */ +func getParamsTOML(binPath string, dir string) (string, string) { + path, _ := homedir.Dir() + if dir == path { + path = "home directory" + } else { + path = "current directory" + } + fmt.Printf("Reading configuration from %s\n", path+" for "+tomlFilename) //takes the default bin (defaultBin) if user does not specify bin path + configfileName := lib.GetFileName(tomlFilename) //get the config file + viper.SetConfigType("toml") + viper.SetConfigName(configfileName) + viper.AddConfigPath(dir) + + errs := viper.ReadInConfig() // Find and read the config file + if errs != nil { + fmt.Printf("Unable to read %s provided\n", tomlFilename) // Handle errors reading the config file + fmt.Println(errs) + os.Exit(1) // exit immediately if config file provided but it is unable to read it + } - } else { - usageMessage() - } + bin := viper.Get("bin") // read custom binary location + if binPath == defaultBin && bin != nil { // if the bin path is the same as the default binary path and if the custom binary is provided in the toml file (use it) + binPath = os.ExpandEnv(bin.(string)) } + //fmt.Println(binPath) //uncomment this to debug + version := viper.Get("version") //attempt to get the version if it's provided in the toml + if version == nil { + version = "" + } + + return version.(string), binPath } func usageMessage() { @@ -277,3 +294,48 @@ func installOption(listAll bool, custBinPath *string) { lib.Install(tfversion, *custBinPath) os.Exit(0) } + +// installation when +func installTFProvidedModule(dir string, custBinPath *string) { + tfversion := "" + module, _ := tfconfig.LoadModule(dir) + tfconstraint := module.RequiredCore[0] //we skip duplicated definitions and use only first one + listAll := true //set list all true - all versions including beta and rc will be displayed + tflist, _ := lib.GetTFList(hashiURL, listAll) //get list of versions + fmt.Printf("Reading required version from terraform file, constraint: %s\n", tfconstraint) + + constrains, err := semver.NewConstraint(tfconstraint) //NewConstraint returns a Constraints instance that a Version instance can be checked against + if err != nil { + fmt.Printf("Error parsing constraint: %s\nPlease check constrain syntax on terraform file.\n", err) + fmt.Println() + os.Exit(1) + } + versions := make([]*semver.Version, len(tflist)) + for i, tfvals := range tflist { + version, err := semver.NewVersion(tfvals) //NewVersion parses a given version and returns an instance of Version or an error if unable to parse the version. + if err != nil { + fmt.Printf("Error parsing version: %s", err) + os.Exit(1) + } + + versions[i] = version + } + + sort.Sort(sort.Reverse(semver.Collection(versions))) + + for _, element := range versions { + if constrains.Check(element) { // Validate a version against a constraint + tfversion = element.String() + fmt.Printf("Matched version: %s\n", tfversion) + if lib.ValidVersionFormat(tfversion) { //check if version format is correct + lib.Install(tfversion, *custBinPath) + } else { + printInvalidTFVersion() + os.Exit(1) + } + } + } + + fmt.Println("No version found to match constraint. Follow the README.md instructions for setup. https://github.com/warrensbox/terraform-switcher/blob/master/README.md") + os.Exit(1) +} diff --git a/snapcraft.yaml b/snapcraft.yaml new file mode 100644 index 00000000..024ee486 --- /dev/null +++ b/snapcraft.yaml @@ -0,0 +1,35 @@ +name: tfswitch +version: git +summary: A command line tool to switch between different versions of terraform +description: | + The `tfswitch` command line tool lets you switch between different versions of terraform(https://www.terraform.io/). + If you do not have a particular version of terraform installed, `tfswitch` will download the version you desire. + The installation is minimal and easy. + Once installed, simply select the version you require from the dropdown and start using terraform. +architectures: + - build-on: arm64 +assumes: [snapd2.45] +base: core18 + +grade: stable +confinement: strict + +apps: + tfswitch: + command: bin/tfswitch + plugs: + - home + - network + - network-bind + +parts: + tfswitch: + source: . + plugin: go + go-importpath: github.com/warrensbox/terraform-switcher + build-packages: + - gcc-multilib + go-buildtags: + - tfswitch + override-build: + go build -o ../install/bin/tfswitch \ No newline at end of file diff --git a/test-data/test_terraform-version/.terraform-version b/test-data/test_terraform-version/.terraform-version new file mode 100644 index 00000000..d9df1bbc --- /dev/null +++ b/test-data/test_terraform-version/.terraform-version @@ -0,0 +1 @@ +0.11.0 diff --git a/test-data/test_tfswitchrc/.tfswitchrc b/test-data/test_tfswitchrc/.tfswitchrc new file mode 100644 index 00000000..9028ec63 --- /dev/null +++ b/test-data/test_tfswitchrc/.tfswitchrc @@ -0,0 +1 @@ +0.10.5 diff --git a/test-data/test_tfswitchtoml/.tfswitch.toml b/test-data/test_tfswitchtoml/.tfswitch.toml new file mode 100644 index 00000000..63df82e7 --- /dev/null +++ b/test-data/test_tfswitchtoml/.tfswitch.toml @@ -0,0 +1,2 @@ +bin = "/Users/uveerum/bin/terraform" +version = "0.11.3" diff --git a/test-data/test_versiontf/version.tf b/test-data/test_versiontf/version.tf new file mode 100644 index 00000000..998dc471 --- /dev/null +++ b/test-data/test_versiontf/version.tf @@ -0,0 +1,8 @@ +terraform { + required_version = ">= 0.12.9" + + required_providers { + aws = ">= 2.52.0" + kubernetes = ">= 1.11.1" + } +} \ No newline at end of file diff --git a/version b/version index 524a135d..512833fc 100644 --- a/version +++ b/version @@ -1 +1 @@ -RELEASE_VERSION=0.8 \ No newline at end of file +RELEASE_VERSION=0.9 \ No newline at end of file diff --git a/www/docs/CNAME b/www/docs/CNAME new file mode 100644 index 00000000..7f85881a --- /dev/null +++ b/www/docs/CNAME @@ -0,0 +1 @@ +tfswitch.warrensbox.com \ No newline at end of file diff --git a/www/docs/Continuous-Integration.md b/www/docs/Continuous-Integration.md new file mode 100644 index 00000000..62a4939e --- /dev/null +++ b/www/docs/Continuous-Integration.md @@ -0,0 +1,62 @@ +### Jenkins setup +drawing + +```sh +#!/bin/bash + +echo "Installing tfswitch locally" +wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh #Get the installer on to your machine + +chmod 755 install.sh #Make installer executable + +./install.sh -b `pwd`/.bin #Install tfswitch in a location you have permission + +CUSTOMBIN=`pwd`/.bin #set custom bin path + +export PATH=$PATH:$CUSTOMBIN #Add custom bin path to PATH environment + +$CUSTOMBIN/tfswitch -b $CUSTOMBIN/terraform 0.11.7 #or simply tfswitch -b $CUSTOMBIN/terraform 0.11.7 + +terraform -v #testing version +``` + +### Circle CI setup + +drawing + + +Example config yaml +```yaml +version: 2 +jobs: + build: + docker: + - image: ubuntu + + working_directory: /go/src/github.com/warrensbox/terraform-switcher + + steps: + - checkout + - run: + command: | + set +e + apt-get update + apt-get install -y wget + rm -rf /var/lib/apt/lists/* + + echo "Installing tfswitch locally" + + wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh #Get the installer on to your machine + + chmod 755 install.sh #Make installer executable + + ./install.sh -b `pwd`/.bin #Install tfswitch in a location you have permission + + CUSTOMBIN=`pwd`/.bin #set custom bin path + + export PATH=$PATH:$CUSTOMBIN #Add custom bin path to PATH environment + + $CUSTOMBIN/tfswitch -b $CUSTOMBIN/terraform 0.11.7 #or simply tfswitch -b $CUSTOMBIN/terraform 0.11.7 + + terraform -v #testing version +``` \ No newline at end of file diff --git a/www/docs/How-to-Contribute.md b/www/docs/How-to-Contribute.md new file mode 100644 index 00000000..9c1cc5a6 --- /dev/null +++ b/www/docs/How-to-Contribute.md @@ -0,0 +1,80 @@ +## Step by step instructions + +An open source project becomes meaningful when people collaborate to improve the code. + +Feel free to look at the code, critique and make suggestions. Lets make `tfswitch` better! + +## Required version +```sh +go version 1.13 +``` + +### Step 1 - Create workspace +*Skip this step if you already have a github go workspace* +Create a github workspace. +drawing + +### Step 2 - Set GOPATH +*Skip this step if you already have a github go workspace* +Export your GOPATH environment variable in your `go` directory. +```sh +export GOPATH=`pwd` +``` +drawing + +### Step 3 - Clone repository +Git clone this repository. +```sh +git clone git@github.com:warrensbox/terraform-switcher.git +``` +drawing + +### Step 4 - Get dependencies +Go get all the dependencies. + +```sh +go mod download +``` +```sh +go get -v -t -d ./... +``` +Test the code (optional). +```sh +go vet -tests=false ./... +``` +```sh +go test -v ./... +``` +drawing + +### Step 5 - Build executable +Create a new branch. +```sh +git checkout -b feature/put-your-branch-name-here +``` +Refactor and add new features to the code. +Go build the code. +```sh +go build -o test-tfswitch +``` +Test the code and create a new pull request! + +drawing + +### Contributors + +drawing drawing drawing drawing drawing drawing drawing drawing drawing drawingdrawing + + + + + + + + + + + + + diff --git a/www/docs/Install.md b/www/docs/Install.md new file mode 100644 index 00000000..c9f6bb08 --- /dev/null +++ b/www/docs/Install.md @@ -0,0 +1,33 @@ +## Installation + +`tfswitch` is available for MacOS and Linux based operating systems. + +### Homebrew + +Installation for MacOS is the easiest with Homebrew. If you do not have homebrew installed, click here. + +```ruby +brew install warrensbox/tap/tfswitch +``` + +### Linux + +Installation for Linux operation systems. + +```sh +curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash +``` + +### Snapcraft for CentOS, Ubuntu, Linux Mint, RHEL, Debian, Fedora + +```sh +sudo snap install tfswitch +``` + +### Install from source + +Alternatively, you can install the binary from the source here. + +[Having trouble installing](https://tfswitch.warrensbox.com/Troubleshoot/). + + diff --git a/docs/index.md b/www/docs/Quick-Start.md similarity index 60% rename from docs/index.md rename to www/docs/Quick-Start.md index 87cffb16..3669fd00 100644 --- a/docs/index.md +++ b/www/docs/Quick-Start.md @@ -1,65 +1,30 @@ -# Terraform Switcher - -The `tfswitch` command line tool lets you switch between different versions of [terraform](https://www.terraform.io/){:target="_blank"}. -If you do not have a particular version of terraform installed, `tfswitch` will download the version you desire. -The installation is minimal and easy. -Once installed, simply select the version you require from the dropdown and start using terraform. - -
- -## Installation - -`tfswitch` is available for MacOS and Linux based operating systems. - -### Homebrew - -Installation for MacOS is the easiest with Homebrew. [If you do not have homebrew installed, click here](https://brew.sh/){:target="_blank"}. - - -```ruby -brew install warrensbox/tap/tfswitch -``` - -### Linux - -Installation for Linux operation systems. - -```sh -curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash -``` - -### Install from source - -Alternatively, you can install the binary from the source [here](https://github.com/warrensbox/terraform-switcher/releases) - -
## How to use: ### Use dropdown menu to select version -drawing +drawing -1. You can switch between different versions of terraform by typing the command `tfswitch` on your terminal. +1. You can switch between different versions of terraform by typing the command `tfswitch` on your terminal. 2. Select the version of terraform you require by using the up and down arrow. 3. Hit **Enter** to select the desired version. The most recently selected versions are presented at the top of the dropdown. ### Supply version on command line -drawing +drawing 1. You can also supply the desired version as an argument on the command line. 2. For example, `tfswitch 0.10.5` for version 0.10.5 of terraform. 3. Hit **Enter** to switch. ### See all versions including beta, alpha and release candidates(rc) -drawing +drawing 1. Display all versions including beta, alpha and release candidates(rc). 2. For example, `tfswitch -l` or `tfswitch --list-all` to see all versions. 3. Hit **Enter** to select the desired version. ### Use version.tf file -If a .tf file with the terraform constrain is included in the current directory, it should automatically download or switch to that terraform version. For example, the following should automatically switch terraform to version `0.12.24`: +If a .tf file with the terraform constrain is included in the current directory, it should automatically download or switch to that terraform version. For example, the following should automatically switch terraform to the lastest version: ``` terraform { required_version = ">= 0.12.9" @@ -70,41 +35,40 @@ terraform { } } ``` -drawing - +drawing ### Use .tfswitch.toml file (For non-admin - users with limited privilege on their computers) This is similiar to using a .tfswitchrc file, but you can specify a custom binary path for your terraform installation -drawing -drawing +drawing +drawing 1. Create a custom binary path. Ex: `mkdir /Users/warrenveerasingam/bin` (replace warrenveerasingam with your username) 2. Add the path to your PATH. Ex: `export PATH=$PATH:/Users/warrenveerasingam/bin` (add this to your bash profile or zsh profile) 3. Pass -b or --bin parameter with your custom path to install terraform. Ex: `tfswitch -b /Users/warrenveerasingam/bin/terraform 0.10.8 ` -4. Optionally, you can create a `.tfswitch.toml` file in your terraform directory. +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 5. Your `.tfswitch.toml` file should look like this: -``` +```ruby bin = "/Users/warrenveerasingam/bin/terraform" version = "0.11.3" ``` 4. Run `tfswitch` and it should automatically install the required terraform version in the specified binary path ### Use .tfswitchrc file -drawing +drawing -1. Create a `.tfswitchrc` file containing the desired version. -2. For example, `echo "0.10.5" >> .tfswitchrc` for version 0.10.5 of terraform. -3. Run the command `tfswitch` in the same directory as your `.tfswitchrc`. +1. Create a `.tfswitchrc` file containing the desired version +2. For example, `echo "0.10.5" >> .tfswitchrc` for version 0.10.5 of terraform +3. Run the command `tfswitch` in the same directory as your `.tfswitchrc` *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* **Automatically switch with bash** -Add the following to the end of your `~/.bashrc` file: +Add the following to the end of your `~/.bashrc` file: (Use either `.tfswitchrc` or `.tfswitch.toml` or `.terraform-version`) -``` +```sh cdtfswitch(){ builtin cd "$@"; cdir=$PWD; @@ -119,7 +83,7 @@ alias cd='cdtfswitch' Add the following to the end of your `~/.zshrc` file: -``` +```sh load-tfswitch() { local tfswitchrc_path=".tfswitchrc" @@ -136,7 +100,7 @@ load-tfswitch > ``` *older version of zsh* -``` +```sh cd(){ builtin cd "$@"; cdir=$PWD; @@ -145,28 +109,25 @@ cd(){ fi } ``` +**Automatically switch with fish shell** -### Jenkins setup -drawing +Add the following to the end of your `~/.config/fish/config.fish` file: +```sh +function switch_terraform --on-event fish_postexec + string match --regex '^cd\s' "$argv" > /dev/null + set --local is_command_cd $status + + if test $is_command_cd -eq 0 + if count *.tf > /dev/null + + grep -c "required_version" *.tf > /dev/null + set --local tf_contains_version $status + + if test $tf_contains_version -eq 0 + command tfswitch + end + end + end +end ``` -#!/bin/bash - -echo "Installing tfswitch locally" -wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh -chmod 755 install.sh -./install.sh -b bin-directory - -./bin-directory/tfswitch -``` - -
- -## Issues - -Please open *issues* here: [New Issue](https://github.com/warrensbox/terraform-switcher/issues){:target="_blank"} - -
- -See how to *upgrade*, *uninstall*, *troubleshoot* here: -[Additional Info](additional) diff --git a/www/docs/Troubleshoot.md b/www/docs/Troubleshoot.md new file mode 100644 index 00000000..b646068d --- /dev/null +++ b/www/docs/Troubleshoot.md @@ -0,0 +1,48 @@ + +Problem: +```sh +install: can't change permissions of /usr/local/bin: Operation not permitted +``` + +```sh +"Unable to remove symlink. You must have SUDO privileges" +``` + +```sh +"Unable to create symlink. You must have SUDO privileges" +``` + +```sh +install: cannot create regular file '/usr/local/bin/tfswitch': Permission denied +``` + +Solution: You probably need to have privileges to install *tfswitch* at /usr/local/bin. + +Try the following: + +```sh +wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh #Get the installer on to your machine: + +chmod 755 install.sh #Make installer executable + +./install.sh -b $HOME/.bin #Install tfswitch in a location you have permission: + +$HOME/.bin/tfswitch #test + +export PATH=$PATH:$HOME/.bin #Export your .bin into your path + +#You should probably add step 4 in your `.bash_profile` in your $HOME directory. + +#Next, try: +`tfswitch -b $HOME/.bin/terraform 0.11.7` + +#or simply + +`tfswitch -b $HOME/.bin/terraform` + + +``` + +See the custom directory option `-b`: +drawing + diff --git a/www/docs/Upgrade-or-Uninstall.md b/www/docs/Upgrade-or-Uninstall.md new file mode 100644 index 00000000..10dc0088 --- /dev/null +++ b/www/docs/Upgrade-or-Uninstall.md @@ -0,0 +1,29 @@ +## Upgrade: + +### Homebrew + +```ruby +brew upgrade warrensbox/tap/tfswitch +``` +### Linux + +Rerun: + +```sh +curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash +``` + +## Uninstall: + +### Homebrew + +```ruby +brew uninstall warrensbox/tap/tfswitch +``` +### Linux + +Run: + +```sh +rm /usr/local/bin/tfswitch +``` \ No newline at end of file diff --git a/www/docs/index.md b/www/docs/index.md new file mode 100644 index 00000000..646bcb7c --- /dev/null +++ b/www/docs/index.md @@ -0,0 +1,9 @@ +# Introduction to tfswitch + +drawing + +The `tfswitch` command line tool lets you switch between different versions of terraform. +If you do not have a particular version of terraform installed, `tfswitch` lets you download the version you desire. +The installation is minimal and easy. +Once installed, simply select the version you require from the dropdown and start using terraform. + diff --git a/www/docs/static/favicon_tfswitch_16.png b/www/docs/static/favicon_tfswitch_16.png new file mode 100644 index 00000000..7951adc4 Binary files /dev/null and b/www/docs/static/favicon_tfswitch_16.png differ diff --git a/www/docs/static/favicon_tfswitch_48.png b/www/docs/static/favicon_tfswitch_48.png new file mode 100644 index 00000000..8d5fb3bf Binary files /dev/null and b/www/docs/static/favicon_tfswitch_48.png differ diff --git a/www/docs/static/logo.png b/www/docs/static/logo.png new file mode 100644 index 00000000..835e0748 Binary files /dev/null and b/www/docs/static/logo.png differ diff --git a/www/mkdocs.yml b/www/mkdocs.yml new file mode 100644 index 00000000..d611190f --- /dev/null +++ b/www/mkdocs.yml @@ -0,0 +1,27 @@ +site_name: TFSwitch +site_description: A command line tool to switch between different versions of terraform (install with homebrew and more) +copyright: This project is maintained by warrensbox +repo_name: warrensbox/terraform-switcher +repo_url: https://github.com/warrensbox/terraform-switcher +site_url: https://tfswitch.warrensbox.com + +theme: + name: material + palette: + primary: indigo + favicon: static/favicon_tfswitch_16.png + logo: static/logo.png + +nav: + - index.md + - Install.md + - Quick-Start.md + - Continuous-Integration.md + - Upgrade-or-Uninstall.md + - How-to-Contribute.md + - Troubleshoot.md + +google_analytics: + - UA-120055973-1 + - auto + \ No newline at end of file