lib/puppet/resource_api/transport.rb in puppet-resource_api-1.8.14 vs lib/puppet/resource_api/transport.rb in puppet-resource_api-1.8.18
- old
+ new
@@ -101,10 +101,11 @@
if connection_info.key?(:"remote-transport")
clean_bolt_attributes(transport_schema, connection_info)
end
+ apply_defaults(transport_schema, connection_info)
message_prefix = 'The connection info provided does not match the Transport Schema'
transport_schema.check_schema(connection_info, message_prefix)
transport_schema.validate(connection_info)
end
private_class_method :validate
@@ -125,9 +126,21 @@
end
end
connection_info
end
private_class_method :wrap_sensitive
+
+ def self.apply_defaults(transport_schema, connection_info)
+ context = get_context(transport_schema.name)
+ transport_schema.attributes.each do |attr_name, options|
+ if options.key?(:default) && connection_info.key?(attr_name) == false
+ context.debug('Using default value for attribute: %{attribute_name}, value: %{default_value}' % { attribute_name: attr_name, default_value: options[:default].inspect })
+ connection_info[attr_name] = options[:default]
+ end
+ end
+ connection_info
+ end
+ private_class_method :apply_defaults
def self.transports
@transports ||= {}
end
private_class_method :transports