Skip to content

Commit

Permalink
Merge pull request #14 from chef/include_chef_cli_gem
Browse files Browse the repository at this point in the history
Include the Chef-cli as gem with the test-kitchen hab package
  • Loading branch information
ashiqueps authored Nov 13, 2024
2 parents dc4a5f1 + c980e2f commit a253ed1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
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

0 comments on commit a253ed1

Please sign in to comment.