Skip to content

Commit d05f624

Browse files
(GH-242) Ensure catalog passing when raw_catalog_access flag specified
This commit updates the BaseContext class initialization method to take a second argument, catalog (default to nil), which ensures that the @catalog instance variable is populated with the value passed. It also updates the context method in resource_api to pass the catalog to that initializer if specified, or pass nil if not. This does not add unit or acceptance tests for the behavior.
1 parent a796a81 commit d05f624

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/puppet/resource_api.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def strict_check_title_parameter(current_state)
430430
end
431431

432432
def context
433-
@context ||= PuppetContext.new(TypeDefinition.new(definition), type_definition.feature?('raw_catalog_access') ? @catalog : nil)
433+
@context ||= PuppetContext.new(type_definition, type_definition.feature?('raw_catalog_access') ? @catalog : nil)
434434
end
435435

436436
def self.title_patterns

lib/puppet/resource_api/base_context.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Puppet::ResourceApi::BaseContext
1111
attr_reader :type
1212
attr_reader :catalog
1313

14-
def initialize(definition)
14+
def initialize(definition, catalog = nil)
1515
if definition.is_a?(Hash)
1616
# this is only for backwards compatibility
1717
@type = Puppet::ResourceApi::TypeDefinition.new(definition)
@@ -20,6 +20,7 @@ def initialize(definition)
2020
else
2121
raise ArgumentError, 'BaseContext requires definition to be a child of Puppet::ResourceApi::BaseTypeDefinition, not <%{actual_type}>' % { actual_type: definition.class }
2222
end
23+
@catalog = catalog
2324
end
2425

2526
def device

0 commit comments

Comments
 (0)