poise-git 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.kitchen.yml +3 -0
  4. data/.travis.yml +54 -0
  5. data/.yardopts +7 -0
  6. data/CHANGELOG.md +5 -0
  7. data/Gemfile +36 -0
  8. data/LICENSE +201 -0
  9. data/README.md +151 -0
  10. data/Rakefile +17 -0
  11. data/chef/attributes/default.rb +26 -0
  12. data/chef/recipes/default.rb +22 -0
  13. data/lib/poise_git.rb +24 -0
  14. data/lib/poise_git/cheftie.rb +18 -0
  15. data/lib/poise_git/git_client_providers.rb +36 -0
  16. data/lib/poise_git/git_client_providers/base.rb +93 -0
  17. data/lib/poise_git/git_client_providers/dummy.rb +79 -0
  18. data/lib/poise_git/git_client_providers/system.rb +73 -0
  19. data/lib/poise_git/git_command_mixin.rb +37 -0
  20. data/lib/poise_git/resources.rb +27 -0
  21. data/lib/poise_git/resources/poise_git.rb +252 -0
  22. data/lib/poise_git/resources/poise_git_client.rb +82 -0
  23. data/lib/poise_git/safe_string.rb +25 -0
  24. data/lib/poise_git/version.rb +20 -0
  25. data/poise-git.gemspec +42 -0
  26. data/test/cookbook/metadata.rb +18 -0
  27. data/test/cookbook/recipes/default.rb +96 -0
  28. data/test/gemfiles/chef-12.1.gemfile +23 -0
  29. data/test/gemfiles/chef-12.10.gemfile +23 -0
  30. data/test/gemfiles/chef-12.11.gemfile +23 -0
  31. data/test/gemfiles/chef-12.12.gemfile +22 -0
  32. data/test/gemfiles/chef-12.13.gemfile +22 -0
  33. data/test/gemfiles/chef-12.14.gemfile +19 -0
  34. data/test/gemfiles/chef-12.15.gemfile +19 -0
  35. data/test/gemfiles/chef-12.16.gemfile +19 -0
  36. data/test/gemfiles/chef-12.17.gemfile +19 -0
  37. data/test/gemfiles/chef-12.18.gemfile +19 -0
  38. data/test/gemfiles/chef-12.19.gemfile +19 -0
  39. data/test/gemfiles/chef-12.2.gemfile +23 -0
  40. data/test/gemfiles/chef-12.3.gemfile +23 -0
  41. data/test/gemfiles/chef-12.4.gemfile +24 -0
  42. data/test/gemfiles/chef-12.5.gemfile +23 -0
  43. data/test/gemfiles/chef-12.6.gemfile +23 -0
  44. data/test/gemfiles/chef-12.7.gemfile +23 -0
  45. data/test/gemfiles/chef-12.8.gemfile +23 -0
  46. data/test/gemfiles/chef-12.9.gemfile +23 -0
  47. data/test/gemfiles/chef-12.gemfile +19 -0
  48. data/test/gemfiles/master.gemfile +25 -0
  49. data/test/integration/default/serverspec/default_spec.rb +49 -0
  50. data/test/spec/git_client_providers/dummy_spec.rb +76 -0
  51. data/test/spec/git_client_providers/system_spec.rb +64 -0
  52. data/test/spec/recipe_spec.rb +35 -0
  53. data/test/spec/resources/poise_git_client.rb +64 -0
  54. data/test/spec/resources/poise_git_spec.rb +153 -0
  55. data/test/spec/spec_helper.rb +19 -0
  56. metadata +208 -0
@@ -0,0 +1,252 @@
1
+ #
2
+ # Copyright 2015-2017, 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 'shellwords'
18
+ require 'zlib'
19
+
20
+ require 'chef/provider/git'
21
+ require 'chef/resource/git'
22
+ require 'poise'
23
+
24
+ require 'poise_git/git_command_mixin'
25
+ require 'poise_git/safe_string'
26
+
27
+
28
+ module PoiseGit
29
+ module Resources
30
+ # (see PoiseGit::Resource)
31
+ # @since 1.0.0
32
+ module PoiseGit
33
+ # A `poise_git` resource to manage Python installations using pip.
34
+ #
35
+ # @provides poise_git
36
+ # @action checkout
37
+ # @action export
38
+ # @action sync
39
+ # @example
40
+ # poise_git '/srv/myapp' do
41
+ # repository 'https://...'
42
+ # deploy_key data_bag_item('deploy_keys', 'myapp')['key']
43
+ # end
44
+ class Resource < Chef::Resource::Git
45
+ include Poise
46
+ include ::PoiseGit::GitCommandMixin
47
+ provides(:poise_git)
48
+ # Manually create matchers because #actions is unreliable.
49
+ %i{checkout export sync}.each do |action|
50
+ Poise::Helpers::ChefspecMatchers.create_matcher(:poise_git, action)
51
+ end
52
+
53
+ # @api private
54
+ def initialize(*args)
55
+ super
56
+ # Because the superclass declares this, we have to as well. Should be
57
+ # removable at some point when Chef makes everything use the provider
58
+ # resolver system instead.
59
+ @resource_name = :poise_git if defined?(@resource_name) && @resource_name
60
+ @provider = ::PoiseGit::Resources::PoiseGit::Provider if defined?(@provider) && @provider
61
+ end
62
+
63
+ # @!attribute strict_ssh
64
+ # Enable strict SSH host key checking. Defaults to false.
65
+ # @return [Boolean]
66
+ attribute(:strict_ssh, equal_to: [true, false], default: false)
67
+
68
+ # @!attribute deploy_key
69
+ # SSH deploy key as either a string value or a path to a key file.
70
+ # @return [String]
71
+ def deploy_key(val=nil)
72
+ # Use a SafeString for literal deploy keys so they aren't shown.
73
+ val = SafeString.new(val) if val && !deploy_key_is_local?(val)
74
+ set_or_return(:deploy_key, val, kind_of: String)
75
+ end
76
+
77
+ # Default SSH wrapper path.
78
+ #
79
+ # @api private
80
+ # @return [String]
81
+ def ssh_wrapper_path
82
+ @ssh_wrapper_path ||= "#{Chef::Config[:file_cache_path]}/poise_git_wrapper_#{Zlib.crc32(name)}"
83
+ end
84
+
85
+ # Guess if the deploy key is a local path or literal value.
86
+ #
87
+ # @api private
88
+ # @param key [String, nil] Key value to check. Defaults to self.key.
89
+ # @return [Boolean]
90
+ def deploy_key_is_local?(key=nil)
91
+ key ||= deploy_key
92
+ # Try to be mindful of Windows-y paths here even though they almost
93
+ # certainly won't actually work later on with ssh.
94
+ key && key =~ /\A(\/|[a-zA-Z]:)/
95
+ end
96
+
97
+ # Path to deploy key.
98
+ #
99
+ # @api private
100
+ # @return [String]
101
+ def deploy_key_path
102
+ @deploy_key_path ||= if deploy_key_is_local?
103
+ deploy_key
104
+ else
105
+ "#{Chef::Config[:file_cache_path]}/poise_git_deploy_#{Zlib.crc32(name)}"
106
+ end
107
+ end
108
+
109
+ # Hook to force the git install via recipe if needed.
110
+ def after_created
111
+ if !parent_git && node['poise-git']['default_recipe']
112
+ # Use the default recipe to give us a parent the next time we ask.
113
+ run_context.include_recipe(node['poise-git']['default_recipe'])
114
+ # Force it to re-expand the cache next time.
115
+ @parent_git = nil
116
+ end
117
+ super
118
+ end
119
+
120
+ end
121
+
122
+ # The default provider for the `poise_git` resource.
123
+ #
124
+ # @see Resource
125
+ class Provider < Chef::Provider::Git
126
+ include Poise
127
+ include ::PoiseGit::GitCommandMixin
128
+ provides(:poise_git)
129
+
130
+ # @api private
131
+ def initialize(*args)
132
+ super
133
+ # Set the SSH wrapper path in a late-binding kind of way. This better
134
+ # supports situations where the user doesn't exist until Chef converges.
135
+ new_resource.ssh_wrapper(new_resource.ssh_wrapper_path) if new_resource.deploy_key
136
+ end
137
+
138
+ # Hack our special login in before load_current_resource runs because that
139
+ # needs access to the git remote.
140
+ #
141
+ # @api private
142
+ def load_current_resource
143
+ create_deploy_key if new_resource.deploy_key
144
+ super
145
+ end
146
+
147
+ # Like {#load_current_resource}, make sure git is installed since we might
148
+ # need it depending on the version of Chef.
149
+ #
150
+ # @api private
151
+ def define_resource_requirements
152
+ create_deploy_key if new_resource.deploy_key
153
+ super
154
+ end
155
+
156
+ private
157
+
158
+ # Install git and set up the deploy key if needed. Safe to call multiple
159
+ # times if needed.
160
+ #
161
+ # @api private
162
+ # @return [void]
163
+ def create_deploy_key
164
+ return if @create_deploy_key
165
+ Chef::Log.debug("[#{new_resource}] Creating deploy key")
166
+ old_why_run = Chef::Config[:why_run]
167
+ begin
168
+ # Forcibly disable why run support so these will always run, since
169
+ # we need to be able to talk to the git remote even just for the
170
+ # whyrun checks.
171
+ Chef::Config[:why_run] = false
172
+ notifying_block do
173
+ write_deploy_key
174
+ write_ssh_wrapper
175
+ end
176
+ ensure
177
+ Chef::Config[:why_run] = old_why_run
178
+ end
179
+ @create_deploy_key = true
180
+ end
181
+
182
+ # Copy the deploy key to a file if needed.
183
+ #
184
+ # @api private
185
+ # @return [void]
186
+ def write_deploy_key
187
+ # Check if we have a local path or some actual content
188
+ return if new_resource.deploy_key_is_local?
189
+ file new_resource.deploy_key_path do
190
+ owner new_resource.user
191
+ group new_resource.group
192
+ mode '600'
193
+ content new_resource.deploy_key
194
+ sensitive true
195
+ end
196
+ end
197
+
198
+ # Create the SSH wrapper script.
199
+ #
200
+ # @api private
201
+ # @return [void]
202
+ def write_ssh_wrapper
203
+ # Write out the GIT_SSH script, it should already be enabled above
204
+ file new_resource.ssh_wrapper_path do
205
+ owner new_resource.user
206
+ group new_resource.group
207
+ mode '700'
208
+ content %Q{#!/bin/sh\n/usr/bin/env ssh #{'-o "StrictHostKeyChecking=no" ' unless new_resource.strict_ssh}-i "#{new_resource.deploy_key_path}" $@\n}
209
+ end
210
+ end
211
+
212
+ # Patch back in the `#git` from the git provider. This otherwise conflicts
213
+ # with the `#git` defined by the DSL, which gets included in such a way
214
+ # that the DSL takes priority.
215
+ #
216
+ # @api private
217
+ def git(*args, &block)
218
+ self.class.superclass.instance_method(:git).bind(self).call(*args, &block)
219
+ end
220
+
221
+ # Trick all shell_out related things in the base class in to using
222
+ # my git_shell_out instead.
223
+ #
224
+ # @api private
225
+ def shell_out(*cmd, **options)
226
+ if @shell_out_hack_inner
227
+ # This is the real call.
228
+ super
229
+ else
230
+ # This ia call we want to intercept and send to our method.
231
+ begin
232
+ @shell_out_hack_inner = true
233
+ # Remove nils and flatten for compat with how core uses this method.
234
+ cmd.compact!
235
+ cmd.flatten!
236
+ # Reparse the command to get a clean array.
237
+ cmd = Shellwords.split(cmd.join(' '))
238
+ # We'll add the git command back in ourselves.
239
+ cmd.shift if cmd.first == 'git'
240
+ # Push the yak stack.
241
+ git_shell_out(*cmd, **options)
242
+ ensure
243
+ @shell_out_hack_inner = false
244
+ end
245
+ end
246
+ end
247
+
248
+ end
249
+
250
+ end
251
+ end
252
+ end
@@ -0,0 +1,82 @@
1
+ #
2
+ # Copyright 2017, 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 'chef/resource'
18
+ require 'poise'
19
+
20
+
21
+ module PoiseGit
22
+ module Resources
23
+ # (see PoiseGitClient::Resource)
24
+ # @since 1.0.0
25
+ module PoiseGitClient
26
+ # A `poise_git_client` resource to install a C compiler and build tools.
27
+ #
28
+ # @provides poise_git_client
29
+ # @action install
30
+ # @action uninstall
31
+ # @example
32
+ # poise_git_client 'git'
33
+ class Resource < Chef::Resource
34
+ include Poise(inversion: true, container: true)
35
+ provides(:poise_git_client)
36
+ actions(:install, :uninstall)
37
+
38
+ # @!attribute version
39
+ # Version of Git to install. The version is prefix-matched so `'2'`
40
+ # will install the most recent Git 2.x, and so on.
41
+ # @return [String]
42
+ # @example Install any version
43
+ # poise_git_client 'any' do
44
+ # version ''
45
+ # end
46
+ # @example Install Git 2
47
+ # poise_git_client '2'
48
+ attribute(:version, kind_of: String, default: lazy { default_version })
49
+
50
+ # The path to the `git` binary for this Git installation. This is
51
+ # an output property.
52
+ #
53
+ # @return [String]
54
+ # @example
55
+ # execute "#{resources('poise_git_client[git]').git_binary} init"
56
+ def git_binary
57
+ provider_for_action(:git_binary).git_binary
58
+ end
59
+
60
+ # The environment variables for this Git installation. This is an
61
+ # output property.
62
+ #
63
+ # @return [Hash<String, String>]
64
+ def git_environment
65
+ provider_for_action(:git_environment).git_environment
66
+ end
67
+
68
+ private
69
+
70
+ # Default value for the version property. Trims an optional `git-` from
71
+ # the resource name.
72
+ #
73
+ # @return [String]
74
+ def default_version
75
+ name[/^(git-?)?(.*)$/, 2] || ''
76
+ end
77
+ end
78
+
79
+ # Providers can be found under git_client_providers/.
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ # Copyright 2015-2017, 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
+
18
+ module PoiseGit
19
+ # A string that won't be shown in Chef error output
20
+ class SafeString < String
21
+ def to_text
22
+ '"suppressed sensitive value"'
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ #
2
+ # Copyright 2015-2017, 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
+
18
+ module PoiseGit
19
+ VERSION = '1.0.0'
20
+ end
@@ -0,0 +1,42 @@
1
+ #
2
+ # Copyright 2015-2017, 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
+ lib = File.expand_path('../lib', __FILE__)
18
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
19
+ require 'poise_git/version'
20
+
21
+ Gem::Specification.new do |spec|
22
+ spec.name = 'poise-git'
23
+ spec.version = PoiseGit::VERSION
24
+ spec.authors = ['Noah Kantrowitz']
25
+ spec.email = %w{noah@coderanger.net}
26
+ spec.description = 'A Chef cookbook for installing and using Git.'
27
+ spec.summary = spec.description
28
+ spec.homepage = 'https://github.com/poise/poise-git'
29
+ spec.license = 'Apache 2.0'
30
+
31
+ spec.files = `git ls-files`.split($/)
32
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
33
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
34
+ spec.require_paths = %w{lib}
35
+
36
+ spec.add_dependency 'chef', '>= 12.1', '< 14'
37
+ spec.add_dependency 'halite', '~> 1.1'
38
+ spec.add_dependency 'poise', '~> 2.6'
39
+ spec.add_dependency 'poise-languages', '~> 2.1'
40
+
41
+ spec.add_development_dependency 'poise-boiler', '~> 1.6'
42
+ end
@@ -0,0 +1,18 @@
1
+ #
2
+ # Copyright 2017, 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
+ name 'poise-git_test'
18
+ depends 'poise-git'
@@ -0,0 +1,96 @@
1
+ #
2
+ # Copyright 2017, 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
+ # Test SSH deploy key. Go ahead and scrape it, won't get you much.
18
+ # Pubkey ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCk2Y0Vj3oWr5oyo2ekL0V7Tj9/vNBjH6AiO/zfIc+7dR1KaCeCkx5GRhP/XxaiSn3Fxl1JSpBswd+Oue9SJ16nuQ2eUrK5zzN+GRsz4DfqvczmDLGHrlND3FpE+GbCMbmXObYoki9LuysrYVWfye4Rc5ICm+rSqtD+QB8rUguqXKu9tVVx9ug22P5s5OxcTCOZRJsz4U++64coD8X3P++6icGemXZDUUR5B2oWoMzXafbOC1Oo0aStAxEew/kfs3hFmdfmMdC9KAilqPxY1LtqHhMB0rdqynaAc4r1HKoSbAGdcwrJgd2TV8eoB25ydvzZwnOhLdO5Cm8Od63ovEUR
19
+ DEPLOY_KEY = <<-EOH
20
+ -----BEGIN RSA PRIVATE KEY-----
21
+ MIIEowIBAAKCAQEApNmNFY96Fq+aMqNnpC9Fe04/f7zQYx+gIjv83yHPu3UdSmgn
22
+ gpMeRkYT/18Wokp9xcZdSUqQbMHfjrnvUidep7kNnlKyuc8zfhkbM+A36r3M5gyx
23
+ h65TQ9xaRPhmwjG5lzm2KJIvS7srK2FVn8nuEXOSApvq0qrQ/kAfK1ILqlyrvbVV
24
+ cfboNtj+bOTsXEwjmUSbM+FPvuuHKA/F9z/vuonBnpl2Q1FEeQdqFqDM12n2zgtT
25
+ qNGkrQMRHsP5H7N4RZnX5jHQvSgIpaj8WNS7ah4TAdK3asp2gHOK9RyqEmwBnXMK
26
+ yYHdk1fHqAducnb82cJzoS3TuQpvDnet6LxFEQIDAQABAoIBAHkim/fB7LcK5sZb
27
+ KOePDQGk6ChXeNG+BY/igNj+IYXgc1uf2Zirvs1o5Xz8RMeQ8YcJUrduoV4pwLtC
28
+ ikfWQkoBQ66ZmlfLmE0K6eBe3PgT7KMHpNTNFsaA/5w65FfC7lvfvqllcne12+0O
29
+ ozq9ycDtKdfc9ttDRjvupnjQ212deUmpg6BG8rR9dx87Rwbk2/l+dCiSafl4HN5N
30
+ LbrENL7K3j+XVA2DKEVsrCstJzaFgqflcsnrDX76M9TEx1MtowM3Ec3jcT9W1FX1
31
+ /Rizmyow4ZV56QVz1+U13N7j0tW4EJl9EQnUye7UXyoSKfDOAGkZEKeztephBwZQ
32
+ WBgnBLkCgYEA1FmUBv7gBnVRtpfDF+qefhgT9O/ANBh0W4m6mAzawle+TleZ1vsJ
33
+ 1oKG6XcSQQiRRnKdcAakxSmIw5LK54hlMczy9l5GHRQozYrbdsGUzTgYHcmThr6v
34
+ V4b7c+OxmfeV3vae07GHeXUPttzHDKXBdQqZaTaax5y8bjAflmRYNbcCgYEAxrxj
35
+ 1SSwOlTXB+PVaHUPTe4AvrliCxjs9PV4O1f8oMbZ97avvNrtBNroYvukLfQNrnfF
36
+ 0fIdm/BDOgAnD5I9bwbOuRqvLidzHik9KM33mpmC/4fRI5lFzMv0yd4S/dpJbGql
37
+ FQvZKGGGc8h4NXiXdSqCqr+axJdBRRL+2PJ3G3cCgYB4jZpiFlRsljIbrTDO5R2x
38
+ jE3YIjxF1xRH23sZU0LmThX2N/lYeRBuvY+F/1lXnluLWQpUTRFB9YB1N2MF6wM4
39
+ MJhGkeLQI1++wPQzCVdG4m+eiY+9UYgN8s3STxPGyy5EdFJa8FBu/aw8Lj66yWd4
40
+ 4NmTR7K7XBoFnEByiukhJQKBgQCb//2NrkL3RumUM++tE1Z0IcNL81FWzLYUgyth
41
+ yetweSdYH3tLj75F9WA9crKpr82dij8qUheT9MGQodYHjw/SO1HCU4P3gtgGcPCl
42
+ OyiFnsMJup8chpAX9nGslDnsMpE4HW6AWtCXthZIhLB3qLWbL0dqqQTgFKsTgZmy
43
+ yoFceQKBgBcNNGTOjzW+J7lfC+AY+XUPhZQAUJi47+m0Tbrp5j/1BDuvI6WTlsIr
44
+ 7WMFJM91xqHQZK7D0zjbGa42+uwlCs+ZBolNZpW2K7dNAriBjHuD3VDhlkqZrPC2
45
+ EwOhBYydRkzoALbgESjKP3VwfIVr9tWs4CyndY81uqRbgiRqdzR4
46
+ -----END RSA PRIVATE KEY-----
47
+ EOH
48
+
49
+ # Base case test.
50
+ poise_git '/test1' do
51
+ repository 'https://github.com/poise/test_repo.git'
52
+ revision 'master'
53
+ end
54
+
55
+ # Test using a branch just to make sure I didn't break that.
56
+ poise_git '/test2' do
57
+ repository 'https://github.com/poise/test_repo.git'
58
+ revision 'release'
59
+ end
60
+
61
+ # Test using an inline string value for the deploy key.
62
+ poise_git '/test3' do
63
+ repository 'git@github.com:coderanger/private_test_repo.git'
64
+ revision 'master'
65
+ deploy_key DEPLOY_KEY
66
+ end
67
+
68
+ # Test using a file path for the deploy key.
69
+ file '/test4.key' do
70
+ content DEPLOY_KEY
71
+ mode '600'
72
+ sensitive true
73
+ end
74
+
75
+ poise_git '/test4' do
76
+ repository 'git@github.com:coderanger/private_test_repo.git'
77
+ revision 'release'
78
+ deploy_key '/test4.key'
79
+ end
80
+
81
+ # Test deploying as a non-root user.
82
+ user 'poise' do
83
+ system true
84
+ end
85
+
86
+ directory '/test5' do
87
+ mode '777'
88
+ owner 'poise'
89
+ end
90
+
91
+ poise_git '/test5' do
92
+ repository 'git@github.com:coderanger/private_test_repo.git'
93
+ revision 'master'
94
+ deploy_key DEPLOY_KEY
95
+ user 'poise'
96
+ end