Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the Chef-cli as gem with the test-kitchen hab package #14

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,27 @@ do_install() {
build_line "Setting GEM_PATH=$GEM_HOME"
export GEM_PATH="$GEM_HOME"
gem install chef-test-kitchen-enterprise-*.gem --no-document
wrap_ruby_bin
gem install chef-cli
wrap_ruby_kitchen
wrap_ruby_chef_cli
set_runtime_env "GEM_PATH" "${pkg_prefix}/vendor/gems"
}

wrap_ruby_bin() {
wrap_ruby_kitchen() {
local bin="$pkg_prefix/bin/kitchen"
local real_bin="$GEM_HOME/gems/chef-test-kitchen-enterprise-${pkg_version}/bin/kitchen"
wrap_bin_with_ruby "$bin" "$real_bin"
}

wrap_ruby_chef_cli() {
local bin="$pkg_prefix/bin/chef-cli"
local real_bin="$GEM_HOME/bin/chef-cli"
wrap_bin_with_ruby "$bin" "$real_bin"
}

wrap_bin_with_ruby() {
local bin="$1"
local real_bin="$2"
build_line "Adding wrapper $bin to $real_bin"
cat <<EOF > "$bin"
#!$(pkg_path_for core/bash)/bin/bash
Expand All @@ -71,14 +85,14 @@ set -e
export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:\$PATH"

# Set Ruby paths defined from 'do_setup_environment()'
export GEM_HOME="$pkg_prefix/vendor/gems"
export GEM_HOME="$pkg_prefix/vendor/gems"
export GEM_PATH="\$GEM_HOME"

export GEM_PATH="$GEM_HOME"
exec $(pkg_path_for $_chef_client_ruby)/bin/ruby $real_bin \$@
EOF
chmod -v 755 "$bin"
}

do_strip() {
return 0
}
}
2 changes: 1 addition & 1 deletion lib/kitchen/provisioner/chef_infra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def prepare_command
file_content = "nonce:#{nonce}\ntimestamp:#{timestamp}\nsignature:#{signature}"
file_location = config[:root_path] + "/#{context_key}"

sudo("echo '#{file_content}' > #{file_location}")
"echo '#{file_content}' > #{file_location}"
end

def run_command
Expand Down
Loading