Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable catalog access feature #284

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puppet/resource_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def strict_check_title_parameter(current_state)
end

def context
self.class.context
@context ||= PuppetContext.new(type_definition, type_definition.feature?('raw_catalog_access') ? @catalog : nil)
end

def self.title_patterns
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet/resource_api/base_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ module Puppet::ResourceApi; end
# The runtime environment will inject an appropriate implementation.
class Puppet::ResourceApi::BaseContext
attr_reader :type
attr_reader :catalog

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

def device
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/resource_api/type_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def validate_schema(definition, attr_key)
Puppet::ResourceApi::DataTypeHandling.validate_ensure(definition)

definition[:features] ||= []
supported_features = %w[supports_noop canonicalize remote_resource simple_get_filter].freeze
supported_features = %w[supports_noop canonicalize remote_resource simple_get_filter raw_catalog_access].freeze
unknown_features = definition[:features] - supported_features
Puppet.warning("Unknown feature detected: #{unknown_features.inspect}") unless unknown_features.empty?
end
Expand Down