Class: Kitchen::Provisioner::Dokken

Inherits:
ChefZero
  • Object
show all
Defined in:
lib/kitchen/provisioner/dokken.rb

Overview

Author:

Instance Method Summary collapse

Instance Method Details

#call(state) ⇒ Object


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

def call(state)
  create_sandbox
  write_run_command(run_command)
  instance.transport.connection(state) do |conn|
    if remote_docker_host?
      info("Transferring files to #{instance.to_str}")
      conn.upload(sandbox_dirs, config[:root_path])
    end

    conn.execute(prepare_command)
    conn.execute_with_retry(
      "sh #{config[:root_path]}/run_command",
      config[:retry_on_exit_code],
      config[:max_retries],
      config[:wait_for_retry]
    )
  end
rescue Kitchen::Transport::TransportFailed => ex
  raise ActionFailed, ex.message
ensure
  return unless config[:clean_dokken_sandbox] # rubocop: disable Lint/EnsureReturn

  cleanup_dokken_sandbox
end

#validate_configObject


82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/kitchen/provisioner/dokken.rb', line 82

def validate_config
  # check if we have an space for the user provided options
  # or add it if not to avoid issues
  unless config[:chef_options].start_with? " "
    config[:chef_options].prepend(" ")
  end

  # strip spaces from all other options
  config[:chef_binary] = config[:chef_binary].strip
  config[:chef_log_level] = config[:chef_log_level].strip
  config[:chef_output_format] = config[:chef_output_format].strip

  # if the user wants to be funny and pass empty strings
  # just use the defaults
  config[:chef_log_level] = "warn" if config[:chef_log_level].empty?
  config[:chef_output_format] = "doc" if config[:chef_output_format].empty?
end