Skip to content

Commit

Permalink
rename cookbook, use 'golang' namespace for attributes (#56)
Browse files Browse the repository at this point in the history
* use 'golang' namespace for attributes
* rename cookbook
* version 2.0.0!
  • Loading branch information
mburns authored Feb 25, 2018
1 parent 24dfd6a commit cfd79d5
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 173 deletions.
9 changes: 5 additions & 4 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ provisioner:
require_chef_omnibus: true

platforms:
- name: ubuntu-14.10
- name: centos-6.5
- name: ubuntu-16.04
- name: debian-8
- name: centos-6.9

suites:
- name: default
run_list:
- recipe[golang_test::default]
- recipe[minitest-handler]
attributes:
go:
golang:
owner: 'vagrant'
group: 'vagrant'
- name: src
run_list:
- recipe[golang_test::default]
- recipe[minitest-handler]
attributes:
go:
golang:
from_source: true
arch: 'amd64'
owner: 'vagrant'
Expand Down
6 changes: 3 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-02-23 20:09:39 -0800 using RuboCop version 0.52.1.
# on 2018-02-24 21:54:23 -0800 using RuboCop version 0.52.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -27,8 +27,8 @@ Style/RegexpLiteral:
Exclude:
- 'providers/package.rb'

# Offense count: 12
# Offense count: 14
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 131
Max: 135
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file is used to list changes made in each version of golang.

## 2.0.0

* rename to `chef-golang` so that metadata name matches repositoriy name
* change attribute namespace to `node['golang']`

## 1.7.2

* Better chef12,13 support
Expand Down
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Contributing

1. Fork the repository
2. Create a named feature branch (like `add_component_x`)
3. Write you change
4. Test it by running `rake kitchen:all`
5. Submit a Pull Request
57 changes: 23 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
[![Build Status](https://travis-ci.org/NOX73/chef-golang.svg?branch=master)](https://travis-ci.org/NOX73/chef-golang)
[![Cookbook Version](https://img.shields.io/cookbook/v/golang.svg?style=flat)](https://supermarket.chef.io/cookbooks/golang)

# golang (Chef cookbook for Go)
# chef-golang (Chef cookbook Go)

## Description

Chef cookbook for [Go programming language](http://golang.org/).
Chef cookbook for the [Go programming language](http://golang.org/).

## Requirements

### Platform

* Ubuntu (12.04/13.04/14.10)
* Debian (6.0)
* CentOS (6.5)
* Ubuntu (16.04)
* Debian (8)
* CentOS (6.9)

**Notes**: This cookbook has been tested on the listed platforms. It
may work on other platforms with or without modification. Please
[report issues](https://github.com/NOX73/chef-golang/issues) any additional platforms so they can be added.
**Notes**: This cookbook has been tested on the listed platforms. It may work on other platforms with or without modification. Please [report issues](https://github.com/NOX73/chef-golang/issues) any additional platforms so they can be added.


## Usage

#### golang::default
#### chef-golang::default

Just include `golang` in your node's `run_list`:

```json
{
"name":"my_node",
"run_list": [
"recipe[golang]"
"recipe[chef-golang]"
]
}
```

#### golang::packages
#### chef-golang::packages

To install Go packages using node attributes, include `golang::packages` in your node's `run_list`, and use the `['go']['packages']` attribute:
To install Go packages using node attributes, include `golang::packages` in your node's `run_list`, and use the `['golang']['packages']` attribute:

```json
{
Expand All @@ -56,23 +54,22 @@ To install Go packages using node attributes, include `golang::packages` in your

## Attributes

#### golang::default

#### chef-golang::default

Key | Type | Description | Default
--- | ---- | ----------- | -------
`['go']['version']` | String | Go version | `1.5`
`['go']['platform']` | String | `amd64` or `i386` | `amd64`
`['go']['scm']` | Boolean | install SCM dependencies `git`, `hg`, and `bzr` | `true`
`['go']['packages']` | Array | Go packages to install when using the `golang::packages` recipe | `[]`
`['go']['owner']` | String | The user account that owns $GOPATH | `root`
`['go']['group']` | String | The group that owns $GOPATH | `root`
`['go']['mode']` | String | The mode of $GOPATH | `0755`
`['go']['from_source']` | Boolean | Install go from source | `false`
`['go']['os']` | String | Build go for which operating system | `linux`
`['go']['arch']` | String | Build go for which architecture | `arm`
`['go']['arm']` | String | Build go for which arm version | `6`
`['go']['source_method']` | String | Choose which install script should be used | `all.bash`
`['golang']['version']` | String | Go version | `1.5`
`['golang']['platform']` | String | `amd64` or `i386` | `amd64`
`['golang']['scm']` | Boolean | install SCM dependencies `git`, `hg`, and `bzr` | `true`
`['golang']['packages']` | Array | Go packages to install when using the `golang::packages` recipe | `[]`
`['golang']['owner']` | String | The user account that owns $GOPATH | `root`
`['golang']['group']` | String | The group that owns $GOPATH | `root`
`['golang']['mode']` | String | The mode of $GOPATH | `0755`
`['golang']['from_source']` | Boolean | Install go from source | `false`
`['golang']['os']` | String | Build go for which operating system | `linux`
`['golang']['arch']` | String | Build go for which architecture | `arm`
`['golang']['arm']` | String | Build go for which arm version | `6`
`['golang']['source_method']` | String | Choose which install script should be used | `all.bash`

## Testing

Expand All @@ -87,11 +84,3 @@ satisfied:
* [Vagrant](http://vagrantup.com/) (>= 1.1.0)
* [VirtualBox](https://www.virtualbox.org/)
* [Vagrant Berkshelf Plugin](http://rubygems.org/gems/vagrant-berkshelf)

## Contributing

1. Fork the repository
2. Create a named feature branch (like `add_component_x`)
3. Write you change
4. Test it by running `rake kitchen:all`
5. Submit a Pull Request
38 changes: 19 additions & 19 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
default['go']['version'] = '1.5'
default['go']['platform'] = node['kernel']['machine'] =~ /i.86/ ? '386' : 'amd64'
default['go']['filename'] = "go#{node['go']['version']}.#{node['os']}-#{node['go']['platform']}.tar.gz"
default['go']['from_source'] = false
if node['go']['from_source']
default['go']['filename'] = "go#{node['go']['version']}.src.tar.gz"
default['go']['os'] = 'linux'
default['go']['arch'] = 'arm'
default['go']['arm'] = '6'
default['go']['source_method'] = 'all.bash'
default['golang']['version'] = '1.5'
default['golang']['platform'] = node['kernel']['machine'] =~ /i.86/ ? '386' : 'amd64'
default['golang']['filename'] = "go#{node['golang']['version']}.#{node['os']}-#{node['golang']['platform']}.tar.gz"
default['golang']['from_source'] = false
if node['golang']['from_source']
default['golang']['filename'] = "go#{node['golang']['version']}.src.tar.gz"
default['golang']['os'] = 'linux'
default['golang']['arch'] = 'arm'
default['golang']['arm'] = '6'
default['golang']['source_method'] = 'all.bash'
end
default['go']['url'] = "http://golang.org/dl/#{node['go']['filename']}"
default['go']['install_dir'] = '/usr/local'
default['go']['gopath'] = '/opt/go'
default['go']['gobin'] = '/opt/go/bin'
default['go']['scm'] = true
default['go']['packages'] = []
default['go']['owner'] = 'root'
default['go']['group'] = 'root'
default['go']['mode'] = 0o755
default['golang']['url'] = "http://golang.org/dl/#{node['golang']['filename']}"
default['golang']['install_dir'] = '/usr/local'
default['golang']['gopath'] = '/opt/go'
default['golang']['gobin'] = '/opt/go/bin'
default['golang']['scm'] = true
default['golang']['packages'] = []
default['golang']['owner'] = 'root'
default['golang']['group'] = 'root'
default['golang']['mode'] = 0o755
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
license 'Apache-2.0'
description 'Installs go programming language'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.7.2'
version '2.0.0'
chef_version '>= 12' if respond_to?(:chef_version)

recipe 'golang', 'Installs go programing language.'
Expand Down
42 changes: 21 additions & 21 deletions providers/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
tmp_file_path = ::File.join tmp_dir_path, new_resource.name.gsub(/\//, '-')

directory tmp_dir_path do
user node['go']['owner']
group node['go']['group']
user node['golang']['owner']
group node['golang']['group']
mode '0775'
action :nothing
end.run_action(:create)

bash "Installing package #{new_resource.name}" do
code "#{node['go']['install_dir']}/go/bin/go get -v #{new_resource.name} 2> >(grep -v '(download)$' | tee #{tmp_file_path})"
code "#{node['golang']['install_dir']}/go/bin/go get -v #{new_resource.name} 2> >(grep -v '(download)$' | tee #{tmp_file_path})"
action :nothing
user node['go']['owner']
group node['go']['group']
user node['golang']['owner']
group node['golang']['group']
environment(
'GOPATH' => node['go']['gopath'],
'GOBIN' => node['go']['gobin']
'GOPATH' => node['golang']['gopath'],
'GOBIN' => node['golang']['gobin']
)
end.run_action(:run)

f = file tmp_file_path do
user node['go']['owner']
group node['go']['group']
user node['golang']['owner']
group node['golang']['group']
content ''
end
f.run_action(:create)
Expand All @@ -34,13 +34,13 @@
tmp_file_path = ::File.join Chef::Config[:file_cache_path], new_resource.name.gsub(/\//, '-')

bash "Updating package #{new_resource.name}" do
code "#{node['go']['install_dir']}/go/bin/go get -v -u #{new_resource.name} 2> >(grep -v '(download)$' | tee #{tmp_file_path})"
code "#{node['golang']['install_dir']}/go/bin/go get -v -u #{new_resource.name} 2> >(grep -v '(download)$' | tee #{tmp_file_path})"
action :nothing
user node['go']['owner']
group node['go']['group']
user node['golang']['owner']
group node['golang']['group']
environment(
'GOPATH' => node['go']['gopath'],
'GOBIN' => node['go']['gobin']
'GOPATH' => node['golang']['gopath'],
'GOBIN' => node['golang']['gobin']
)
end.run_action(:run)

Expand All @@ -53,23 +53,23 @@
action :build do
tmpdir = directory (::File.join Chef::Config[:file_cache_path], new_resource.name.gsub(/\//, '-') + '_BUILD') do
action :nothing
owner node['go']['owner']
group node['go']['group']
owner node['golang']['owner']
group node['golang']['group']
recursive true
end

# create temporary directory to executing the build in
tmpdir.run_action(:create)

b = bash "Build package #{new_resource.name}" do
code "#{node['go']['install_dir']}/go/bin/go build #{new_resource.name}"
code "#{node['golang']['install_dir']}/go/bin/go build #{new_resource.name}"
action :nothing
cwd tmpdir.name
user node['go']['owner']
group node['go']['group']
user node['golang']['owner']
group node['golang']['group']
environment(
'GOPATH' => node['go']['gopath'],
'GOBIN' => node['go']['gobin']
'GOPATH' => node['golang']['gopath'],
'GOBIN' => node['golang']['gobin']
)
end

Expand Down
Loading

0 comments on commit cfd79d5

Please sign in to comment.