NOX73/chef-golang — pull request #35 by leejones (2014-11-19 22:23:50+00:00)
Title: Fix permissions issue when installing packages

First off, thanks for creating/maintaining this cookbook!

I wanted golang and its packages to be installed as the CI user (`jenkins-node` in our case). It looks like the `golang_package` provider [writes to Chef's cache directory](https://github.com/NOX73/chef-golang/blob/master/providers/package.rb#L6). In my case this fails because the `jenkins-node` user is trying to write to `/var/cache/chef` which is owned by `root`.

Here is the error output:

```
Mixlib::ShellOut::ShellCommandFailed: golang_package[github.com/tools/godep] (golang::packages line 23) had an error: Mixlib::ShellOut::ShellCommandFailed: bash[/usr/local/go/bin/go get -v github.com/tools/godep 2> >(grep -v '(download)$'
> /var/cache/chef/github.com-tools-godep)] (/var/cache/chef/cookbooks/golang/providers/package.rb line 5) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '141'
---- Begin output of "bash" "/tmp/chef-script20141119-6735-2f5prf" ----
STDOUT:
STDERR: /tmp/chef-script20141119-6735-2f5prf: line 1: /var/cache/chef/github.com-tools-godep: Permission denied
```

I ran test kitchen to see if I hit the same error locally and saw that the test recipe uses the vagrant user. I discovered that the Chef cache directory when running test kitchen is set to `/tmp/kitchen`. It turns out that `/tmp/kitchen` is owned by the `vagrant` user so there is no failure locally.

I updated the test kitchen to use a different user and was able to then reproduce the issue.

I then added a fix by creating the file before attempting to write to it. I'm not sure I entirely understand what the LWRP is trying to do with this file, but my fix seems to resolve the error I was hitting. Any feedback would be appreciated.

A few other notes about the PR:

* please see https://github.com/lonelyplanet/chef-golang/commit/476155a08b153a8ec2216c9b8e4b0b272a78ccbe for why I bumped Berkshelf
* I was able to successfully run the tests against the Ubuntu VM (using `bundle exec kitchen test ubuntu), but it looks like the configured CentOS VM is no longer available:

```
Downloading box from URL: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.5_chef-11.4.4.box
Progress: 0% (Rate: 0/s, Estimated time remaining: --:--:--)
STDERR: Download failed. Will try another box URL if there is one.
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

The requested URL returned error: 404 Not Found
```

I did a little searching for a new URL, but couldn't find one.