Class: Kitchen::CLI

Inherits:
Thor
  • Object
show all
Includes:
PerformCommand, Logging
Defined in:
lib/kitchen/cli.rb

Overview

The command line runner for Kitchen.

Author:

Defined Under Namespace

Modules: PerformCommand

Constant Summary collapse

MAX_CONCURRENCY =

The maximum number of concurrent instances that can run--which is a bit high

9999

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PerformCommand

#perform

Methods included from Logging

#banner, #debug, #error, #fatal, #info, #warn

Constructor Details

#initialize(*args) ⇒ CLI

Constructs a new instance.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/kitchen/cli.rb', line 66

def initialize(*args)
  super
  $stdout.sync = true
  @loader = Kitchen::Loader::YAML.new(
    project_config: ENV["KITCHEN_YAML"] || ENV["KITCHEN_YML"],
    local_config: ENV["KITCHEN_LOCAL_YAML"] || ENV["KITCHEN_LOCAL_YML"],
    global_config: ENV["KITCHEN_GLOBAL_YAML"] || ENV["KITCHEN_GLOBAL_YML"]
  )
  @config = Kitchen::Config.new(
    loader: @loader
  )
  @config.log_level = Kitchen.env_log unless Kitchen.env_log.nil?
  @config.log_overwrite = Kitchen.env_log_overwrite unless Kitchen.env_log_overwrite.nil?
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



63
64
65
# File 'lib/kitchen/cli.rb', line 63

def config
  @config
end

Class Method Details

.log_optionsObject

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.

Sets the logging method_options



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/kitchen/cli.rb', line 83

def self.log_options
  method_option :log_level,
    aliases: "-l",
    desc: "Set the log level (debug, info, warn, error, fatal)"
  method_option :log_overwrite,
    desc: "Set to false to prevent log overwriting each time Test Kitchen runs",
    type: :boolean
  method_option :color,
    type: :boolean,
    lazy_default: $stdout.tty?,
    desc: "Toggle color output for STDOUT logger"
end

.test_base_pathObject

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.

Sets the test_base_path method_options



98
99
100
101
102
# File 'lib/kitchen/cli.rb', line 98

def self.test_base_path
  method_option :test_base_path,
    aliases: "-t",
    desc: "Set the base path of the tests"
end

Instance Method Details

#consolevoid

This method returns an undefined value.

Starts an interactive console session with the Test Kitchen configuration loaded.



382
383
384
# File 'lib/kitchen/cli.rb', line 382

def console
  perform("console", "console")
end

#diagnose(*args) ⇒ void

This method returns an undefined value.

Prints the fully computed diagnostic configuration for one or more instances, after all loader and plugin data has been merged.

Parameters:

  • args (Array<String>)

    instance names or regexps to match; matches all instances when empty



158
159
160
161
# File 'lib/kitchen/cli.rb', line 158

def diagnose(*args)
  update_config!
  perform("diagnose", "diagnose", args, loader: @loader)
end

#doctor(*args) ⇒ void

This method returns an undefined value.

Checks one or more instances for common system and configuration problems.

Parameters:

  • args (Array<String>)

    instance names or regexps to match; matches all instances when empty



338
339
340
341
# File 'lib/kitchen/cli.rb', line 338

def doctor(*args)
  update_config!
  perform("doctor", "doctor", args)
end

#exec(*args) ⇒ void

This method returns an undefined value.

Executes a remote command on one or more instances over their configured transport.

Parameters:

  • args (Array<String>)

    instance names or regexps to match; matches all instances when empty



355
356
357
358
# File 'lib/kitchen/cli.rb', line 355

def exec(*args)
  update_config!
  perform("exec", "exec", args)
end

#list(*args) ⇒ void

This method returns an undefined value.

Lists one or more instances and their last known action state.

Parameters:

  • args (Array<String>)

    instance names or regexps to match; matches all instances when empty



129
130
131
132
133
# File 'lib/kitchen/cli.rb', line 129

def list(*args)
  log_overwrite = options[:log_overwrite].nil? ? false : options[:log_overwrite]
  update_config!(log_overwrite:)
  perform("list", "list", args)
end

#login(*args) ⇒ void

This method returns an undefined value.

Opens an interactive login session on a single instance.

Parameters:

  • args (Array<String>)

    an instance name or regexp matching exactly one instance



283
284
285
286
# File 'lib/kitchen/cli.rb', line 283

def (*args)
  update_config!
  perform("login", "login", args)
end

#logs(*args) ⇒ void

This method returns an undefined value.

Prints the structured log events recorded for one or more instances.

Parameters:

  • args (Array<String>)

    instance names or regexps to match; matches all instances when empty



309
310
311
312
# File 'lib/kitchen/cli.rb', line 309

def logs(*args)
  update_config!(log_overwrite: false)
  perform("logs", "logs", args)
end

#package(*args) ⇒ void

This method returns an undefined value.

Packages a single instance into a distributable artifact, as implemented by the instance's driver.

Parameters:

  • args (Array<String>)

    an instance name or regexp matching exactly one instance



322
323
324
325
# File 'lib/kitchen/cli.rb', line 322

def package(*args)
  update_config!
  perform("package", "package", args)
end

#sinkvoid

This method returns an undefined value.

Shows the Kitchen sink. A hidden easter egg command.



373
374
375
# File 'lib/kitchen/cli.rb', line 373

def sink
  perform("sink", "sink")
end

#test(*args) ⇒ void

This method returns an undefined value.

Runs a full test cycle (destroy, create, converge, setup, verify, destroy) against one or more instances.

Parameters:

  • args (Array<String>)

    instance names or regexps to match; matches all instances when empty



270
271
272
273
274
# File 'lib/kitchen/cli.rb', line 270

def test(*args)
  update_config!
  ensure_initialized
  perform("test", "test", args)
end

#versionvoid

This method returns an undefined value.

Prints Test Kitchen's version information to stdout.



364
365
366
# File 'lib/kitchen/cli.rb', line 364

def version
  puts "Test Kitchen version #{Kitchen::VERSION}"
end