Skip to content

Commit

Permalink
Added license, lots of comments and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
jackscott committed Apr 14, 2016
1 parent 84a4759 commit 2005adf
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 35 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Jack Scott

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
49 changes: 27 additions & 22 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
===============
==============
Golang-Formula
==============

Expand Down Expand Up @@ -27,34 +27,39 @@ Install go!
-----------------
Helpful for debugging, dumps the jinja map to a text file

## Testing

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.

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)
Testing
=========

Requirements
------------

```
bundle
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`.

\\ or
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.

bundle install
```
.. _KitchenSalt: https://github.com/simonmcc/kitchen-salt

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
- creating a vagrant box
- install salt
- run the states defined in **golang-formula/.kitchen.yml**

Cheat Sheet
------------

.. code-block::
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>`_.
# Initial setup
which bundle || gem install bundler
bundle install
# build vagrant box and run states
kitchen converge
# run tests in `test/integration/default`
kitchen verify
You can also run the `kitchen test` command, but that will destroy the existing vagrant before converging, roughly:
```
kitchen destroy && kitchen converge && kitchen verify && kitchen destroy
```
which is useful for CI pipelines but not so much during dev.
# sledgehammer
kitchen destroy
# alias for running (destroy + converge + verify + destroy)
kitchen test
## Author
[Jack Scott](https://github.com/jackscott) \<emacs+pinky@gmail.com\>
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
39 changes: 26 additions & 13 deletions golang/init.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{% from "golang/map.jinja" import config with context %}
# :TODO: Move this shit into defaults
# Installing Golang is pretty easy, thanks Googs, so basically all we need to
# do is pull down an archive and unpack it somewhere. To allow for versioning,
# we use a extract the tarball to <prefix>/golang/<version>/go and then create
# a symlink back to `golang:lookup:go_root` which defaults to /usr/local/go
# pull down a copy of the archive the first time we run but check
# with the salt filesystem for a copy before hitting the web.
# regardless of source, they should all pass the hash check
# In the interest of being good netizens, we will only pull down the archive
# if golang is not installed or the specific version is missing
golang|cache-archive:
file.managed:
- name: /tmp/{{ config.archive_name }}
Expand All @@ -12,25 +14,30 @@ golang|cache-archive:
- user: root
- group: root
- unless:
- test -f /tmp/{{ config.archive_name }}
# asserts go is on our path
- which go
# asserts the version of go
- test -x {{ config.base_dir }}/go/bin/go
# Extract the archive locally to {{ config.base_dir }}/go
# which is useful if we ever need to handle multiple versions
# Extract the archive locally to golang:lookup:base_dir: which has our version
# schema already baked in and extract the archive if necessary
golang|extract-archive:
file.directory:
- names:
- {{ config.base_dir }}
- {{ config.go_path }}
- user: root
- group: root
- mode: 775
- makedirs: true
- makedirs: truen
- unless:
- test -d {{ config.base_dir }}
- recurse:
- user
- group
- mode
# golang|cache-archive provides us with a cached copy of the archive
# so we only need to look in a single place when we actually exract
# if the version of go is already installed and is on our path, skip extract
archive.extracted:
- name: {{ config.base_dir }}
- source: "/tmp/{{ config.archive_name }}"
Expand All @@ -39,13 +46,15 @@ golang|extract-archive:
- user: root
- group: root
- tar_options: v
- require:
- watch:
- file: golang|cache-archive
# golang|cache-archive already applies these predicates and the watch
# statement should cover us, paranoia is an applied art.
- unless:
- go version | grep {{ config.version }}
- test -x {{ config.base_dir }}/go/bin/go
# add a symlink from versioned install to /usr/local/go
# add a symlink from versioned install to point at golang:lookup:go_root
golang|update-alternatives:
alternatives.install:
- name: golang-home-link
Expand All @@ -56,6 +65,7 @@ golang|update-alternatives:
- watch:
- archive: golang|extract-archive
# add symlinks to /usr/bin for the three go commands
{% for i in ['go', 'godoc', 'gofmt'] %}
golang|create-symlink-{{ i }}:
Expand All @@ -69,6 +79,8 @@ golang|create-symlink-{{ i }}:
- archive: golang|extract-archive
{% endfor %}
# sets up the necessary environment variables required for golang usage
golang|setup-bash-profile:
file.managed:
- name: /etc/profile.d/golang.sh
Expand All @@ -80,3 +92,4 @@ golang|setup-bash-profile:
- user: root
- group: root

0 comments on commit 2005adf

Please sign in to comment.