class Kitchen::Provisioner::Dokken

@author Sean OMeara <sean@sean.io>

def call(state)

(see Base#call)
def call(state)
  create_sandbox
  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(
      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
  cleanup_sandbox if remote_docker_host?
end

def run_command

patching Kitchen::Provisioner::ChefZero#run_command
def run_command
  validate_config
  cmd = config[:chef_binary]
  cmd << config[:chef_options].to_s
  cmd << " -l #{config[:chef_log_level]}"
  cmd << " -F #{config[:chef_output_format]}"
  cmd << ' -c /opt/kitchen/client.rb'
  cmd << ' -j /opt/kitchen/dna.json'
end

def runner_container_name

def runner_container_name
  instance.name.to_s
end

def validate_config

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