Skip to content

Commit

Permalink
Merge pull request #68 from warrensbox/master
Browse files Browse the repository at this point in the history
Release Changes
  • Loading branch information
warrensbox authored Mar 5, 2020
2 parents 6789a3f + d747848 commit ba54688
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 239 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ test: $(EXE)
.PHONEY: dep
dep:
dep ensure

.PHONY: docs
docs:
cd docs; bundle install --path vendor/bundler; bundle exec jekyll build -c _config.yml; cd ..

69 changes: 20 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ The most recently selected versions are presented at the top of the dropdown.
3. Hit **Enter** to select the desired version.


### Use .tfswitch.toml file (For uprivilege users/ non-admin - users with limited privilege on their computer)
### 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

<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/tfswitch-v7.gif" alt="drawing" style="width: 170px;"/>
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/tfswitch-v8.gif" alt="drawing" style="width: 170px;"/>

1. Create a custom binary path. Ex: `mkdir /Users/warrenveerasingam/bin` (replace warrenveerasingam with your username)
Expand All @@ -81,64 +82,20 @@ version = "0.11.3"
```
4. Run `tfswitch` and it should automatically install the required terraform version in the specified binary path

<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/tfswitch-v7.gif" alt="drawing" style="width: 170px;"/>

**Automatically switch with bash**

Add the following to the end of your `~/.bashrc` file:
```
cdtfswitch(){
builtin cd "$@";
cdir=$PWD;
if [ -f "$cdir/.tfswitch.toml" ]; 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=".tfswitch.toml"
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 [ -f "$cdir/.tfswitchrc" ]; then
tfswitch
fi
}
```

### Use .tfswitchrc file
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/tfswitch-v6.gif" alt="drawing" style="width: 170px;"/>

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 "$@";
Expand Down Expand Up @@ -181,9 +138,23 @@ cd(){
}
```

### Jenkins setup
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/jenkins_tfswitch.png" alt="drawing" style="width: 170px;"/>

```
#!/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
```

## 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://warrensbox.github.io/terraform-switcher/additional)


## Issues
Expand Down
4 changes: 2 additions & 2 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ GEM
jekyll-seo-tag (~> 2.1)
minitest (5.11.3)
multipart-post (2.0.0)
nokogiri (1.10.1)
nokogiri (1.10.8)
mini_portile2 (~> 2.4.0)
octokit (4.13.0)
sawyer (~> 0.8.0, >= 0.5.3)
Expand All @@ -219,7 +219,7 @@ GEM
ruby-enum (0.7.2)
i18n
ruby_dep (1.5.0)
rubyzip (1.2.2)
rubyzip (1.3.0)
safe_yaml (1.0.4)
sass (3.7.3)
sass-listen (~> 4.0.0)
Expand Down
10 changes: 8 additions & 2 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

gtag('config', 'UA-120055973-1');
</script>

<!-- Place this tag in your head or just before your close body tag. -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body>
<div class="wrapper">
Expand All @@ -51,17 +54,20 @@
<li><a href="https://github.com/warrensbox/terraform-switcher/releases">Releases On <strong>GitHub</strong></a></li>
</ul>
{% endif %}

<!-- Place this tag where you want the button to render. -->
<a class="github-button" href="https://github.com/warrensbox/terraform-switcher" data-size="large" data-show-count="true" aria-label="Star warrensbox/terraform-switcher on GitHub">Star</a>
</header>
<section>

{{ content }}
{% if site.github.is_project_page %}
<p><small>This project is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a></small></p>
<p><small>This project is maintained by <a href="{{ site.github.repository_url }}">{{ site.github.owner_name }}</a></small></p>
{% endif %}
</section>
<footer>
<!-- <p><small>View other products &mdash; by <a href="http://warren.veerasingam.com/#about_me" target="_blank">Warren Veerasingam</a></small></p> -->
<p><small>This project is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a></small></p>
<p><small>This project is maintained by <a href="{{ site.github.repository_url }}">{{ site.github.owner_name }}</a></small></p>
</footer>
</div>
<script src="{{ "/assets/js/scale.fix.js" | relative_url }}"></script>
Expand Down
4 changes: 2 additions & 2 deletions docs/_site/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ GEM
jekyll-seo-tag (~> 2.1)
minitest (5.11.3)
multipart-post (2.0.0)
nokogiri (1.10.1)
nokogiri (1.10.8)
mini_portile2 (~> 2.4.0)
octokit (4.13.0)
sawyer (~> 0.8.0, >= 0.5.3)
Expand All @@ -219,7 +219,7 @@ GEM
ruby-enum (0.7.2)
i18n
ruby_dep (1.5.0)
rubyzip (1.2.2)
rubyzip (1.3.0)
safe_yaml (1.0.4)
sass (3.7.3)
sass-listen (~> 4.0.0)
Expand Down
16 changes: 11 additions & 5 deletions docs/_site/additional.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{"description":"Manage terraform versions - the tfswitch command line tool lets you switch between different versions of terraform","@type":"WebPage","url":"/additional.html","publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"/assets/img/logo.png"}},"headline":"tfswitch","@context":"http://schema.org"}</script>
<!-- End Jekyll SEO tag -->

<link rel="stylesheet" href="/assets/css/style.css?v=6d07d7f358b39ef797c837ef812a979456d32f5f">
<link rel="stylesheet" href="/assets/css/style.css?v=0b7be9932efc2fc12b75f7de015e535bb13fda26">
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
Expand All @@ -37,6 +37,9 @@

gtag('config', 'UA-120055973-1');
</script>

<!-- Place this tag in your head or just before your close body tag. -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body>
<div class="wrapper">
Expand All @@ -57,11 +60,14 @@


<ul>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases/download/0.7.0/terraform-switcher_0.7.0_darwin_amd64.tar.gz">Download <strong>MacOS</strong></a></li>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases/download/0.7.0/terraform-switcher_0.7.0_linux_amd64.tar.gz">Download <strong>Linux</strong></a></li>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases/download/0.7.737/terraform-switcher_0.7.737_darwin_amd64.tar.gz">Download <strong>MacOS</strong></a></li>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases/download/0.7.737/terraform-switcher_0.7.737_linux_amd64.tar.gz">Download <strong>Linux</strong></a></li>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases">Releases On <strong>GitHub</strong></a></li>
</ul>


<!-- Place this tag where you want the button to render. -->
<a class="github-button" href="https://github.com/warrensbox/terraform-switcher" data-size="large" data-show-count="true" aria-label="Star warrensbox/terraform-switcher on GitHub">Star</a>
</header>
<section>

Expand Down Expand Up @@ -111,12 +117,12 @@ <h2 id="troubleshoot">Troubleshoot:</h2>
<a href="index">Back to main</a></p>


<p><small>This project is maintained by <a href="http://github.com/warrensbox">warrensbox</a></small></p>
<p><small>This project is maintained by <a href="http://github.com/warrensbox/terraform-switcher">warrensbox</a></small></p>

</section>
<footer>
<!-- <p><small>View other products &mdash; by <a href="http://warren.veerasingam.com/#about_me" target="_blank">Warren Veerasingam</a></small></p> -->
<p><small>This project is maintained by <a href="http://github.com/warrensbox">warrensbox</a></small></p>
<p><small>This project is maintained by <a href="http://github.com/warrensbox/terraform-switcher">warrensbox</a></small></p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
Expand Down
85 changes: 32 additions & 53 deletions docs/_site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{"name":"tfswitch","description":"Manage terraform versions - the tfswitch command line tool lets you switch between different versions of terraform","@type":"WebSite","url":"/","publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"/assets/img/logo.png"}},"headline":"Terraform Switcher","@context":"http://schema.org"}</script>
<!-- End Jekyll SEO tag -->

<link rel="stylesheet" href="/assets/css/style.css?v=6d07d7f358b39ef797c837ef812a979456d32f5f">
<link rel="stylesheet" href="/assets/css/style.css?v=0b7be9932efc2fc12b75f7de015e535bb13fda26">
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
Expand All @@ -37,6 +37,9 @@

gtag('config', 'UA-120055973-1');
</script>

<!-- Place this tag in your head or just before your close body tag. -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body>
<div class="wrapper">
Expand All @@ -57,11 +60,14 @@


<ul>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases/download/0.7.0/terraform-switcher_0.7.0_darwin_amd64.tar.gz">Download <strong>MacOS</strong></a></li>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases/download/0.7.0/terraform-switcher_0.7.0_linux_amd64.tar.gz">Download <strong>Linux</strong></a></li>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases/download/0.7.737/terraform-switcher_0.7.737_darwin_amd64.tar.gz">Download <strong>MacOS</strong></a></li>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases/download/0.7.737/terraform-switcher_0.7.737_linux_amd64.tar.gz">Download <strong>Linux</strong></a></li>
<li><a href="https://github.com/warrensbox/terraform-switcher/releases">Releases On <strong>GitHub</strong></a></li>
</ul>


<!-- Place this tag where you want the button to render. -->
<a class="github-button" href="https://github.com/warrensbox/terraform-switcher" data-size="large" data-show-count="true" aria-label="Star warrensbox/terraform-switcher on GitHub">Star</a>
</header>
<section>

Expand Down Expand Up @@ -128,10 +134,11 @@ <h3 id="see-all-versions-including-beta-alpha-and-release-candidatesrc">See all
<li>Hit <strong>Enter</strong> to select the desired version.</li>
</ol>

<h3 id="use-tfswitchtoml-file--for-uprivilege-users-non-admin---users-with-limited-privilege-on-their-computer">Use .tfswitch.toml file (For uprivilege users/ non-admin - users with limited privilege on their computer)</h3>
<h3 id="use-tfswitchtoml-file--for-non-admin---users-with-limited-privilege-on-their-computers">Use .tfswitch.toml file (For non-admin - users with limited privilege on their computers)</h3>
<p>This is similiar to using a .tfswitchrc file, but you can specify a custom binary path for your terraform installation</p>

<p><img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/tfswitch-v8.gif" alt="drawing" style="width: 170px;" /></p>
<p><img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/tfswitch-v7.gif" alt="drawing" style="width: 490px;" />
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/tfswitch-v8.gif" alt="drawing" style="width: 490px;" /></p>

<ol>
<li>Create a custom binary path. Ex: <code class="highlighter-rouge">mkdir /Users/warrenveerasingam/bin</code> (replace warrenveerasingam with your username)</li>
Expand All @@ -146,51 +153,6 @@ <h3 id="use-tfswitchtoml-file--for-uprivilege-users-non-admin---users-with-limit
<li>Run <code class="highlighter-rouge">tfswitch</code> and it should automatically install the required terraform version in the specified binary path</li>
</ol>

<p><img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/tfswitch-v7.gif" alt="drawing" style="width: 170px;" /></p>

<p><strong>Automatically switch with bash</strong></p>

<p>Add the following to the end of your <code class="highlighter-rouge">~/.bashrc</code> file:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cdtfswitch(){
builtin cd "$@";
cdir=$PWD;
if [ -f "$cdir/.tfswitch.toml" ]; then
tfswitch
fi
}
alias cd='cdtfswitch'
</code></pre></div></div>

<p><strong>Automatically switch with zsh</strong></p>

<p>Add the following to the end of your <code class="highlighter-rouge">~/.zshrc</code> file:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>load-tfswitch() {
local tfswitchrc_path=".tfswitch.toml"

if [ -f "$tfswitchrc_path" ]; then
tfswitch
fi
}
add-zsh-hook chpwd load-tfswitch
load-tfswitch
</code></pre></div></div>
<blockquote>
<p>NOTE: if you see an error like this: <code class="highlighter-rouge">command not found: add-zsh-hook</code>, then you might be on an older version of zsh (see below), or you simply need to load <code class="highlighter-rouge">add-zsh-hook</code> by adding this to your <code class="highlighter-rouge">.zshrc</code>:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code> autoload -U add-zsh-hook
</code></pre></div> </div>
</blockquote>

<p><em>older version of zsh</em></p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd(){
builtin cd "$@";
cdir=$PWD;
if [ -f "$cdir/.tfswitchrc" ]; then
tfswitch
fi
}
</code></pre></div></div>

<h3 id="use-tfswitchrc-file">Use .tfswitchrc file</h3>
<p><img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/tfswitch-v6.gif" alt="drawing" style="width: 490px;" /></p>

Expand All @@ -200,9 +162,13 @@ <h3 id="use-tfswitchrc-file">Use .tfswitchrc file</h3>
<li>Run the command <code class="highlighter-rouge">tfswitch</code> in the same directory as your <code class="highlighter-rouge">.tfswitchrc</code>.</li>
</ol>

<p><em>Instead of a <code class="highlighter-rouge">.tfswitchrc</code> file, a <code class="highlighter-rouge">.terraform-version</code> file may be used for compatibility with <a href="https://github.com/tfutils/tfenv#terraform-version-file"><code class="highlighter-rouge">tfenv</code></a> and other tools which use it</em></p>

<p><strong>Automatically switch with bash</strong></p>

<p>Add the following to the end of your <code class="highlighter-rouge">~/.bashrc</code> file:</p>
<p>Add the following to the end of your <code class="highlighter-rouge">~/.bashrc</code> file:
(Use either <code class="highlighter-rouge">.tfswitchrc</code> or <code class="highlighter-rouge">.tfswitch.toml</code> or <code class="highlighter-rouge">.terraform-version</code>)</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cdtfswitch(){
builtin cd "$@";
cdir=$PWD;
Expand Down Expand Up @@ -243,6 +209,19 @@ <h3 id="use-tfswitchrc-file">Use .tfswitchrc file</h3>
}
</code></pre></div></div>

<h3 id="jenkins-setup">Jenkins setup</h3>
<p><img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/jenkins_tfswitch.png" alt="drawing" style="width: 170px;" /></p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/bash </span>

<span class="nb">echo</span> <span class="s2">"Installing tfswitch locally"</span>
wget https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh
chmod 755 install.sh
./install.sh <span class="nt">-b</span> bin-directory

./bin-directory/tfswitch
</code></pre></div></div>

<hr />

<h2 id="issues">Issues</h2>
Expand All @@ -255,12 +234,12 @@ <h2 id="issues">Issues</h2>
<a href="additional">Additional Info</a></p>


<p><small>This project is maintained by <a href="http://github.com/warrensbox">warrensbox</a></small></p>
<p><small>This project is maintained by <a href="http://github.com/warrensbox/terraform-switcher">warrensbox</a></small></p>

</section>
<footer>
<!-- <p><small>View other products &mdash; by <a href="http://warren.veerasingam.com/#about_me" target="_blank">Warren Veerasingam</a></small></p> -->
<p><small>This project is maintained by <a href="http://github.com/warrensbox">warrensbox</a></small></p>
<p><small>This project is maintained by <a href="http://github.com/warrensbox/terraform-switcher">warrensbox</a></small></p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
Expand Down
Loading

0 comments on commit ba54688

Please sign in to comment.