Skip to content
This repository has been archived by the owner on Feb 18, 2020. It is now read-only.

Commit

Permalink
#58 gocd_plugin resource
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzo committed Dec 11, 2015
1 parent 27ad93a commit 707e602
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .kitchen.openstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ platforms:
box: 'debian-7.8-bpk-chef-12.4.1'
customize:
server_name: 'kt-go'
flavor: 'v.c1.m1536.d5.e0'
flavor: 'v.c1.m2048.d5.e0'
server_create_timeout: 540
server_active_timeout: 540

suites:
- name: default
run_list:
- recipe[gocd]
- recipe[gocd_test::plugin_lwrp]
attributes:
java:
jdk_version: 7
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ gocd_agent 'my-go-agent' do
end
```

# GoCD plugin LWRP

You can install Go server plugins with `gocd_plugin` LWRP like this

```ruby
include_recipe 'gocd::server'

gocd_plugin 'github-pr-status' do
plugin_uri 'https://github.com/gocd-contrib/gocd-build-status-notifier/releases/download/1.1/github-pr-status-1.1.jar'
end
```

# License

Apache License, Version 2.0
3 changes: 3 additions & 0 deletions libraries/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ def create_gocd_agent(resource_name)
def delete_gocd_agent(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:gocd_agent, :delete, resource_name)
end
def create_gocd_plugin(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:gocd_plugin, :create, resource_name)
end
end
16 changes: 16 additions & 0 deletions providers/plugin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use_inline_resources

action :create do
run_context.include_recipe 'gocd::server_linux_install'

plugin_name = new_resource.plugin_name
server_work_dir = new_resource.server_work_dir
plugin_uri = new_resource.plugin_uri
remote_file "#{server_work_dir}/plugins/external/#{plugin_name}.jar" do
source plugin_uri
owner 'go'
group 'go'
mode 0770
retries 5
end
end
7 changes: 7 additions & 0 deletions resources/plugin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
actions :create, :delete

default_action :create if defined?(default_action)

attribute :plugin_name, :name_attribute => true, :kind_of => String, :required => true
attribute :plugin_uri, :kind_of => String, :required => true
attribute :server_work_dir, :kind_of => String, :required => false, :default => node['gocd']['server']['work_dir']
24 changes: 24 additions & 0 deletions spec/plugin_lwrp_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'spec_helper'

describe 'gocd_test::plugin_lwrp' do
let(:chef_run) do
run = ChefSpec::SoloRunner.new(step_into: 'gocd_plugin') do |node|
node.automatic['lsb']['id'] = 'Debian'
node.automatic['platform_family'] = 'debian'
node.automatic['platform'] = 'debian'
node.automatic['os'] = 'linux'
end
run.converge(described_recipe)
end

it 'creates gocd_plugin chef resource' do
expect(chef_run).to create_gocd_plugin('github-pr-status')
end
it 'downloads github-pr-status plugin as a remote_file' do
expect(chef_run).to create_remote_file('/var/lib/go-server/plugins/external/github-pr-status.jar')
.with(
source: 'https://github.com/gocd-contrib/gocd-build-status-notifier/releases/download/1.1/github-pr-status-1.1.jar',
owner: 'go'
)
end
end
5 changes: 5 additions & 0 deletions test/test_cookbook/recipes/plugin_lwrp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include_recipe 'gocd::server'

gocd_plugin 'github-pr-status' do
plugin_uri 'https://github.com/gocd-contrib/gocd-build-status-notifier/releases/download/1.1/github-pr-status-1.1.jar'
end

0 comments on commit 707e602

Please sign in to comment.