poise-application-git 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,69 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ application_git '/opt/test1' do
18
+ repository 'https://github.com/poise/test_repo.git'
19
+ revision 'master'
20
+ end
21
+
22
+ application '/opt/test2' do
23
+ git do
24
+ repository 'https://github.com/poise/test_repo.git'
25
+ revision 'master'
26
+ end
27
+ end
28
+
29
+ application '/opt/test3' do
30
+ git 'https://github.com/poise/test_repo.git' do
31
+ revision 'release'
32
+ end
33
+ end
34
+
35
+ application '/opt/test4' do
36
+ git 'git@github.com:coderanger/private_test_repo.git' do
37
+ revision 'master'
38
+ # Pubkey ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCk2Y0Vj3oWr5oyo2ekL0V7Tj9/vNBjH6AiO/zfIc+7dR1KaCeCkx5GRhP/XxaiSn3Fxl1JSpBswd+Oue9SJ16nuQ2eUrK5zzN+GRsz4DfqvczmDLGHrlND3FpE+GbCMbmXObYoki9LuysrYVWfye4Rc5ICm+rSqtD+QB8rUguqXKu9tVVx9ug22P5s5OxcTCOZRJsz4U++64coD8X3P++6icGemXZDUUR5B2oWoMzXafbOC1Oo0aStAxEew/kfs3hFmdfmMdC9KAilqPxY1LtqHhMB0rdqynaAc4r1HKoSbAGdcwrJgd2TV8eoB25ydvzZwnOhLdO5Cm8Od63ovEUR
39
+ deploy_key <<-EOH
40
+ -----BEGIN RSA PRIVATE KEY-----
41
+ MIIEowIBAAK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Mv0yd4S/dpJbGql
57
+ FQvZKGGGc8h4NXiXdSqCqr+axJdBRRL+2PJ3G3cCgYB4jZpiFlRsljIbrTDO5R2x
58
+ jE3YIjxF1xRH23sZU0LmThX2N/lYeRBuvY+F/1lXnluLWQpUTRFB9YB1N2MF6wM4
59
+ MJhGkeLQI1++wPQzCVdG4m+eiY+9UYgN8s3STxPGyy5EdFJa8FBu/aw8Lj66yWd4
60
+ 4NmTR7K7XBoFnEByiukhJQKBgQCb//2NrkL3RumUM++tE1Z0IcNL81FWzLYUgyth
61
+ yetweSdYH3tLj75F9WA9crKpr82dij8qUheT9MGQodYHjw/SO1HCU4P3gtgGcPCl
62
+ OyiFnsMJup8chpAX9nGslDnsMpE4HW6AWtCXthZIhLB3qLWbL0dqqQTgFKsTgZmy
63
+ yoFceQKBgBcNNGTOjzW+J7lfC+AY+XUPhZQAUJi47+m0Tbrp5j/1BDuvI6WTlsIr
64
+ 7WMFJM91xqHQZK7D0zjbGa42+uwlCs+ZBolNZpW2K7dNAriBjHuD3VDhlkqZrPC2
65
+ EwOhBYydRkzoALbgESjKP3VwfIVr9tWs4CyndY81uqRbgiRqdzR4
66
+ -----END RSA PRIVATE KEY-----
67
+ EOH
68
+ end
69
+ end
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.0'
@@ -0,0 +1,24 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', github: 'chef/chef'
20
+ gem 'halite', github: 'poise/halite'
21
+ gem 'poise', github: 'poise/poise'
22
+ gem 'poise-application', github: 'poise/application'
23
+ gem 'poise-boiler', github: 'poise/poise-boiler'
24
+ gem 'poise-service', github: 'poise/poise-service'
@@ -0,0 +1,42 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'serverspec'
18
+ set :backend, :exec
19
+
20
+ describe file('/opt/test1/README.md') do
21
+ it { is_expected.to be_a_file }
22
+ its(:content) { is_expected.to include('repo=test_repo') }
23
+ its(:content) { is_expected.to include('branch=master') }
24
+ end
25
+
26
+ describe file('/opt/test2/README.md') do
27
+ it { is_expected.to be_a_file }
28
+ its(:content) { is_expected.to include('repo=test_repo') }
29
+ its(:content) { is_expected.to include('branch=master') }
30
+ end
31
+
32
+ describe file('/opt/test3/README.md') do
33
+ it { is_expected.to be_a_file }
34
+ its(:content) { is_expected.to include('repo=test_repo') }
35
+ its(:content) { is_expected.to include('branch=release') }
36
+ end
37
+
38
+ describe file('/opt/test4/README.md') do
39
+ it { is_expected.to be_a_file }
40
+ its(:content) { is_expected.to include('repo=private_test_repo') }
41
+ its(:content) { is_expected.to include('branch=master') }
42
+ end
@@ -0,0 +1,97 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'spec_helper'
18
+
19
+ describe PoiseApplicationGit::Resource do
20
+ step_into(:application_git)
21
+ recipe do
22
+ application_git '/test' do
23
+ user 'root'
24
+ repository 'https://example.com/test.git'
25
+ revision 'd44ec06d0b2a87732e91c005ed2048c824fd63ed'
26
+ deploy_key 'secretkey'
27
+ end
28
+ end
29
+
30
+ before do
31
+ # Don't actually run the real thing
32
+ expect_any_instance_of(PoiseApplicationGit::Provider).to receive(:action_sync).and_return(nil)
33
+ expect_any_instance_of(PoiseApplicationGit::Provider).to receive(:include_recipe).with('git').and_return(nil)
34
+ # Unwrap notifying_block
35
+ allow_any_instance_of(PoiseApplicationGit::Provider).to receive(:notifying_block) {|&block| block.call }
36
+ end
37
+
38
+ it { is_expected.to sync_application_git('/test').with(repository: 'https://example.com/test.git', revision: 'd44ec06d0b2a87732e91c005ed2048c824fd63ed', deploy_key: 'secretkey', ssh_wrapper: File.expand_path('~root/.ssh/ssh_wrapper_2089348824')) }
39
+ it { is_expected.to render_file(File.expand_path('~root/.ssh/id_deploy_2089348824')).with_content('secretkey') }
40
+ it { is_expected.to render_file(File.expand_path('~root/.ssh/ssh_wrapper_2089348824')).with_content(%Q{#!/bin/sh\n/usr/bin/env ssh -o "StrictHostKeyChecking=no" -i "#{File.expand_path('~root/.ssh/id_deploy_2089348824')}" $@\n}) }
41
+
42
+ context 'with a local path to a deploy key' do
43
+ recipe do
44
+ application_git '/test' do
45
+ user 'root'
46
+ repository 'https://example.com/test.git'
47
+ revision 'd44ec06d0b2a87732e91c005ed2048c824fd63ed'
48
+ deploy_key '/etc/key'
49
+ end
50
+ end
51
+
52
+ it { is_expected.to sync_application_git('/test').with(repository: 'https://example.com/test.git', revision: 'd44ec06d0b2a87732e91c005ed2048c824fd63ed', deploy_key: '/etc/key', ssh_wrapper: File.expand_path('~root/.ssh/ssh_wrapper_2089348824')) }
53
+ it { is_expected.to render_file(File.expand_path('~root/.ssh/ssh_wrapper_2089348824')).with_content(%Q{#!/bin/sh\n/usr/bin/env ssh -o "StrictHostKeyChecking=no" -i "/etc/key" $@\n}) }
54
+ it { expect(chef_run.application_git('/test').to_text).to include 'deploy_key "/etc/key"' }
55
+ end # /context with a local path to a deploy key
56
+
57
+ context 'with strict SSH' do
58
+ recipe do
59
+ application_git '/test' do
60
+ user 'root'
61
+ repository 'https://example.com/test.git'
62
+ revision 'd44ec06d0b2a87732e91c005ed2048c824fd63ed'
63
+ deploy_key 'secretkey'
64
+ strict_ssh true
65
+ end
66
+ end
67
+
68
+ it { is_expected.to sync_application_git('/test').with(repository: 'https://example.com/test.git', revision: 'd44ec06d0b2a87732e91c005ed2048c824fd63ed', deploy_key: 'secretkey', ssh_wrapper: File.expand_path('~root/.ssh/ssh_wrapper_2089348824')) }
69
+ it { is_expected.to render_file(File.expand_path('~root/.ssh/ssh_wrapper_2089348824')).with_content(%Q{#!/bin/sh\n/usr/bin/env ssh -i "#{File.expand_path('~root/.ssh/id_deploy_2089348824')}" $@\n}) }
70
+ it { expect(chef_run.application_git('/test').to_text).to include 'deploy_key "suppressed sensitive value"' }
71
+ end # /context with strict SSH
72
+
73
+ context 'with an application path' do
74
+ recipe do
75
+ application '/app' do
76
+ application_git 'https://example.com/test.git' do
77
+ revision 'd44ec06d0b2a87732e91c005ed2048c824fd63ed'
78
+ end
79
+ end
80
+ end
81
+
82
+ it { is_expected.to sync_application_git('https://example.com/test.git').with(destination: '/app', repository: 'https://example.com/test.git', revision: 'd44ec06d0b2a87732e91c005ed2048c824fd63ed') }
83
+ end # /context with an application path
84
+
85
+ context 'with a short name' do
86
+ before do
87
+ expect_any_instance_of(PoiseApplicationGit::Provider).to receive(:remote_resolve_reference) {|instance| instance.new_resource.revision }
88
+ end
89
+ recipe do
90
+ application '/app' do
91
+ application_git 'https://example.com/test.git'
92
+ end
93
+ end
94
+
95
+ it { is_expected.to sync_application_git('https://example.com/test.git').with(destination: '/app', repository: 'https://example.com/test.git', revision: 'HEAD') }
96
+ end # /context with a short name
97
+ end
@@ -0,0 +1,18 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'poise_boiler/spec_helper'
18
+ require 'poise_application_git'
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: poise-application-git
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Noah Kantrowitz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: halite
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: poise
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: poise-application
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: poise-boiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ description: A plugin for poise-application to deploy applications from git.
70
+ email:
71
+ - noah@coderanger.net
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".kitchen.travis.yml"
78
+ - ".kitchen.yml"
79
+ - ".travis.yml"
80
+ - ".yardopts"
81
+ - Berksfile
82
+ - CHANGELOG.md
83
+ - Gemfile
84
+ - LICENSE
85
+ - README.md
86
+ - Rakefile
87
+ - SUPPORTERS.md
88
+ - lib/poise-application-git.rb
89
+ - lib/poise_application_git.rb
90
+ - lib/poise_application_git/cheftie.rb
91
+ - lib/poise_application_git/resource.rb
92
+ - lib/poise_application_git/safe_string.rb
93
+ - lib/poise_application_git/version.rb
94
+ - poise-application-git.gemspec
95
+ - test/cookbooks/application_git_test/metadata.rb
96
+ - test/cookbooks/application_git_test/recipes/default.rb
97
+ - test/docker/docker.ca
98
+ - test/docker/docker.pem
99
+ - test/gemfiles/chef-12.gemfile
100
+ - test/gemfiles/master.gemfile
101
+ - test/integration/default/serverspec/default_spec.rb
102
+ - test/spec/resource_spec.rb
103
+ - test/spec/spec_helper.rb
104
+ homepage: https://github.com/poise/application_git
105
+ licenses:
106
+ - Apache 2.0
107
+ metadata:
108
+ halite_name: application_git
109
+ halite_dependencies: git
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.8
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: A plugin for poise-application to deploy applications from git.
130
+ test_files:
131
+ - test/cookbooks/application_git_test/metadata.rb
132
+ - test/cookbooks/application_git_test/recipes/default.rb
133
+ - test/docker/docker.ca
134
+ - test/docker/docker.pem
135
+ - test/gemfiles/chef-12.gemfile
136
+ - test/gemfiles/master.gemfile
137
+ - test/integration/default/serverspec/default_spec.rb
138
+ - test/spec/resource_spec.rb
139
+ - test/spec/spec_helper.rb
140
+ has_rdoc: