Module: Kitchen
- Defined in:
- lib/kitchen.rb,
lib/kitchen/cli.rb,
lib/kitchen/ssh.rb,
lib/kitchen/util.rb,
lib/kitchen/color.rb,
lib/kitchen/suite.rb,
lib/kitchen/busser.rb,
lib/kitchen/config.rb,
lib/kitchen/driver.rb,
lib/kitchen/errors.rb,
lib/kitchen/logger.rb,
lib/kitchen/logging.rb,
lib/kitchen/version.rb,
lib/kitchen/instance.rb,
lib/kitchen/platform.rb,
lib/kitchen/lazy_hash.rb,
lib/kitchen/shell_out.rb,
lib/kitchen/collection.rb,
lib/kitchen/diagnostic.rb,
lib/kitchen/rake_tasks.rb,
lib/kitchen/state_file.rb,
lib/kitchen/thor_tasks.rb,
lib/kitchen/data_munger.rb,
lib/kitchen/driver/base.rb,
lib/kitchen/loader/yaml.rb,
lib/kitchen/provisioner.rb,
lib/kitchen/driver/dummy.rb,
lib/kitchen/driver/proxy.rb,
lib/kitchen/login_command.rb,
lib/kitchen/generator/init.rb,
lib/kitchen/driver/ssh_base.rb,
lib/kitchen/metadata_chopper.rb,
lib/kitchen/provisioner/base.rb,
lib/kitchen/provisioner/dummy.rb,
lib/kitchen/provisioner/chef_base.rb,
lib/kitchen/provisioner/chef_solo.rb,
lib/kitchen/provisioner/chef_zero.rb,
lib/kitchen/generator/driver_create.rb,
lib/kitchen/provisioner/chef/berkshelf.rb,
lib/kitchen/provisioner/chef/librarian.rb
Overview
Author:: Fletcher Nichol ([email protected])
Copyright (C) 2012, Fletcher Nichol
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Modules: Color, Driver, Error, Generator, Loader, Logging, Provisioner, ShellOut, Util Classes: ActionFailed, Busser, CLI, ClientError, Collection, Config, DataMunger, Diagnostic, Instance, InstanceFailure, LazyHash, Logger, LoginCommand, MetadataChopper, Platform, RakeTasks, SSH, SSHFailed, StandardError, StateFile, StateFileLoadError, Suite, ThorTasks, TransientFailure, UserError
Constant Summary collapse
- DEFAULT_LOG_LEVEL =
Default log level verbosity
:info- DEFAULT_TEST_DIR =
"test/integration".freeze
- DEFAULT_LOG_DIR =
".kitchen/logs".freeze
- VERSION =
"1.1.1"
Class Attribute Summary collapse
-
.crashes ⇒ Object
Returns the value of attribute crashes.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.mutex ⇒ Object
Returns the value of attribute mutex.
Class Method Summary collapse
- .crashes? ⇒ Boolean
- .debug_log(lines) ⇒ Object
- .default_file_logger ⇒ Object
- .default_logger ⇒ Object
- .file_log(level, lines) ⇒ Object
- .handle_error(e) ⇒ Object
- .handle_instance_failure(e) ⇒ Object
-
.source_root ⇒ Pathname
Returns the root path of the Kitchen gem source code.
- .stderr_log(lines) ⇒ Object
- .with_friendly_errors ⇒ Object
Class Attribute Details
.crashes ⇒ Object
Returns the value of attribute crashes.
57 58 59 |
# File 'lib/kitchen.rb', line 57 def crashes @crashes end |
.logger ⇒ Object
Returns the value of attribute logger.
56 57 58 |
# File 'lib/kitchen.rb', line 56 def logger @logger end |
.mutex ⇒ Object
Returns the value of attribute mutex.
58 59 60 |
# File 'lib/kitchen.rb', line 58 def mutex @mutex end |
Class Method Details
.crashes? ⇒ Boolean
67 68 69 |
# File 'lib/kitchen.rb', line 67 def crashes? ! crashes.empty? end |
.debug_log(lines) ⇒ Object
112 113 114 |
# File 'lib/kitchen/errors.rb', line 112 def self.debug_log(lines) Array(lines).each { |line| Kitchen.logger.debug(line) } end |
.default_file_logger ⇒ Object
75 76 77 78 |
# File 'lib/kitchen.rb', line 75 def default_file_logger logfile = File.(File.join(".kitchen", "logs", "kitchen.log")) Logger.new(:stdout => STDOUT, :logdev => logfile, :level => env_log) end |
.default_logger ⇒ Object
71 72 73 |
# File 'lib/kitchen.rb', line 71 def default_logger Logger.new(:stdout => STDOUT, :level => env_log) end |
.file_log(level, lines) ⇒ Object
96 97 98 99 100 101 102 103 104 |
# File 'lib/kitchen/errors.rb', line 96 def self.file_log(level, lines) Array(lines).each do |line| if Kitchen.logger.debug? Kitchen.logger.debug(line) else Kitchen.logger.logdev && Kitchen.logger.logdev.public_send(level, line) end end end |
.handle_error(e) ⇒ Object
123 124 125 126 127 |
# File 'lib/kitchen/errors.rb', line 123 def self.handle_error(e) stderr_log(Error.formatted_exception(e)) stderr_log("Please see .kitchen/logs/kitchen.log for more details\n") file_log(:error, Error.formatted_trace(e)) end |
.handle_instance_failure(e) ⇒ Object
116 117 118 119 120 121 |
# File 'lib/kitchen/errors.rb', line 116 def self.handle_instance_failure(e) stderr_log(e..split(/\s{2,}/)) stderr_log(Error.formatted_exception(e.original)) file_log(:error, e..split(/\s{2,}/).first) debug_log(Error.formatted_trace(e)) end |
.source_root ⇒ Pathname
Returns the root path of the Kitchen gem source code.
63 64 65 |
# File 'lib/kitchen.rb', line 63 def source_root @source_root ||= Pathname.new(File.('../../', __FILE__)) end |
.stderr_log(lines) ⇒ Object
106 107 108 109 110 |
# File 'lib/kitchen/errors.rb', line 106 def self.stderr_log(lines) Array(lines).each do |line| $stderr.puts(Color.colorize(">>>>>> #{line}", :red)) end end |
.with_friendly_errors ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/kitchen/errors.rb', line 80 def self.with_friendly_errors yield rescue Kitchen::InstanceFailure => e Kitchen.mutex.synchronize do handle_instance_failure(e) end exit 10 rescue Kitchen::Error => e Kitchen.mutex.synchronize do handle_error(e) end exit 20 end |