Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Smith committed Mar 17, 2016
2 parents 791e8f0 + 2db47e4 commit 51b1582
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion api/schemas/catalog.json
Expand Up @@ -16,7 +16,7 @@
"type": "string"
},
"version": {
"type": "integer"
"type": ["string", "integer"]
},
"code_id": {
"type": ["string", "null"]
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet/resource/catalog.rb
Expand Up @@ -102,6 +102,9 @@ def add_resource_before(other, *resources)
end
end

# Add `resources` to the catalog after `other`. WARNING: adding
# multiple resources will produce the reverse ordering, e.g. calling
# `add_resource_after(A, [B,C])` will result in `[A,C,B]`.
def add_resource_after(other, *resources)
resources.each do |resource|
other_title_key = title_key_for_ref(other.ref)
Expand All @@ -111,7 +114,6 @@ def add_resource_after(other, *resources)
end
end


def add_resource(*resources)
resources.each do |resource|
add_one_resource(resource)
Expand Down
24 changes: 0 additions & 24 deletions lib/puppet/transaction.rb
Expand Up @@ -275,30 +275,6 @@ def propagate_failure(resource)
resource_status(resource).failed_dependencies = failed.to_a
end

# A general method for recursively generating new resources from a
# resource.
def generate_additional_resources(resource)
return unless resource.respond_to?(:generate)
begin
made = resource.generate
rescue => detail
resource.log_exception(detail, "Failed to generate additional resources using 'generate': #{detail}")
end
return unless made
made = [made] unless made.is_a?(Array)
made.uniq.each do |res|
begin
res.tag(*resource.tags)
@catalog.add_resource(res)
res.finish
add_conditional_directed_dependency(resource, res)
generate_additional_resources(res)
rescue Puppet::Resource::Catalog::DuplicateResourceError
res.info "Duplicate generated resource; skipping"
end
end
end

# Should we ignore tags?
def ignore_tags?
! @catalog.host_config?
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/version.rb
Expand Up @@ -7,7 +7,7 @@


module Puppet
PUPPETVERSION = '4.4.0'
PUPPETVERSION = '4.4.1'

##
# version is a public API method intended to always provide a fast and
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/provider/service/systemd_spec.rb
Expand Up @@ -42,7 +42,7 @@
end
end

[ 17, 18, 19, 20, 21 ].each do |ver|
[ 17, 18, 19, 20, 21, 22, 23 ].each do |ver|
it "should be the default provider on fedora#{ver}" do
Facter.stubs(:value).with(:osfamily).returns(:redhat)
Facter.stubs(:value).with(:operatingsystem).returns(:fedora)
Expand Down
27 changes: 27 additions & 0 deletions spec/unit/resource/catalog_spec.rb
Expand Up @@ -296,6 +296,7 @@
@catalog = Puppet::Resource::Catalog.new("host")
@one = Puppet::Type.type(:notify).new :name => "one"
@two = Puppet::Type.type(:notify).new :name => "two"
@three = Puppet::Type.type(:notify).new :name => "three"
@dupe = Puppet::Type.type(:notify).new :name => "one"
end

Expand Down Expand Up @@ -349,6 +350,32 @@
expect(@catalog.resource("notify[one]", nil)).to equal(@one)
end

it "adds resources before an existing resource" do
@catalog.add_resource(@one)
@catalog.add_resource_before(@one, @two, @three)

expect(@catalog.resources).to eq([@two, @three, @one])
end

it "raises if adding a resource before a resource not in the catalog" do
expect {
@catalog.add_resource_before(@one, @two)
}.to raise_error(ArgumentError, "Cannot add resource Notify[two] before Notify[one] because Notify[one] is not yet in the catalog")
end

it "adds resources after an existing resource in reverse order" do
@catalog.add_resource(@one)
@catalog.add_resource_after(@one, @two, @three)

expect(@catalog.resources).to eq([@one, @three, @two])
end

it "raises if adding a resource after a resource not in the catalog" do
expect {
@catalog.add_resource_after(@one, @two)
}.to raise_error(ArgumentError, "Cannot add resource Notify[two] after Notify[one] because Notify[one] is not yet in the catalog")
end

describe 'with a duplicate resource' do
def resource_at(type, name, file, line)
resource = Puppet::Resource.new(type, name)
Expand Down

0 comments on commit 51b1582

Please sign in to comment.