puppet 3.0.0.rc7 → 3.0.0.rc8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

@@ -2,15 +2,15 @@
2
2
  packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master'
3
3
  packaging_repo: 'packaging'
4
4
  default_cow: 'base-squeeze-i386.cow'
5
- cows: 'base-lucid-amd64.cow base-lucid-i386.cow base-natty-amd64.cow base-natty-i386.cow base-oneiric-amd64.cow base-oneiric-i386.cow base-precise-amd64.cow base-precise-i386.cow base-sid-amd64.cow base-sid-i386.cow base-squeeze-amd64.cow base-squeeze-i386.cow base-testing-amd64.cow base-testing-i386.cow base-wheezy-i386.cow'
5
+ cows: 'base-lucid-i386.cow base-natty-i386.cow base-oneiric-i386.cow base-precise-i386.cow base-sid-i386.cow base-squeeze-i386.cow base-stable-i386.cow base-testing-i386.cow base-unstable-i386.cow base-wheezy-i386.cow'
6
6
  pbuild_conf: '/etc/pbuilderrc'
7
7
  packager: 'puppetlabs'
8
8
  gpg_name: 'info@puppetlabs.com'
9
9
  gpg_key: '4BD6EC30'
10
10
  sign_tar: FALSE
11
11
  # a space separated list of mock configs
12
- final_mocks: 'pl-5-i386 pl-5-x86_64 pl-6-i386 pl-6-x86_64 fedora-15-i386 fedora-15-x86_64 fedora-16-i386 fedora-16-x86_64 fedora-17-i386 fedora-17-x86_64'
13
- rc_mocks: 'pl-5-i386-dev pl-5-x86_64-dev pl-6-i386-dev pl-6-x86_64-dev fedora-15-i386-dev fedora-15-x86_64-dev fedora-16-i386-dev fedora-16-x86_64-dev fedora-17-i386-dev fedora-17-x86_64-dev'
12
+ final_mocks: 'pl-5-i386 pl-6-i386 fedora-15-i386 fedora-16-i386 fedora-17-i386'
13
+ rc_mocks: 'pl-5-i386-dev pl-6-i386-dev fedora-15-i386-dev fedora-16-i386-dev fedora-17-i386-dev'
14
14
  yum_host: 'burji.puppetlabs.com'
15
15
  yum_repo_path: '/opt/repository/yum/'
16
16
  build_gem: TRUE
@@ -8,4 +8,33 @@ class Puppet::DataBinding
8
8
 
9
9
  indirects(:data_binding, :terminus_setting => :data_binding_terminus,
10
10
  :doc => "Where to find external data bindings.")
11
+
12
+ # A class that acts just enough like a Puppet::Parser::Scope to
13
+ # fool Hiera's puppet backend. This class doesn't actually do anything
14
+ # but it does allow people to use the puppet backend with the hiera
15
+ # data bindings withough causing problems.
16
+ class Variables
17
+ FAKE_RESOURCE = Struct.new(:name).new("fake").freeze
18
+ FAKE_CATALOG = Struct.new(:classes).new([].freeze).freeze
19
+
20
+ def initialize(variable_bindings)
21
+ @variable_bindings = variable_bindings
22
+ end
23
+
24
+ def [](name)
25
+ @variable_bindings[name]
26
+ end
27
+
28
+ def resource
29
+ FAKE_RESOURCE
30
+ end
31
+
32
+ def catalog
33
+ FAKE_CATALOG
34
+ end
35
+
36
+ def function_include(name)
37
+ # noop
38
+ end
39
+ end
11
40
  end
@@ -1488,14 +1488,7 @@ database from within the Puppet Master process."
1488
1488
 
1489
1489
  # This doesn't actually work right now.
1490
1490
 
1491
- define_settings(
1492
- :parser,
1493
-
1494
- :lexical => {
1495
- :default => false,
1496
- :type => :boolean,
1497
- :desc => "Whether to use lexical scoping (vs. dynamic).",
1498
- },
1491
+ define_settings(:parser,
1499
1492
  :templatedir => {
1500
1493
  :default => "$vardir/templates",
1501
1494
  :type => :directory,
@@ -1503,8 +1496,7 @@ database from within the Puppet Master process."
1503
1496
  directories.",
1504
1497
  }
1505
1498
  )
1506
- define_settings(
1507
- :puppetdoc,
1499
+ define_settings(:puppetdoc,
1508
1500
  :document_all => {
1509
1501
  :default => false,
1510
1502
  :type => :boolean,
@@ -9,8 +9,7 @@ class Puppet::Indirector::Hiera < Puppet::Indirector::Terminus
9
9
  end
10
10
 
11
11
  def find(request)
12
- fake_scope = FakeScope.new(request.options[:facts])
13
- hiera.lookup(request.key, nil, fake_scope, nil, nil)
12
+ hiera.lookup(request.key, nil, request.options[:variables], nil, nil)
14
13
  end
15
14
 
16
15
  private
@@ -36,34 +35,5 @@ class Puppet::Indirector::Hiera < Puppet::Indirector::Terminus
36
35
  def hiera
37
36
  self.class.hiera
38
37
  end
39
-
40
- # A class that acts just enough like a Puppet::Parser::Scope to
41
- # fool Hiera's puppet backend. This class doesn't actually do anything
42
- # but it does allow people to use the puppet backend with the hiera
43
- # data bindings withough causing problems.
44
- class FakeScope
45
- FAKE_RESOURCE = Struct.new(:name).new("fake").freeze
46
- FAKE_CATALOG = Struct.new(:classes).new([].freeze).freeze
47
-
48
- def initialize(variable_bindings)
49
- @variable_bindings = variable_bindings
50
- end
51
-
52
- def [](name)
53
- @variable_bindings[name]
54
- end
55
-
56
- def resource
57
- FAKE_RESOURCE
58
- end
59
-
60
- def catalog
61
- FAKE_CATALOG
62
- end
63
-
64
- def function_include(name)
65
- # noop
66
- end
67
- end
68
38
  end
69
39
 
@@ -300,45 +300,56 @@ class Puppet::Resource
300
300
  [ type, title ].join('/')
301
301
  end
302
302
 
303
+ def missing_arguments
304
+ resource_type.arguments.select do |param, default|
305
+ param = param.to_sym
306
+ parameters[param].nil? || parameters[param].value == :undef
307
+ end
308
+ end
309
+ private :missing_arguments
310
+
311
+ # Consult external data bindings for class parameter values which must be
312
+ # namespaced in the backend.
313
+ #
314
+ # Example:
315
+ #
316
+ # class foo($port){ ... }
317
+ #
318
+ # We make a request to the backend for the key 'foo::port' not 'foo'
319
+ #
320
+ def lookup_external_default_for(param, scope)
321
+ if resource_type.type == :hostclass
322
+ Puppet::DataBinding.indirection.find(
323
+ "#{resource_type.name}::#{param}",
324
+ :environment => scope.environment.to_s,
325
+ :variables => Puppet::DataBinding::Variables.new(scope))
326
+ else
327
+ nil
328
+ end
329
+ end
330
+ private :lookup_external_default_for
331
+
303
332
  def set_default_parameters(scope)
304
333
  return [] unless resource_type and resource_type.respond_to?(:arguments)
305
334
 
306
- result = []
307
-
308
- resource_type.arguments.each do |param, default|
309
- param = param.to_sym
310
- next if parameters.include?(param)
311
- unless is_a?(Puppet::Parser::Resource)
312
- fail Puppet::DevError, "Cannot evaluate default parameters for #{self} - not a parser resource"
313
- end
335
+ unless is_a?(Puppet::Parser::Resource)
336
+ fail Puppet::DevError, "Cannot evaluate default parameters for #{self} - not a parser resource"
337
+ end
314
338
 
315
- # Consult external data bindings for class parameter values which must be
316
- # namespaced in the backend.
317
- #
318
- # Example:
319
- #
320
- # class foo($port){ ... }
321
- #
322
- # We make a request to the backend for the key 'foo::port' not 'foo'
323
- #
324
- external_value = nil
325
- if resource_type.type == :hostclass
326
- namespaced_param = "#{resource_type.name}::#{param}"
327
- external_value = Puppet::DataBinding.indirection.find(
328
- namespaced_param, :host => scope.host, :environment => scope.environment.to_s, :facts => scope.facts.values)
329
- end
339
+ missing_arguments.collect do |param, default|
340
+ external_value = lookup_external_default_for(param, scope)
330
341
 
331
- if external_value.nil?
332
- next if default.nil?
342
+ if external_value.nil? && default.nil?
343
+ next
344
+ elsif external_value.nil?
333
345
  value = default.safeevaluate(scope)
334
346
  else
335
347
  value = external_value
336
348
  end
337
349
 
338
- self[param] = value
339
- result << param
340
- end
341
- result
350
+ self[param.to_sym] = value
351
+ param
352
+ end.compact
342
353
  end
343
354
 
344
355
  def to_resource
@@ -316,7 +316,7 @@ class Puppet::Resource::Type
316
316
 
317
317
  # Evaluate the default parameters, now that all other variables are set
318
318
  default_params = resource.set_default_parameters(scope)
319
- default_params.each { |param| scope[param.to_s] = resource[param] }
319
+ default_params.each { |param| scope[param] = resource[param] }
320
320
 
321
321
  # This has to come after the above parameters so that default values
322
322
  # can use their values
@@ -6,7 +6,7 @@
6
6
  # Raketasks and such to set the version based on the output of `git describe`
7
7
  #
8
8
  module Puppet
9
- PUPPETVERSION = '3.0.0-rc7'
9
+ PUPPETVERSION = '3.0.0-rc8'
10
10
 
11
11
  def self.version
12
12
  @puppet_version || PUPPETVERSION
@@ -1,9 +1,15 @@
1
1
  require 'spec_helper'
2
2
  require 'puppet_spec/compiler'
3
3
 
4
- describe "Undefined parameters should be handled so that" do
4
+ describe "Parameter passing" do
5
5
  include PuppetSpec::Compiler
6
6
 
7
+ before :each do
8
+ # DataBinding will be consulted before falling back to a default value,
9
+ # but we aren't testing that here
10
+ Puppet::DataBinding.indirection.stubs(:find)
11
+ end
12
+
7
13
  def expect_the_message_to_be(message, node = Puppet::Node.new('the node'))
8
14
  catalog = compile_to_catalog(yield, node)
9
15
  catalog.resource('Notify', 'something')[:message].should == message
@@ -12,77 +18,70 @@ describe "Undefined parameters should be handled so that" do
12
18
  def expect_puppet_error(message, node = Puppet::Node.new('the node'))
13
19
  expect { compile_to_catalog(yield, node) }.to raise_error(Puppet::Error, message)
14
20
  end
15
- before :each do
16
- Puppet.expects(:deprecation_warning).never
21
+
22
+ it "overrides the default when a value is given" do
23
+ expect_the_message_to_be('2') do <<-MANIFEST
24
+ define a($x=1) { notify { 'something': message => $x }}
25
+ a {'a': x => 2}
26
+ MANIFEST
27
+ end
17
28
  end
18
29
 
19
- describe "when a value is given as parameter value" do
20
- it "it should override the default" do
21
- expect_the_message_to_be('2') do <<-MANIFEST
22
- node default {
23
- include foo
24
- }
25
- class foo {
26
- define a($x=1) { notify { 'something': message => $x }}
27
- a {'a': x => 2}
28
- }
29
- MANIFEST
30
- end
30
+ it "shadows an inherited variable with the default value when undef is passed" do
31
+ expect_the_message_to_be('default') do <<-MANIFEST
32
+ class a { $x = 'inherited' }
33
+ class b($x='default') inherits a { notify { 'something': message => $x }}
34
+ class { 'b': x => undef}
35
+ MANIFEST
31
36
  end
32
37
  end
33
38
 
34
- describe "when 'undef' is given as parameter value" do
35
- it "the value should be set to 'undef'" do
36
- expect_the_message_to_be(true) do <<-MANIFEST
37
- node default {
38
- include foo
39
- }
40
- class foo {
41
- define a($x=1) { notify { 'something': message => $x == undef }}
42
- a {'a': x => undef}
43
- }
44
- MANIFEST
45
- end
39
+ it "uses a default value that comes from an inherited class when the parameter is undef" do
40
+ expect_the_message_to_be('inherited') do <<-MANIFEST
41
+ class a { $x = 'inherited' }
42
+ class b($y=$x) inherits a { notify { 'something': message => $y }}
43
+ class { 'b': y => undef}
44
+ MANIFEST
46
45
  end
47
46
  end
48
47
 
49
- describe "when no value is given for a parameter" do
50
- it "the value should be set to the default" do
51
- expect_the_message_to_be('1') do <<-MANIFEST
52
- node default {
53
- include foo
54
- }
55
- class foo {
56
- define a($x=1) { notify { 'something': message => $x }}
57
- a {'a': }
58
- }
59
- MANIFEST
60
- end
48
+ it "uses a default value that references another variable when the parameter is passed as undef" do
49
+ expect_the_message_to_be('a') do <<-MANIFEST
50
+ define a($a = $title) { notify { 'something': message => $a }}
51
+ a {'a': a => undef}
52
+ MANIFEST
61
53
  end
62
- it "and the default is set to undef, the value should be set to the default" do
63
- expect_the_message_to_be(true) do <<-MANIFEST
64
- node default {
65
- include foo
66
- }
67
- class foo {
68
- define a($x=undef) { notify { 'something': message => $x == undef}}
69
- a {'a': }
70
- }
54
+ end
55
+
56
+ it "uses the default when 'undef' is given'" do
57
+ expect_the_message_to_be('1') do <<-MANIFEST
58
+ define a($x=1) { notify { 'something': message => $x }}
59
+ a {'a': x => undef}
71
60
  MANIFEST
72
- end
73
61
  end
62
+ end
74
63
 
75
- it "and no default is set should fail with error" do
76
- expect_puppet_error(/^Must pass x to Foo::A\[a\].*/) do <<-MANIFEST
77
- node default {
78
- include foo
79
- }
80
- class foo {
81
- define a($x) { notify { 'something': message => $x }}
82
- a {'a': }
83
- }
64
+ it "uses the default when no parameter is provided" do
65
+ expect_the_message_to_be('1') do <<-MANIFEST
66
+ define a($x=1) { notify { 'something': message => $x }}
67
+ a {'a': }
84
68
  MANIFEST
85
- end
69
+ end
70
+ end
71
+
72
+ it "uses a value of undef when the default is undef and no parameter is provided" do
73
+ expect_the_message_to_be(true) do <<-MANIFEST
74
+ define a($x=undef) { notify { 'something': message => $x == undef}}
75
+ a {'a': }
76
+ MANIFEST
77
+ end
78
+ end
79
+
80
+ it "errors when no parameter is provided and there is no default" do
81
+ expect_puppet_error(/^Must pass x to A\[a\].*/) do <<-MANIFEST
82
+ define a($x) { notify { 'something': message => $x }}
83
+ a {'a': }
84
+ MANIFEST
86
85
  end
87
86
  end
88
87
  end
@@ -302,21 +302,21 @@ describe Puppet::Resource do
302
302
  Puppet::Resource::Type.new(:definition, "default_param", :arguments => {"a" => Puppet::Parser::AST::String.new(:value => "a_default_value")})
303
303
  )
304
304
  resource = Puppet::Parser::Resource.new("default_param", "name", :scope => Puppet::Parser::Scope.new(Puppet::Parser::Compiler.new(Puppet::Node.new("foo"))))
305
- resource.set_default_parameters(@scope).should == [:a]
305
+ resource.set_default_parameters(@scope).should == ["a"]
306
306
  end
307
307
 
308
308
  describe "when the resource type is :hostclass" do
309
- let(:environmnet_name) { "testing env" }
309
+ let(:environment_name) { "testing env" }
310
310
  let(:fact_values) { { :a => 1 } }
311
311
  let(:port) { Puppet::Parser::AST::String.new(:value => '80') }
312
312
  let(:apache) { Puppet::Resource::Type.new(:hostclass, 'apache', :arguments => { 'port' => port }) }
313
313
 
314
314
  before do
315
- environment = Puppet::Node::Environment.new(environmnet_name)
315
+ environment = Puppet::Node::Environment.new(environment_name)
316
316
  environment.known_resource_types.add(apache)
317
317
 
318
318
  @scope.stubs(:host).returns('host')
319
- @scope.stubs(:environment).returns(Puppet::Node::Environment.new(environmnet_name))
319
+ @scope.stubs(:environment).returns(Puppet::Node::Environment.new(environment_name))
320
320
  @scope.stubs(:facts).returns(Puppet::Node::Facts.new("facts", fact_values))
321
321
  end
322
322
 
@@ -327,19 +327,23 @@ describe Puppet::Resource do
327
327
 
328
328
  it "should query the data_binding terminus using a namespaced key" do
329
329
  Puppet::DataBinding.indirection.expects(:find).with(
330
- 'apache::port', :host => 'host', :environment => environmnet_name, :facts => fact_values)
330
+ 'apache::port', all_of(has_key(:environment), has_key(:variables)))
331
331
  resource.set_default_parameters(@scope)
332
332
  end
333
333
 
334
334
  it "should use the value from the data_binding terminus" do
335
335
  Puppet::DataBinding.indirection.expects(:find).returns('443')
336
- resource.set_default_parameters(@scope).should == [:port]
336
+
337
+ resource.set_default_parameters(@scope)
338
+
337
339
  resource[:port].should == '443'
338
340
  end
339
341
 
340
342
  it "should use the default value if the data_binding terminus returns nil" do
341
343
  Puppet::DataBinding.indirection.expects(:find).returns(nil)
342
- resource.set_default_parameters(@scope).should == [:port]
344
+
345
+ resource.set_default_parameters(@scope)
346
+
343
347
  resource[:port].should == '80'
344
348
  end
345
349
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1331283097
4
+ hash: 3961099711
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 0
10
10
  - rc
11
- - 7
12
- version: 3.0.0.rc7
11
+ - 8
12
+ version: 3.0.0.rc8
13
13
  platform: ruby
14
14
  authors:
15
15
  - Puppet Labs
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-09-21 00:00:00 Z
20
+ date: 2012-09-25 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: hiera
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- hash: 665641595
30
+ hash: 1980549863
31
31
  segments:
32
32
  - 1
33
33
  - 0