Class: Kitchen::Provisioner::ChefGithub

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

Instance Method Summary collapse

Instance Method Details

#create_sandboxObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kitchen/provisioner/chef_github.rb', line 11

def create_sandbox
  super
  dna = {
    chef_appbundle_updater: {
      github_org: config[:github_owner],
      github_repo: config[:github_repo],
      refname: config[:refname]
    }
  }

  File.open(File.join(sandbox_path, 'dna_updater.json'), "wb") do |f|
    f.write(dna.to_json)
  end
end

#latest_chef_appbundle_updaterObject



26
27
28
29
30
31
# File 'lib/kitchen/provisioner/chef_github.rb', line 26

def latest_chef_appbundle_updater
  @cookbook_url ||= open("https://api.github.com/repos/jdmundrawala/chef-appbundle-updater/releases/latest") do |r|
    j = JSON.parse(r.read)
    j["assets"][0]["browser_download_url"]
  end
end

#prepare_commandObject



33
34
35
36
37
38
# File 'lib/kitchen/provisioner/chef_github.rb', line 33

def prepare_command
  [
    prepare_command_vars,
    KitchenAppbundleUpdater::Helpers.load_file("chef_base_updater", powershell_shell?)
  ].join("\n")
end

#prepare_command_varsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/kitchen/provisioner/chef_github.rb', line 40

def prepare_command_vars
  vars = [
    shell_var("cookbook_url", latest_chef_appbundle_updater),
    shell_var("json", File.join(config[:root_path], 'dna_updater.json')),
    shell_var("chef_omnibus_root", config[:chef_omnibus_root]),
  ]

  if powershell_shell?
    vars.join("\n")
  else
    vars.join(";\n")
  end
end