Class: Kitchen::Driver::Dummy

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/driver/dummy.rb

Overview

Dummy driver for Kitchen. This driver does nothing but report what would happen if this driver did anything of consequence. As a result it may be a useful driver to use when debugging or developing new features or plugins.

Author:

Instance Attribute Summary

Attributes included from Configurable

#instance

Instance Method Summary collapse

Methods inherited from Base

#cache_directory, #doctor, #initialize, kitchen_driver_api_version, #package

Methods included from ShellOut

#run_command

Methods included from Logging

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

Methods included from Configurable

#[], #bourne_shell?, #calculate_path, #config_keys, #diagnose, #diagnose_plugin, #finalize_config!, included, #name, #powershell_shell?, #remote_path_join, #unix_os?, #verify_dependencies, #windows_os?

Constructor Details

This class inherits a constructor from Kitchen::Driver::Base

Instance Method Details

#create(state) ⇒ Object

Creates an instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



33
34
35
36
37
# File 'lib/kitchen/driver/dummy.rb', line 33

def create(state)
  # Intentionally not calling `super` to avoid pre_create_command.
  state[:my_id] = "#{instance.name}-#{Time.now.to_i}"
  report(:create, state)
end

#destroy(state) ⇒ Object

Destroys an instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



50
51
52
53
# File 'lib/kitchen/driver/dummy.rb', line 50

def destroy(state)
  report(:destroy, state)
  state.delete(:my_id)
end

#setup(state) ⇒ Object



40
41
42
# File 'lib/kitchen/driver/dummy.rb', line 40

def setup(state)
  report(:setup, state)
end

#status(state) ⇒ Hash

Reports whether the dummy instance has a generated resource id.

Parameters:

  • state (Hash)

    mutable instance and driver state

Returns:

  • (Hash)

    normalized status data



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/kitchen/driver/dummy.rb', line 59

def status(state)
  if state[:my_id]
    {
      live: true,
      state: "running",
      source: "driver",
      resource_id: state[:my_id],
      message: "Dummy instance exists",
      checked_at: Time.now.utc.iso8601,
    }
  else
    {
      live: false,
      state: "not_created",
      source: "driver",
      resource_id: nil,
      message: "Dummy instance has no resource id",
      checked_at: Time.now.utc.iso8601,
    }
  end
end

#verify(state) ⇒ Object



45
46
47
# File 'lib/kitchen/driver/dummy.rb', line 45

def verify(state)
  report(:verify, state)
end