Class: Kitchen::Config
- Inherits:
-
Object
- Object
- Kitchen::Config
- Defined in:
- lib/kitchen/config.rb
Overview
Base configuration class for Kitchen. This class exposes configuration such as the location of the Kitchen config file, instances, log_levels, etc. This object is a factory object, meaning that it is responsible for consuming the desired testing configuration in and returning Ruby objects which are used to perfom the work.
Most internal objects are created with the expectation of being immutable, meaning that internal state cannot be modified after creation. Any data manipulation or thread-unsafe activity is performed in this object so that the subsequently created objects (such as Instances, Platforms, Drivers, etc.) can safely run in concurrent threads of execution. To prevent the re-creation of duplicate objects, most created objects are memoized. The consequence of this is that once the Instance Array has been requested (with the ‘#instances` message), you will always be returned the same Instance objects.
Instance Attribute Summary collapse
-
#colorize ⇒ Boolean
private
Whether to force color output or not in logger.
-
#debug ⇒ Boolean
private
Whether to enable debugging in the provisioner/verifier plugin or not.
-
#kitchen_root ⇒ String
readonly
private
The absolute path to the root of a Test Kitchen project.
-
#loader ⇒ #read
readonly
private
The data loader that responds to a ‘#read` message, returning a Hash data structure.
-
#log_level ⇒ Symbol
private
The logging verbosity level.
-
#log_overwrite ⇒ Boolean
private
Whether to overwrite the log file when Test Kitchen runs.
-
#log_root ⇒ String
readonly
private
The absolute path to the directory into which all Test Kitchen log files will be written.
-
#test_base_path ⇒ String
private
An absolute path to the directory containing test suites.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
Creates a new configuration, representing a particular testing configuration for a project.
-
#instances ⇒ Collection<Instance>
All instances, resulting from all platform and suite combinations.
-
#platforms ⇒ Collection<Platform>
All defined platforms which will be used in convergence integration.
-
#suites ⇒ Collection<Suite>
All defined suites which will be used in convergence integration.
Constructor Details
#initialize(options = {}) ⇒ Config
Creates a new configuration, representing a particular testing configuration for a project.
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/kitchen/config.rb', line 102 def initialize( = {}) @loader = .fetch(:loader) { Kitchen::Loader::YAML.new } @kitchen_root = .fetch(:kitchen_root) { Dir.pwd } @log_level = .fetch(:log_level) { Kitchen::DEFAULT_LOG_LEVEL } @log_overwrite = .fetch(:log_overwrite) { Kitchen::DEFAULT_LOG_OVERWRITE } @colorize = .fetch(:colorize) { Kitchen.tty? } @log_root = .fetch(:log_root) { default_log_root } @test_base_path = .fetch(:test_base_path) { default_test_base_path } @debug = .fetch(:debug) { false } end |
Instance Attribute Details
#colorize ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether to force color output or not in logger.
78 79 80 |
# File 'lib/kitchen/config.rb', line 78 def colorize @colorize end |
#debug ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether to enable debugging in the provisioner/verifier plugin or not.
82 83 84 |
# File 'lib/kitchen/config.rb', line 82 def debug @debug end |
#kitchen_root ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the absolute path to the root of a Test Kitchen project.
51 52 53 |
# File 'lib/kitchen/config.rb', line 51 def kitchen_root @kitchen_root end |
#loader ⇒ #read (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The data loader that responds to a ‘#read` message, returning a Hash data structure
61 62 63 |
# File 'lib/kitchen/config.rb', line 61 def loader @loader end |
#log_level ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the logging verbosity level.
65 66 67 |
# File 'lib/kitchen/config.rb', line 65 def log_level @log_level end |
#log_overwrite ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether to overwrite the log file when Test Kitchen runs.
70 71 72 |
# File 'lib/kitchen/config.rb', line 70 def log_overwrite @log_overwrite end |
#log_root ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the absolute path to the directory into which all Test Kitchen log files will be written.
56 57 58 |
# File 'lib/kitchen/config.rb', line 56 def log_root @log_root end |
#test_base_path ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an absolute path to the directory containing test suites.
74 75 76 |
# File 'lib/kitchen/config.rb', line 74 def test_base_path @test_base_path end |
Instance Method Details
#instances ⇒ Collection<Instance>
Returns all instances, resulting from all platform and suite combinations.
115 116 117 |
# File 'lib/kitchen/config.rb', line 115 def instances @instances ||= Collection.new(build_instances) end |
#platforms ⇒ Collection<Platform>
Returns all defined platforms which will be used in convergence integration.
121 122 123 124 125 |
# File 'lib/kitchen/config.rb', line 121 def platforms @platforms ||= Collection.new( data.platform_data.map { |pdata| Platform.new(pdata) } ) end |
#suites ⇒ Collection<Suite>
Returns all defined suites which will be used in convergence integration.
129 130 131 132 133 |
# File 'lib/kitchen/config.rb', line 129 def suites @suites ||= Collection.new( data.suite_data.map { |sdata| Suite.new(sdata) } ) end |