r10k 2.5.2 → 2.5.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: eee7199351f477d257169a009b046e2230937312
4
- data.tar.gz: ea45b1df75cbdaa6cd72192f703db55b9061bb14
3
+ metadata.gz: c759d0c0834d72049d5a2757df623f61af4d8789
4
+ data.tar.gz: 4747b49041fefce181a3ef2cf54f5417261d403e
5
5
  SHA512:
6
- metadata.gz: c2ca4c25383eec5578394f412313b6e44b5204637b4ac05cd3943bf6526f9e6fca11b6fc23e7961cd630a39133d97d92edd5488627c83af3f78aa443a3833f37
7
- data.tar.gz: 99e145a3c22b4bbc7523523800a610e13fed13b46b8c09624c822aeaa774d7f22569752ad337b90d01ac5a5297c7f620d65217bc095da5411419018cc20ff633
6
+ metadata.gz: 6fc5a03488a7ec604f8f4042049aa739e64d34214818699e10fcbf649fc797cbfc054fdcd4c42c29a1664783660084000cdddbccc16eed59bc14fc6cb3ac9e4f
7
+ data.tar.gz: 0c4107408660301001ee41bbbbb951646aaabcdd5bb3232d4ce65bc7da536f24fff9e7deef328393cb81f9833fcff35a330b5d41305d318a13421b33f559e864
@@ -1,6 +1,22 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 2.5.3
5
+ -----
6
+
7
+ 2017/03/31
8
+
9
+ ### Bug Fixes
10
+
11
+ (#645) Fix undefined method error when r10.yaml empty
12
+
13
+ (#659)(RK-269) Puppetfile actions acknowledge :branch and :default_branch
14
+ (Thanks to [Chris Cowley](https://github.com/chriscowley) for the report.)
15
+
16
+ ### Changes
17
+
18
+ (PF-1317) Emit a warning when syncing a deprecated Forge module.
19
+
4
20
  2.5.2
5
21
  -----
6
22
 
@@ -6,7 +6,7 @@ be customized easily.
6
6
 
7
7
  This guide assumes that each of your modules is in a separate repository
8
8
  and that the `Puppetfile` is in its own repo called the
9
- [Control Repo](http://www.jeffmalnick.com/blog/2014/05/16/r10k-control-repos/).
9
+ [Control Repo](http://technoblogic.io/blog/2014/05/16/r10k-control-repos/).
10
10
  All module repos have a primary branch of *master* and the Control's primary
11
11
  branch is *production*. All changes are made through r10k and no user makes
12
12
  manual changes to the environments under **/etc/puppet**.
@@ -27,6 +27,11 @@ module R10K
27
27
 
28
28
  def visit_module(mod)
29
29
  logger.info _("Updating module %{mod_path}") % {mod_path: mod.path}
30
+
31
+ if mod.respond_to?(:desired_ref) && mod.desired_ref == :control_branch
32
+ logger.warn _("Cannot track control repo branch for content '%{name}' when not part of a 'deploy' action, will use default if available." % {name: mod.name})
33
+ end
34
+
30
35
  mod.sync(force: false) # Don't force sync for 'puppetfile install' RK-265
31
36
  end
32
37
 
@@ -43,6 +43,10 @@ class R10K::Module::Forge < R10K::Module::Base
43
43
  end
44
44
 
45
45
  def sync(opts={})
46
+ if deprecated?
47
+ logger.warn "Puppet Forge module '#{@v3_module.slug}' has been deprecated, visit https://forge.puppet.com/#{@v3_module.slug.tr('-','/')} for more information."
48
+ end
49
+
46
50
  case status
47
51
  when :absent
48
52
  install
@@ -88,6 +92,14 @@ class R10K::Module::Forge < R10K::Module::Base
88
92
  status == :insync
89
93
  end
90
94
 
95
+ def deprecated?
96
+ begin
97
+ !@v3_module.deprecated_at.nil?
98
+ rescue Faraday::ResourceNotFound => e
99
+ raise PuppetForge::ReleaseNotFound, _("The module %{title} does not exist on %{url}.") % {title: @title, url: PuppetForge::V3::Release.conn.url_prefix}, e.backtrace
100
+ end
101
+ end
102
+
91
103
  # Determine the status of the forge module.
92
104
  #
93
105
  # @return [Symbol] :absent If the directory doesn't exist
@@ -18,6 +18,11 @@ class R10K::Module::Git < R10K::Module::Base
18
18
  # @return [R10K::Git::StatefulRepository]
19
19
  attr_reader :repo
20
20
 
21
+ # @!attribute [r] desired_ref
22
+ # @api private
23
+ # @return [String]
24
+ attr_reader :desired_ref
25
+
21
26
  def initialize(title, dirname, args, environment=nil)
22
27
  super
23
28
 
@@ -50,16 +55,31 @@ class R10K::Module::Git < R10K::Module::Base
50
55
  private
51
56
 
52
57
  def validate_ref(desired, default)
53
- if desired && @repo.resolve(desired)
58
+ if desired && desired != :control_branch && @repo.resolve(desired)
54
59
  return desired
55
60
  elsif default && @repo.resolve(default)
56
61
  return default
57
62
  else
63
+ msg = ["Unable to manage Puppetfile content '%{name}':"]
64
+ vars = {name: @name}
65
+
66
+ if desired == :control_branch
67
+ msg << "Could not resolve control repo branch"
68
+ elsif desired
69
+ msg << "Could not resolve desired ref '%{desired}'"
70
+ vars[:desired] = desired
71
+ else
72
+ msg << "Could not determine desired ref"
73
+ end
74
+
58
75
  if default
59
- raise ArgumentError, _("Unable to manage Puppetfile content '%{name}': Could not resolve desired ref '%{desired}' or default ref '%{default}'") % {name: @name, desired: desired, default: default}
76
+ msg << "or resolve default ref '%{default}'"
77
+ vars[:default] = default
60
78
  else
61
- raise ArgumentError, _("Unable to manage Puppetfile content '%{name}': Could not resolve desired ref '%{desired}' and no default given") % {name: @name, desired: desired}
79
+ msg << "and no default provided"
62
80
  end
81
+
82
+ raise ArgumentError, _(msg.join(' ')) % vars
63
83
  end
64
84
  end
65
85
 
@@ -77,12 +97,8 @@ class R10K::Module::Git < R10K::Module::Base
77
97
  @desired_ref = ref_opts.find { |key| break options[key] if options.has_key?(key) } || 'master'
78
98
  @default_ref = options[:default_branch]
79
99
 
80
- if @desired_ref == :control_branch
81
- if @environment && @environment.respond_to?(:ref)
82
- @desired_ref = @environment.ref
83
- else
84
- raise ArgumentError, _("Cannot track control repo branch from Puppetfile in this context: environment is nil or did not provide a valid ref")
85
- end
100
+ if @desired_ref == :control_branch && @environment && @environment.respond_to?(:ref)
101
+ @desired_ref = @environment.ref
86
102
  end
87
103
  end
88
104
  end
@@ -69,6 +69,9 @@ module R10K
69
69
  raise ConfigError, _("Couldn't load config file: %{error_msg}") % {error_msg: e.message}
70
70
  end
71
71
 
72
+ if !contents
73
+ raise ConfigError, _("File exists at #{path} but doesn't contain any YAML") % {path: path}
74
+ end
72
75
  R10K::Util::SymbolizeKeys.symbolize_keys!(contents, true)
73
76
  contents
74
77
  end
@@ -1,3 +1,3 @@
1
1
  module R10K
2
- VERSION = '2.5.2'
2
+ VERSION = '2.5.3'
3
3
  end
@@ -2,6 +2,7 @@ require 'r10k/module/forge'
2
2
  require 'spec_helper'
3
3
 
4
4
  describe R10K::Module::Forge do
5
+ # TODO: make these *unit* tests not depend on a real module on the real Forge :(
5
6
 
6
7
  include_context 'fail on execution'
7
8
 
@@ -59,6 +60,21 @@ describe R10K::Module::Forge do
59
60
  end
60
61
  end
61
62
 
63
+ context "when a module is deprecated" do
64
+ subject { described_class.new('puppetlabs/corosync', fixture_modulepath, :latest) }
65
+
66
+ it "warns on sync" do
67
+ allow(subject).to receive(:install)
68
+
69
+ logger_dbl = double(Log4r::Logger)
70
+ allow_any_instance_of(described_class).to receive(:logger).and_return(logger_dbl)
71
+
72
+ expect(logger_dbl).to receive(:warn).with(/puppet forge module.*puppetlabs-corosync.*has been deprecated/i)
73
+
74
+ subject.sync
75
+ end
76
+ end
77
+
62
78
  describe '#expected_version' do
63
79
  it "returns an explicitly given expected version" do
64
80
  subject = described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0')
@@ -205,8 +205,35 @@ describe R10K::Module::Git do
205
205
  end
206
206
 
207
207
  context "when module does not belong to an environment" do
208
- it "raises appropriate error" do
209
- expect { test_module(branch: :control_branch) }.to raise_error(ArgumentError, /cannot track control.*environment is nil/i)
208
+ it "leaves desired_ref unchanged" do
209
+ mod = test_module(branch: :control_branch)
210
+ expect(mod.desired_ref).to eq(:control_branch)
211
+ end
212
+
213
+ context "when default ref is provided and resolvable" do
214
+ it "uses default ref" do
215
+ expect(mock_repo).to receive(:resolve).with('default').and_return('abc123')
216
+ mod = test_module({branch: :control_branch, default_branch: 'default'})
217
+
218
+ expect(mod.properties).to include(expected: 'default')
219
+ end
220
+ end
221
+
222
+ context "when default ref is provided and not resolvable" do
223
+ it "raises appropriate error" do
224
+ expect(mock_repo).to receive(:resolve).with('default').and_return(nil)
225
+ mod = test_module({branch: :control_branch, default_branch: 'default'})
226
+
227
+ expect { mod.properties }.to raise_error(ArgumentError, /unable to manage.*could not resolve control repo branch.*or resolve default/i)
228
+ end
229
+ end
230
+
231
+ context "when default ref is not provided" do
232
+ it "raises appropriate error" do
233
+ mod = test_module({branch: :control_branch})
234
+
235
+ expect { mod.properties }.to raise_error(ArgumentError, /unable to manage.*could not resolve control repo branch.*no default provided/i)
236
+ end
210
237
  end
211
238
  end
212
239
 
@@ -229,7 +256,7 @@ describe R10K::Module::Git do
229
256
  expect(mock_repo).to receive(:resolve).with('default').and_return(nil)
230
257
  mod = test_module({branch: :control_branch, default_branch: 'default'}, mock_env)
231
258
 
232
- expect { mod.properties }.to raise_error(ArgumentError, /unable to manage.*could not resolve desired.*or default/i)
259
+ expect { mod.properties }.to raise_error(ArgumentError, /unable to manage.*could not resolve desired.*or resolve default/i)
233
260
  end
234
261
  end
235
262
 
@@ -237,7 +264,7 @@ describe R10K::Module::Git do
237
264
  it "raises appropriate error" do
238
265
  mod = test_module({branch: :control_branch}, mock_env)
239
266
 
240
- expect { mod.properties }.to raise_error(ArgumentError, /unable to manage.*no default given/i)
267
+ expect { mod.properties }.to raise_error(ArgumentError, /unable to manage.*no default provided/i)
241
268
  end
242
269
  end
243
270
  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: 2.5.2
4
+ version: 2.5.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: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -538,9 +538,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
538
538
  version: '0'
539
539
  requirements: []
540
540
  rubyforge_project:
541
- rubygems_version: 2.6.8
541
+ rubygems_version: 2.2.5
542
542
  signing_key:
543
543
  specification_version: 4
544
544
  summary: Puppet environment and module deployment
545
545
  test_files: []
546
- has_rdoc: