Skip to content
Open
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
3 changes: 2 additions & 1 deletion habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ wrap_ruby_bin() {
set -e

# Set binary path that allows InSpec to use non-Hab pkg binaries
export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:$pkg_prefix/vendor/bin:\$PATH"
# Include Ruby bin directory so chef-cli exec can find gem, etc.
export PATH="$(pkg_path_for ${ruby_pkg})/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:$pkg_prefix/vendor/bin:\$PATH"

# Set Ruby paths defined from 'do_setup_environment()'
export GEM_HOME="$pkg_prefix/vendor"
Expand Down
4 changes: 2 additions & 2 deletions lib/chef-cli/command/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Base
option :version,
short: "-v",
long: "--version",
description: "Show #{ChefCLI::Dist::PRODUCT} version",
description: "Show #{ChefCLI::Dist::CLI_PRODUCT} version",
boolean: true

option :debug,
Expand Down Expand Up @@ -67,7 +67,7 @@ def run_with_default_options(enforce_license, params = [ ])
msg(opt_parser.to_s)
0
elsif needs_version?(params)
msg("#{ChefCLI::Dist::PRODUCT} version: #{ChefCLI::VERSION}")
msg("#{ChefCLI::Dist::CLI_PRODUCT} version: #{ChefCLI::VERSION}")
0
else
check_license_acceptance if enforce_license
Expand Down
2 changes: 1 addition & 1 deletion lib/chef-cli/command/clean_policy_cookbooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CleanPolicyCookbooks < Base
`#{ChefCLI::Dist::EXEC} clean-policy-cookbooks` deletes unused Policyfile cookbooks. Cookbooks
are considered unused when they are not referenced by any Policyfile revision
on the #{ChefCLI::Dist::SERVER_PRODUCT}. Note that cookbooks which are referenced by "orphaned" policy
revisions are not removed, so you may wish to run `chef clean-policy-revisions`
revisions are not removed, so you may wish to run `chef-cli clean-policy-revisions`
to remove orphaned policies before running this command.

See our detailed README for more information:
Expand Down
2 changes: 1 addition & 1 deletion lib/chef-cli/command/delete_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DeletePolicy < Base

`#{ChefCLI::Dist::EXEC} delete-policy POLICY_NAME` deletes all revisions of the policy
`POLICY_NAME` on the configured #{ChefCLI::Dist::SERVER_PRODUCT}. All policy revisions will be
backed up locally, allowing you to undo this operation via the `chef undelete`
backed up locally, allowing you to undo this operation via the `chef-cli undelete`
command.

See our detailed README for more information:
Expand Down
2 changes: 1 addition & 1 deletion lib/chef-cli/command/delete_policy_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DeletePolicyGroup < Base
`#{ChefCLI::Dist::EXEC} delete-policy-group POLICY_GROUP` deletes the policy group POLICY_GROUP on
the configured #{ChefCLI::Dist::SERVER_PRODUCT}. Policy Revisions associated to the policy group are
not deleted. The state of the policy group will be backed up locally, allowing
you to undo this operation via the `chef undelete` command.
you to undo this operation via the `chef-cli undelete` command.

See our detailed README for more information:

Expand Down
2 changes: 1 addition & 1 deletion lib/chef-cli/command/push_archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PushArchive < Base
Usage: #{ChefCLI::Dist::EXEC} push-archive POLICY_GROUP ARCHIVE_FILE [options]

`#{ChefCLI::Dist::EXEC} push-archive` publishes a policy archive to a #{ChefCLI::Dist::SERVER_PRODUCT}. Policy
archives can be created with `chef export -a`. The policy will be applied to
archives can be created with `chef-cli export -a`. The policy will be applied to
the given POLICY_GROUP, which is a set of nodes that share the same
run_list and cookbooks.

Expand Down
6 changes: 3 additions & 3 deletions lib/chef-cli/command/undelete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ class Undelete < Base

`#{ChefCLI::Dist::EXEC} undelete` helps you recover quickly if you've deleted a policy or policy
group in error. When run with no arguements, it lists the available undo
operations. To undo the last delete operation, use `chef undelete --last`.
operations. To undo the last delete operation, use `chef-cli undelete --last`.

CAVEATS:
`#{ChefCLI::Dist::EXEC} undelete` doesn't detect conflicts. If a deleted item has been recreated,
running `chef undelete` will overwrite it.
running `chef-cli undelete` will overwrite it.

Undo information does not include cookbooks that might be referenced by
policies. If you have cleaned the policy cookbooks after the delete operation
you want to reverse, `chef undelete` may not be able to fully restore the
you want to reverse, `chef-cli undelete` may not be able to fully restore the
previous state.

The delete commands also do not store access control data, so you may have to
Expand Down
4 changes: 2 additions & 2 deletions lib/chef-cli/dist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Dist
WORKFLOW = "Chef Workflow (Delivery)".freeze

# The chef executable, as in `chef gem install` or `chef generate cookbook`
EXEC = "chef".freeze
EXEC = "chef-cli".freeze

# Chef-Zero's product name
ZERO_PRODUCT = "Chef Infra Zero".freeze
Expand All @@ -50,6 +50,6 @@ class Dist

# Workstation banner/help text
WORKSTATION_DOCS = "https://docs.chef.io/workstation/".freeze
WORKSTATION_HEADER = "The Chef command line tool for managing your infrastructure from your workstation.".freeze
WORKSTATION_HEADER = "This command line tool is used for managing your infrastructure from your workstation.".freeze
end
end
4 changes: 3 additions & 1 deletion lib/chef-cli/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ def habitat_env(show_warning: false)
raise "Error: Could not determine the vendor package prefix. Ensure #{ChefCLI::Dist::HAB_PKG_NAME} is installed and CHEF_CLI_VERSION is set correctly." unless vendor_pkg_prefix

vendor_dir = File.join(vendor_pkg_prefix, "vendor")
# Construct PATH
# Construct PATH including Ruby bin directory for chef-cli exec command
ruby_bin_dir = File.dirname(RbConfig.ruby)
path = [
File.join(bin_pkg_prefix, "bin"),
File.join(vendor_dir, "bin"),
ruby_bin_dir, # Add Ruby bin directory so exec can find gem etc.
ENV["PATH"].split(File::PATH_SEPARATOR), # Preserve existing PATH
].flatten.uniq

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ the same filename as the name set in the policyfile itself, and use the
Compile the policy with a command like this:

```
chef install policyfiles/my-app-frontend.rb
chef-cli install policyfiles/my-app-frontend.rb
```

This will create a lockfile `policyfiles/my-app-frontend.lock.json`.

To update locked dependencies, run `chef update` like this:
To update locked dependencies, run `chef-cli update` like this:

```
chef update policyfiles/my-app-frontend.rb
chef-cli update policyfiles/my-app-frontend.rb
```

You can upload the policy (with associated cookbooks) to the server
using a command like:

```
chef push staging policyfiles/my-app-frontend.rb
chef-cli push staging policyfiles/my-app-frontend.rb
```
4 changes: 2 additions & 2 deletions spec/shared/a_file_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def generator_context
let(:argv) { [] }

it "emits an error message and exits" do
expected_stdout = "Usage: chef generate #{generator_name} [path/to/cookbook] NAME [options]"
expected_stdout = "Usage: chef-cli generate #{generator_name} [path/to/cookbook] NAME [options]"

expect(recipe_generator.run).to eq(1)
expect(stdout).to include(expected_stdout)
Expand Down Expand Up @@ -85,7 +85,7 @@ def generator_context
let(:argv) { [ new_file_name ] }

it "emits an error message and exits" do
expected_stdout = "Usage: chef generate #{generator_name} [path/to/cookbook] NAME [options]"
expected_stdout = "Usage: chef-cli generate #{generator_name} [path/to/cookbook] NAME [options]"
expected_stderr = "Error: Directory #{Dir.pwd} is not a cookbook\n"

expect(recipe_generator.run).to eq(1)
Expand Down
14 changes: 7 additions & 7 deletions spec/unit/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def stderr
Patents: #{ChefCLI::Dist::PATENTS}

Usage:
chef -h/--help
chef -v/--version
chef command [arguments...] [options...]
chef-cli -h/--help
chef-cli -v/--version
chef-cli command [arguments...] [options...]

Available Commands:
gem Runs the `gem` command in context of the embedded ruby
Expand Down Expand Up @@ -290,7 +290,7 @@ def test_result
run_cli_with_sanity_check(0)
expect(stdout).to eq(base_help_message)
expect(stderr).to include("please reverse that order")
expect(stderr).to include("chef shell-init")
expect(stderr).to include("chef-cli shell-init")
end

it "complains if only embedded is present" do
Expand All @@ -300,7 +300,7 @@ def test_result
run_cli_with_sanity_check(0)
expect(stdout).to eq(base_help_message)
expect(stderr).to include("you must add")
expect(stderr).to include("chef shell-init")
expect(stderr).to include("chef-cli shell-init")
end

it "passes when both are present in the correct order" do
Expand Down Expand Up @@ -349,7 +349,7 @@ def test_result
run_cli_with_sanity_check(0)
expect(stdout).to eq(base_help_message)
expect(stderr).to include("please reverse that order")
expect(stderr).to include("chef shell-init")
expect(stderr).to include("chef-cli shell-init")
end

it "complains if only embedded is present" do
Expand All @@ -359,7 +359,7 @@ def test_result
run_cli_with_sanity_check(0)
expect(stdout).to eq(base_help_message)
expect(stderr).to include("you must add")
expect(stderr).to include("chef shell-init")
expect(stderr).to include("chef-cli shell-init")
end

it "passes when both are present in the correct order" do
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/command/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def run_command(options)

it "should print the version for -v" do
run_command(["-v"])
expect(stdout).to eq("#{ChefCLI::Dist::PRODUCT} version: #{ChefCLI::VERSION}\n")
expect(stdout).to eq("#{ChefCLI::Dist::CLI_PRODUCT} version: #{ChefCLI::VERSION}\n")
end

it "should print the version for --version" do
run_command(["--version"])
expect(stdout).to eq("#{ChefCLI::Dist::PRODUCT} version: #{ChefCLI::VERSION}\n")
expect(stdout).to eq("#{ChefCLI::Dist::CLI_PRODUCT} version: #{ChefCLI::VERSION}\n")
end

it "should run the command passing in the custom options for long custom options" do
Expand Down Expand Up @@ -131,7 +131,7 @@ def run_command(options)
-D, --debug Enable stacktraces and other debug output
-h, --help Show this message
-u, --user If the user exists
-v, --version Show #{ChefCLI::Dist::PRODUCT} version
-v, --version Show #{ChefCLI::Dist::CLI_PRODUCT} version

E
expect(stdout).to eq(expected)
Expand All @@ -154,7 +154,7 @@ def run_command(options)
-D, --debug Enable stacktraces and other debug output
-h, --help Show this message
-u, --user If the user exists
-v, --version Show #{ChefCLI::Dist::PRODUCT} version
-v, --version Show #{ChefCLI::Dist::CLI_PRODUCT} version

E
expect(stdout).to eq(expected)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/command/env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
let(:omnibus_bin_dir) { "/foo/bin" }

it "has a usage banner" do
expect(command_instance.banner).to eq("Usage: chef env")
expect(command_instance.banner).to eq("Usage: chef-cli env")
end

describe "when running from within an omnibus install" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/command/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run_command
end

it "has a usage banner" do
expect(command_instance.banner).to eq("Usage: chef exec SYSTEM_COMMAND")
expect(command_instance.banner).to eq("Usage: chef-cli exec SYSTEM_COMMAND")
end

describe "when locating omnibus directory" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/command/generate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def stderr
context "with a generator defined" do
let(:expected_help_message) do
<<~E
Usage: chef generate GENERATOR [options]
Usage: chef-cli generate GENERATOR [options]

Available generators:
example this is a test
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/command/generator_commands/cookbook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def generator_context
context "when given invalid/incomplete arguments" do

let(:expected_help_message) do
"Usage: chef generate cookbook NAME [options]\n"
"Usage: chef-cli generate cookbook NAME [options]\n"
end

def with_argv(argv)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/command/generator_commands/policyfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def generator_context
let(:argv) { %w{ foo bar baz } }

it "shows usage and exits" do
expected_stdout = "Usage: chef generate policyfile [NAME] [options]"
expected_stdout = "Usage: chef-cli generate policyfile [NAME] [options]"

expect(generator.run).to eq(1)
expect(stderr).to include(expected_stdout)
Expand Down
3 changes: 2 additions & 1 deletion spec/unit/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@
context "when installed with habitat" do
let(:chef_dke_path) { "/hab/pkgs/chef/chef-workstation/1.0.0/123" }
let(:cli_hab_path) { "/hab/pkgs/chef/chef-cli/1.0.0/123" }
let(:ruby_bin_dir) { File.dirname(RbConfig.ruby) }
let(:expected_gem_root) { Gem.default_dir }
let(:expected_path) { [File.join(chef_dke_path, "bin"), File.join(cli_hab_path, "vendor", "bin"), "/usr/bin:/bin"].flatten }
let(:expected_path) { [File.join(chef_dke_path, "bin"), File.join(cli_hab_path, "vendor", "bin"), ruby_bin_dir, "/usr/bin:/bin"].flatten }
let(:expected_env) do
{
"PATH" => expected_path.join(File::PATH_SEPARATOR),
Expand Down
Loading