Skip to content

Commit 2005adf

Browse files
committed
Added license, lots of comments and updated README
1 parent 84a4759 commit 2005adf

File tree

4 files changed

+75
-35
lines changed

4 files changed

+75
-35
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Jack Scott
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.rst

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
===============
1+
==============
22
Golang-Formula
33
==============
44

@@ -27,34 +27,39 @@ Install go!
2727
-----------------
2828
Helpful for debugging, dumps the jinja map to a text file
2929

30-
## Testing
3130

32-
Testing is done with `kitchen-salt<https://github.com/simonmcc/kitchen-salt>`_ which means you'll also need Ruby. Hopefully you're already using rbenv or whatever all of the cool kids are using these days, I'm a fuddy-duddy and use rbenv. This formula has been tested on both 1.9.3 and 2.2.2 versions of Ruby.
3331

34-
You should have `bundler` installed and have `bundle` on your $PATH, running this will set things up for Ruby. If you're not running ruby-2.2.2 an exception will be thrown because the `Gemfile` is pinned to 2.2.2, update your Ruby version and re-run bundle command(s)
32+
Testing
33+
=========
34+
35+
Requirements
36+
------------
3537

36-
```
37-
bundle
38+
Testing is done with KitchenSalt_ which means you'll also need a working Ruby setup and preferably 2.2.2, but you can use whatever version as long as you update the `Gemfile`. You will also need `bundler` installed and can be done so with `gem install bundler`.
3839

39-
\\ or
40+
If all that works, you should be able to run `kitchen test` which is an alias for `kitchen converge` + `kitchen verify` but it deletes the box on completion so it isn't very useful during development.
4041

41-
bundle install
42-
```
42+
.. _KitchenSalt: https://github.com/simonmcc/kitchen-salt
4343

44-
Once you have successfully bundled things up, you should have the `kitchen` command on your $PATH. The first part is to run `kitchen converge` which will setup the environment by
45-
- creating a vagrant box
46-
- install salt
47-
- run the states defined in **golang-formula/.kitchen.yml**
48-
44+
Cheat Sheet
45+
------------
46+
47+
.. code-block::
4948
50-
Once you've successfully `converged` the environment, the tests can be executed. If you were to run `kitchen verify` the tests found in `golang-formula/test/integration/default`. Currently there are only tests which use the `bats<https://blog.engineyard.com/2014/bats-test-command-line-tools>`_ ` `Busser<https://github.com/test-kitchen/busser>`_.
49+
# Initial setup
50+
which bundle || gem install bundler
51+
bundle install
52+
53+
# build vagrant box and run states
54+
kitchen converge
55+
56+
# run tests in `test/integration/default`
57+
kitchen verify
5158
52-
You can also run the `kitchen test` command, but that will destroy the existing vagrant before converging, roughly:
53-
```
54-
kitchen destroy && kitchen converge && kitchen verify && kitchen destroy
55-
```
56-
which is useful for CI pipelines but not so much during dev.
59+
# sledgehammer
60+
kitchen destroy
5761
62+
# alias for running (destroy + converge + verify + destroy)
63+
kitchen test
5864
59-
## Author
60-
[Jack Scott](https://github.com/jackscott) \<[email protected]\>
65+

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

golang/init.sls

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{% from "golang/map.jinja" import config with context %}
2-
# :TODO: Move this shit into defaults
2+
# Installing Golang is pretty easy, thanks Googs, so basically all we need to
3+
# do is pull down an archive and unpack it somewhere. To allow for versioning,
4+
# we use a extract the tarball to <prefix>/golang/<version>/go and then create
5+
# a symlink back to `golang:lookup:go_root` which defaults to /usr/local/go
36
4-
# pull down a copy of the archive the first time we run but check
5-
# with the salt filesystem for a copy before hitting the web.
6-
# regardless of source, they should all pass the hash check
7+
# In the interest of being good netizens, we will only pull down the archive
8+
# if golang is not installed or the specific version is missing
79
golang|cache-archive:
810
file.managed:
911
- name: /tmp/{{ config.archive_name }}
@@ -12,25 +14,30 @@ golang|cache-archive:
1214
- user: root
1315
- group: root
1416
- unless:
15-
- test -f /tmp/{{ config.archive_name }}
17+
# asserts go is on our path
18+
- which go
19+
# asserts the version of go
20+
- test -x {{ config.base_dir }}/go/bin/go
21+
1622
17-
# Extract the archive locally to {{ config.base_dir }}/go
18-
# which is useful if we ever need to handle multiple versions
23+
# Extract the archive locally to golang:lookup:base_dir: which has our version
24+
# schema already baked in and extract the archive if necessary
1925
golang|extract-archive:
2026
file.directory:
2127
- names:
2228
- {{ config.base_dir }}
29+
- {{ config.go_path }}
2330
- user: root
2431
- group: root
2532
- mode: 775
26-
- makedirs: true
33+
- makedirs: truen
34+
- unless:
35+
- test -d {{ config.base_dir }}
2736
- recurse:
2837
- user
2938
- group
3039
- mode
31-
# golang|cache-archive provides us with a cached copy of the archive
32-
# so we only need to look in a single place when we actually exract
33-
# if the version of go is already installed and is on our path, skip extract
40+
3441
archive.extracted:
3542
- name: {{ config.base_dir }}
3643
- source: "/tmp/{{ config.archive_name }}"
@@ -39,13 +46,15 @@ golang|extract-archive:
3946
- user: root
4047
- group: root
4148
- tar_options: v
42-
- require:
49+
- watch:
4350
- file: golang|cache-archive
51+
# golang|cache-archive already applies these predicates and the watch
52+
# statement should cover us, paranoia is an applied art.
4453
- unless:
4554
- go version | grep {{ config.version }}
4655
- test -x {{ config.base_dir }}/go/bin/go
4756
48-
# add a symlink from versioned install to /usr/local/go
57+
# add a symlink from versioned install to point at golang:lookup:go_root
4958
golang|update-alternatives:
5059
alternatives.install:
5160
- name: golang-home-link
@@ -56,6 +65,7 @@ golang|update-alternatives:
5665
- watch:
5766
- archive: golang|extract-archive
5867
68+
5969
# add symlinks to /usr/bin for the three go commands
6070
{% for i in ['go', 'godoc', 'gofmt'] %}
6171
golang|create-symlink-{{ i }}:
@@ -69,6 +79,8 @@ golang|create-symlink-{{ i }}:
6979
- archive: golang|extract-archive
7080
{% endfor %}
7181
82+
83+
# sets up the necessary environment variables required for golang usage
7284
golang|setup-bash-profile:
7385
file.managed:
7486
- name: /etc/profile.d/golang.sh
@@ -80,3 +92,4 @@ golang|setup-bash-profile:
8092
- user: root
8193
- group: root
8294
95+

0 commit comments

Comments
 (0)