Replace most mentions of Attribute (titlecase) in lib and test

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2019-02-11 23:13:50 -05:00
parent ce99624095
commit 4f361bfc56
8 changed files with 18 additions and 18 deletions

View file

@ -27,7 +27,7 @@ module Inspec
# allow attributes to be accessed within control blocks # allow attributes to be accessed within control blocks
define_method :attribute do |name| define_method :attribute do |name|
Inspec::AttributeRegistry.find_attribute(name, profile_id).value Inspec::InputRegistry.find_input(name, profile_id).value
end end
# Support for Control DSL plugins. # Support for Control DSL plugins.
@ -167,12 +167,12 @@ module Inspec
profile_context_owner.register_rule(control, &block) unless control.nil? profile_context_owner.register_rule(control, &block) unless control.nil?
end end
# method for attributes; import attribute handling # method for inputs; import input handling
define_method :attribute do |name, options = nil| define_method :attribute do |name, options = nil|
if options.nil? if options.nil?
Inspec::AttributeRegistry.find_attribute(name, profile_id).value Inspec::InputRegistry.find_input(name, profile_id).value
else else
profile_context_owner.register_attribute(name, options) profile_context_owner.register_input(name, options)
end end
end end

View file

@ -3,8 +3,8 @@
module Inspec module Inspec
module Exceptions module Exceptions
class AttributesFileDoesNotExist < ArgumentError; end class InputsFileDoesNotExist < ArgumentError; end
class AttributesFileNotReadable < ArgumentError; end class InputsFileNotReadable < ArgumentError; end
class ResourceFailed < StandardError; end class ResourceFailed < StandardError; end
class ResourceSkipped < StandardError; end class ResourceSkipped < StandardError; end
class SecretsBackendNotFound < ArgumentError; end class SecretsBackendNotFound < ArgumentError; end

View file

@ -1,7 +1,7 @@
# encoding: utf-8 # encoding: utf-8
module Inspec module Inspec
autoload :Attribute, 'inspec/objects/input' autoload :Input, 'inspec/objects/input'
autoload :Tag, 'inspec/objects/tag' autoload :Tag, 'inspec/objects/tag'
autoload :Control, 'inspec/objects/control' autoload :Control, 'inspec/objects/control'
autoload :Describe, 'inspec/objects/describe' autoload :Describe, 'inspec/objects/describe'

View file

@ -135,7 +135,7 @@ module Inspec
@runner_context.register_attribute(name, attr_dup) @runner_context.register_attribute(name, attr_dup)
end end
elsif metadata.params.key?(:attributes) elsif metadata.params.key?(:attributes)
Inspec::Log.warn 'Attributes must be defined as an Array. Skipping current definition.' Inspec::Log.warn 'Inputs must be defined as an Array. Skipping current definition.'
end end
end end

View file

@ -34,8 +34,8 @@ module Inspec
@control_subcontexts = [] @control_subcontexts = []
@lib_subcontexts = [] @lib_subcontexts = []
@require_loader = ::Inspec::RequireLoader.new @require_loader = ::Inspec::RequireLoader.new
Inspec::AttributeRegistry.register_profile_alias(@profile_id, @profile_name) if @profile_id != @profile_name Inspec::InputRegistry.register_profile_alias(@profile_id, @profile_name) if @profile_id != @profile_name
@attributes = Inspec::AttributeRegistry.list_attributes_for_profile(@profile_id) @attributes = Inspec::InputRegistry.list_inputs_for_profile(@profile_id)
# A local resource registry that only contains resources defined # A local resource registry that only contains resources defined
# in the transitive dependency tree of the loaded profile. # in the transitive dependency tree of the loaded profile.
@resource_registry = Inspec::Resource.new_registry @resource_registry = Inspec::Resource.new_registry
@ -188,8 +188,8 @@ module Inspec
end end
def register_attribute(name, options = {}) def register_attribute(name, options = {})
# we need to return an attribute object, to allow dermination of default values # we need to return an attribute object, to allow dermination of values
attribute = Inspec::AttributeRegistry.register_attribute(name, @profile_id, options) attribute = Inspec::InputRegistry.register_attribute(name, @profile_id, options)
attribute.value = @conf['attributes'][name] unless @conf['attributes'].nil? || @conf['attributes'][name].nil? attribute.value = @conf['attributes'][name] unless @conf['attributes'].nil? || @conf['attributes'][name].nil?
attribute.value attribute.value
end end

View file

@ -64,9 +64,9 @@ module Inspec
end end
class RSpec::Core::ExampleGroup class RSpec::Core::ExampleGroup
# This DSL method allows us to access the values of attributes within InSpec tests # This DSL method allows us to access the values of inputs within InSpec tests
def attribute(name) def attribute(name)
Inspec::AttributeRegistry.find_attribute(name, self.class.metadata[:profile_id]).value Inspec::InputRegistry.find_input(name, self.class.metadata[:profile_id]).value
end end
define_example_method :attribute define_example_method :attribute

View file

@ -291,13 +291,13 @@ module Inspec
def validate_attributes_file_readability!(target) def validate_attributes_file_readability!(target)
unless File.exist?(target) unless File.exist?(target)
raise Inspec::Exceptions::AttributesFileDoesNotExist, raise Inspec::Exceptions::InputsFileDoesNotExist,
"Cannot find attributes file '#{target}'. " \ "Cannot find attributes file '#{target}'. " \
'Check to make sure file exists.' 'Check to make sure file exists.'
end end
unless File.readable?(target) unless File.readable?(target)
raise Inspec::Exceptions::AttributesFileNotReadable, raise Inspec::Exceptions::InputsFileNotReadable,
"Cannot read attributes file '#{target}'. " \ "Cannot read attributes file '#{target}'. " \
'Check to make sure file is readable.' 'Check to make sure file is readable.'
end end

View file

@ -38,7 +38,7 @@ describe 'attributes' do
cmd += File.join(inputs_profiles_path, 'metadata-empty') cmd += File.join(inputs_profiles_path, 'metadata-empty')
cmd += ' --no-create-lockfile' cmd += ' --no-create-lockfile'
out = inspec(cmd) out = inspec(cmd)
out.stdout.must_include 'WARN: Attributes must be defined as an Array. Skipping current definition.' out.stdout.must_include 'WARN: Inputs must be defined as an Array. Skipping current definition.'
out.exit_status.must_equal 0 out.exit_status.must_equal 0
end end
@ -57,7 +57,7 @@ describe 'attributes' do
cmd += File.join(inputs_profiles_path, 'required') cmd += File.join(inputs_profiles_path, 'required')
cmd += ' --no-create-lockfile' cmd += ' --no-create-lockfile'
out = inspec(cmd) out = inspec(cmd)
out.stderr.must_equal "Attribute 'username' is required and does not have a value.\n" out.stderr.must_equal "Input 'username' is required and does not have a value.\n"
out.stdout.must_equal '' out.stdout.must_equal ''
out.exit_status.must_equal 1 out.exit_status.must_equal 1
end end