r10k 3.2.1 → 3.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 975a72d1fc4846986b4cb47f8f3a1b2e1a74d69e
4
- data.tar.gz: 2ff84a7c70d6282b83b48400299507532f57c520
3
+ metadata.gz: 469f2e9b11b47308ab7db4315070fbd65b7d1ed1
4
+ data.tar.gz: 24a53e3495eb9a71b72817f753193559987006ef
5
5
  SHA512:
6
- metadata.gz: 64e6faee87cc61490d08d197c2f96b5c2f700027e83de9383c628b2fe77fa12fc2717d6b9dfa8c1e239c89ad2530d88e675bb421efaff308f384a499fb11cb28
7
- data.tar.gz: a74bc080bfe5e61eb0f36ee5da57937fd667ef909a35f582bab5d101ae1b252abf1241d0f23957690277ec7200b037f27f2de72800ee26eb0ee08c47a7bb8c01
6
+ metadata.gz: f71876396b64988ba115940dea265b5469f8cd13ae37d34bd7cbbca218aa7392966289c226266d23600e02e2c3fdfb745c9648cd0ccb5cf57e7053070db12bf2
7
+ data.tar.gz: f3182e61bab12374beec84a535fa2c4d55299d7cc46357bad637a252b50f29f28bd6dfde2af7630d9d5a00273f96b66c6f387963471a017e9795527979a5c835
@@ -145,11 +145,24 @@ module R10K
145
145
  end
146
146
 
147
147
  def write_environment_info!(environment, started_at, success)
148
+ module_deploys = []
149
+ begin
150
+ environment.puppetfile.modules.each do |mod|
151
+ name = mod.name
152
+ version = mod.version
153
+ sha = mod.repo.head rescue nil
154
+ module_deploys.push({:name => name, :version => version, :sha => sha})
155
+ end
156
+ rescue
157
+ logger.debug("Unable to get environment module deploy data for .r10k-deploy.json at #{environment.path}")
158
+ end
159
+
148
160
  File.open("#{environment.path}/.r10k-deploy.json", 'w') do |f|
149
161
  deploy_info = environment.info.merge({
150
162
  :started_at => started_at,
151
163
  :finished_at => Time.new,
152
164
  :deploy_success => success,
165
+ :module_deploys => module_deploys,
153
166
  })
154
167
 
155
168
  f.puts(JSON.pretty_generate(deploy_info))
@@ -1,3 +1,3 @@
1
1
  module R10K
2
- VERSION = '3.2.1'
2
+ VERSION = '3.2.3'
3
3
  end
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
37
37
  s.add_development_dependency 'rake'
38
38
 
39
39
  s.add_development_dependency 'yard', '~> 0.9.11'
40
- s.add_development_dependency 'minitar', '~> 0.6.1'
40
+ s.add_development_dependency 'minitar', '~> 0.9.0'
41
41
 
42
42
  s.files = %x[git ls-files].split($/)
43
43
  s.require_path = 'lib'
@@ -332,4 +332,63 @@ describe R10K::Action::Deploy::Environment do
332
332
  end
333
333
  end
334
334
  end
335
+
336
+ describe "write_environment_info!" do
337
+
338
+ class Fake_Environment
339
+ attr_accessor :path
340
+ attr_accessor :puppetfile
341
+ attr_accessor :info
342
+
343
+ def initialize(path, info)
344
+ @path = path
345
+ @info = info
346
+ @puppetfile = R10K::Puppetfile.new
347
+ end
348
+ end
349
+
350
+ let(:mock_stateful_repo_1) { instance_double("R10K::Git::StatefulRepository", :head => "123456") }
351
+ let(:mock_stateful_repo_2) { instance_double("R10K::Git::StatefulRepository", :head => "654321") }
352
+ let(:mock_git_module_1) { instance_double("R10K::Module::Git", :name => "my_cool_module", :version => "1.0", :repo => mock_stateful_repo_1) }
353
+ let(:mock_git_module_2) { instance_double("R10K::Module::Git", :name => "my_lame_module", :version => "0.0.1", :repo => mock_stateful_repo_2) }
354
+ let(:mock_forge_module_1) { double(:name => "their_shiny_module", :version => "2.0.0") }
355
+ let(:mock_puppetfile) { instance_double("R10K::Puppetfile", :modules => [mock_git_module_1, mock_git_module_2, mock_forge_module_1]) }
356
+
357
+ before(:all) do
358
+ @tmp_path = "./tmp-r10k-test-dir/"
359
+ Dir.mkdir(@tmp_path) unless File.exists?(@tmp_path)
360
+ end
361
+
362
+ after(:all) do
363
+ File.delete("#{@tmp_path}/.r10k-deploy.json")
364
+ Dir.delete(@tmp_path)
365
+ end
366
+
367
+ it "writes the .r10k-deploy file correctly" do
368
+ allow(R10K::Puppetfile).to receive(:new).and_return(mock_puppetfile)
369
+ allow(mock_forge_module_1).to receive(:repo).and_raise(NoMethodError)
370
+
371
+ fake_env = Fake_Environment.new(@tmp_path, {:name => "my_cool_environment", :signature => "pablo picasso"})
372
+ subject.send(:write_environment_info!, fake_env, "2019-01-01 23:23:22 +0000", true)
373
+
374
+ file_contents = File.read("#{@tmp_path}/.r10k-deploy.json")
375
+ r10k_deploy = JSON.parse(file_contents)
376
+
377
+ expect(r10k_deploy['name']).to eq("my_cool_environment")
378
+ expect(r10k_deploy['signature']).to eq("pablo picasso")
379
+ expect(r10k_deploy['started_at']).to eq("2019-01-01 23:23:22 +0000")
380
+ expect(r10k_deploy['deploy_success']).to eq(true)
381
+ expect(r10k_deploy['module_deploys'].length).to eq(3)
382
+ expect(r10k_deploy['module_deploys'][0]['name']).to eq("my_cool_module")
383
+ expect(r10k_deploy['module_deploys'][0]['version']).to eq("1.0")
384
+ expect(r10k_deploy['module_deploys'][0]['sha']).to eq("123456")
385
+ expect(r10k_deploy['module_deploys'][1]['name']).to eq("my_lame_module")
386
+ expect(r10k_deploy['module_deploys'][1]['version']).to eq("0.0.1")
387
+ expect(r10k_deploy['module_deploys'][1]['sha']).to eq("654321")
388
+ expect(r10k_deploy['module_deploys'][2]['name']).to eq("their_shiny_module")
389
+ expect(r10k_deploy['module_deploys'][2]['version']).to eq("2.0.0")
390
+ expect(r10k_deploy['module_deploys'][2]['sha']).to eq(nil)
391
+
392
+ end
393
+ end
335
394
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r10k
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-17 00:00:00.000000000 Z
11
+ date: 2019-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.6.1
145
+ version: 0.9.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.6.1
152
+ version: 0.9.0
153
153
  description: |2
154
154
  R10K provides a general purpose toolset for deploying Puppet environments and modules.
155
155
  It implements the Puppetfile format and provides a native implementation of Puppet
@@ -235,7 +235,6 @@ files:
235
235
  - integration/tests/Puppetfile/HTTP_PROXY_affects_git_source.rb
236
236
  - integration/tests/README.mkd
237
237
  - integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb
238
- - integration/tests/basic_functionality/negative/attempt_to_install_peonly_module_without_license.rb
239
238
  - integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb
240
239
  - integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb
241
240
  - integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb
@@ -1,71 +0,0 @@
1
- require 'git_utils'
2
- require 'r10k_utils'
3
- require 'master_manipulator'
4
- test_name 'RK-158 - C92361 - Attempt to install a PE-only module with no license file'
5
-
6
- #Init
7
- env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
8
- r10k_fqp = get_r10k_fqp(master)
9
- master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
10
-
11
- git_repo_path = '/git_repos'
12
- git_repo_name = 'environments'
13
- git_control_remote = File.join(git_repo_path, "#{git_repo_name}.git")
14
- git_environments_path = '/root/environments'
15
- last_commit = git_last_commit(master, git_environments_path)
16
- git_provider = ENV['GIT_PROVIDER'] || 'shellgit'
17
-
18
- r10k_config_path = get_r10k_config_file_path(master)
19
- r10k_config_bak_path = "#{r10k_config_path}.bak"
20
-
21
- #In-line files
22
- r10k_conf = <<-CONF
23
- cachedir: '/var/cache/r10k'
24
- git:
25
- provider: '#{git_provider}'
26
- sources:
27
- control:
28
- basedir: "#{env_path}"
29
- remote: "#{git_control_remote}"
30
- CONF
31
-
32
- #Manifest
33
- site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
34
- site_pp = create_site_pp(master_certname, ' include peonly')
35
-
36
- # Verification
37
- error_message_regex = /You must have a valid Puppet Enterprise® license on this node in order to download ztr-peonly/
38
-
39
- #Teardown
40
- teardown do
41
- step 'Restore Original "r10k" Config'
42
- on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
43
-
44
- step 'cleanup r10k'
45
- clean_up_r10k(master, last_commit, git_environments_path)
46
- end
47
-
48
- #Setup
49
- step 'Stub the forge'
50
- stub_forge_on(master)
51
-
52
- step 'Backup a Valid "r10k" Config'
53
- on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
54
-
55
- step 'Update the "r10k" Config'
56
- create_remote_file(master, r10k_config_path, r10k_conf)
57
-
58
- step 'Inject New "site.pp" to the "production" Environment'
59
- inject_site_pp(master, site_pp_path, site_pp)
60
-
61
- step 'Copy Puppetfile to "production" Environment Git Repo'
62
- create_remote_file(master, "#{git_environments_path}/Puppetfile", 'mod "ztr-peonly"')
63
-
64
- step 'Push Changes'
65
- git_add_commit_push(master, 'production', 'add Puppetfile', git_environments_path)
66
-
67
- #Test
68
- step 'Deploy "production" Environment via r10k'
69
- on(master, "#{r10k_fqp} deploy environment -p", :acceptable_exit_codes => [0,1]) do |result|
70
- assert_match(error_message_regex, result.stderr, 'Expected error message was not observed!')
71
- end