Class: Kitchen::Provisioner::Habitat

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/provisioner/habitat.rb

Instance Method Summary collapse

Instance Method Details

#create_sandboxObject



108
109
110
111
112
113
# File 'lib/kitchen/provisioner/habitat.rb', line 108

def create_sandbox
  super
  copy_results_to_sandbox
  copy_user_toml_to_sandbox
  copy_package_config_from_override_to_sandbox
end

#finalize_config!(instance) ⇒ Object



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

def finalize_config!(instance)
  # Check to see if a package ident was specified for package name and be helpful
  unless config[:package_name].nil? || (config[:package_name] =~ %r{/}).nil?
    config[:package_origin], config[:package_name], config[:package_version], config[:package_release] = config[:package_name].split("/")
  end

  unless config[:hab_sup_artifact_name].nil?
    ident = artifact_name_to_package_ident_regex.match(config[:hab_sup_artifact_name])
    config[:hab_sup_origin] = ident["origin"]
    config[:hab_sup_name] = ident["name"]
    config[:hab_sup_version] = ident["version"]
    config[:hab_sup_release] = ident["release"]
  end

  unless config[:artifact_name].nil?
    ident = artifact_name_to_package_ident_regex.match(config[:artifact_name])
    config[:package_origin] = ident["origin"]
    config[:package_name] = ident["name"]
    config[:package_version] = ident["version"]
    config[:package_release] = ident["release"]
  end
  super(instance)
end

#init_commandObject



99
100
101
102
103
104
105
106
# File 'lib/kitchen/provisioner/habitat.rb', line 99

def init_command
  wrap_shell_code "    id -u hab >/dev/null 2>&1 || sudo -E useradd hab >/dev/null 2>&1\n    rm -rf /tmp/kitchen\n    mkdir -p /tmp/kitchen/results\n    \#{\"mkdir -p /tmp/kitchen/config\" unless config[:override_package_config]}\n  EOH\nend\n"

#install_commandObject



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

def install_command
  raise "Need to fill in some implementation here." if instance.platform == "windows"

  version = " -v #{config[:hab_version]}" unless config[:hab_version].eql?("latest")

  wrap_shell_code "  \#{export_hab_bldr_url}\n  \#{export_hab_license}\n  if command -v hab >/dev/null 2>&1\n  then\n    echo \"Habitat CLI already installed.\"\n  else\n    curl -o /tmp/install.sh 'https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh'\n    sudo -E bash /tmp/install.sh\#{version}\n  fi\n  BASH\nend\n"

#prepare_commandObject



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/kitchen/provisioner/habitat.rb', line 115

def prepare_command
  wrap_shell_code "    \#{export_hab_bldr_url}\n    \#{export_hab_license}\n    \#{install_supervisor_command}\n    \#{binlink_supervisor_command}\n    \#{install_service_package}\n    \#{remove_previous_user_toml}\n    \#{copy_user_toml_to_service_directory}\n  EOH\nend\n"

#run_commandObject



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/kitchen/provisioner/habitat.rb', line 127

def run_command
  run = "  \#{export_hab_bldr_url}\n  \#{export_hab_license}\n  \#{clean_up_screen_sessions}\n  \#{clean_up_previous_supervisor}\n  echo \"Running \#{package_ident}.\"\n  \#{run_package_in_background}\n  RUN\n\n  wrap_shell_code run\nend\n"