Class: Kitchen::Provisioner::CincApply

Inherits:
CincBase
  • Object
show all
Defined in:
lib/kitchen/provisioner/cinc_apply.rb

Overview

Cinc Apply provisioner.

Author:

  • Cinc Project

Instance Method Summary collapse

Methods inherited from CincBase

#initialize, #install_command

Constructor Details

This class inherits a constructor from Kitchen::Provisioner::CincBase

Instance Method Details

#create_sandboxObject



75
76
77
78
79
80
81
82
83
# File 'lib/kitchen/provisioner/cinc_apply.rb', line 75

def create_sandbox
  @sandbox_path = Dir.mktmpdir("#{instance.name}-sandbox-")
  File.chmod(0755, sandbox_path)
  info("Preparing files for transfer")
  debug("Creating local sandbox in #{sandbox_path}")

  prepare_json
  prepare(:apply)
end

#init_commandObject



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

def init_command
  dirs = %w{
    apply
  }.sort.map { |dir| remote_path_join(config[:root_path], dir) }

  vars = if powershell_shell?
           init_command_vars_for_powershell(dirs)
         else
           init_command_vars_for_bourne(dirs)
         end

  prefix_command(shell_code_from_file(vars, "cinc_base_init_command"))
end

#run_commandObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/kitchen/provisioner/cinc_apply.rb', line 101

def run_command
  level = config[:log_level]
  lines = []
  config[:run_list].map do |recipe|
    cmd = sudo(config[:cinc_apply_path]).dup
      .tap { |str| str.insert(0, "& ") if powershell_shell? }
    args = [
      "apply/#{recipe}.rb",
      "--log_level #{level}",
      "--no-color",
    ]
    args << "--logfile #{config[:log_file]}" if config[:log_file]

    lines << wrap_shell_code(
      [cmd, *args].join(" ")
      .tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
    )
  end

  prefix_command(lines.join("\n"))
end