chef-cli 5.6.23 → 6.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +20 -12
- data/Rakefile +13 -17
- data/bin/chef-cli +1 -1
- data/chef-cli.gemspec +6 -4
- data/lib/chef-cli/authenticated_http.rb +1 -1
- data/lib/chef-cli/builtin_commands.rb +7 -6
- data/lib/chef-cli/chef_runner.rb +1 -1
- data/lib/chef-cli/chef_server_api_multi.rb +1 -1
- data/lib/chef-cli/cli.rb +1 -1
- data/lib/chef-cli/command/base.rb +1 -1
- data/lib/chef-cli/command/clean_policy_cookbooks.rb +1 -1
- data/lib/chef-cli/command/clean_policy_revisions.rb +1 -1
- data/lib/chef-cli/command/delete_policy.rb +3 -3
- data/lib/chef-cli/command/delete_policy_group.rb +3 -3
- data/lib/chef-cli/command/describe_cookbook.rb +1 -1
- data/lib/chef-cli/command/diff.rb +5 -5
- data/lib/chef-cli/command/env.rb +38 -13
- data/lib/chef-cli/command/exec.rb +3 -2
- data/lib/chef-cli/command/export.rb +1 -1
- data/lib/chef-cli/command/gem.rb +2 -2
- data/lib/chef-cli/command/generate.rb +1 -1
- data/lib/chef-cli/command/generator_commands/attribute.rb +1 -1
- data/lib/chef-cli/command/generator_commands/base.rb +1 -1
- data/lib/chef-cli/command/generator_commands/chef_exts/generator_desc_resource.rb +1 -1
- data/lib/chef-cli/command/generator_commands/chef_exts/quieter_doc_formatter.rb +1 -1
- data/lib/chef-cli/command/generator_commands/chef_exts/recipe_dsl_ext.rb +1 -1
- data/lib/chef-cli/command/generator_commands/cookbook.rb +1 -1
- data/lib/chef-cli/command/generator_commands/cookbook_code_file.rb +1 -1
- data/lib/chef-cli/command/generator_commands/cookbook_file.rb +1 -1
- data/lib/chef-cli/command/generator_commands/generator_generator.rb +1 -1
- data/lib/chef-cli/command/generator_commands/helpers.rb +1 -1
- data/lib/chef-cli/command/generator_commands/input.rb +1 -1
- data/lib/chef-cli/command/generator_commands/policyfile.rb +1 -1
- data/lib/chef-cli/command/generator_commands/profile.rb +1 -1
- data/lib/chef-cli/command/generator_commands/recipe.rb +1 -1
- data/lib/chef-cli/command/generator_commands/repo.rb +1 -1
- data/lib/chef-cli/command/generator_commands/resource.rb +1 -1
- data/lib/chef-cli/command/generator_commands/template.rb +1 -1
- data/lib/chef-cli/command/generator_commands/waiver.rb +1 -1
- data/lib/chef-cli/command/generator_commands.rb +1 -1
- data/lib/chef-cli/command/install.rb +1 -1
- data/lib/chef-cli/command/license.rb +111 -0
- data/lib/chef-cli/command/push.rb +5 -5
- data/lib/chef-cli/command/push_archive.rb +1 -1
- data/lib/chef-cli/command/shell_init.rb +7 -2
- data/lib/chef-cli/command/show_policy.rb +7 -7
- data/lib/chef-cli/command/undelete.rb +3 -3
- data/lib/chef-cli/command/update.rb +1 -1
- data/lib/chef-cli/commands_map.rb +1 -1
- data/lib/chef-cli/completions/bash.sh.erb +1 -1
- data/lib/chef-cli/completions/chef.fish.erb +1 -1
- data/lib/chef-cli/completions/zsh.zsh.erb +1 -1
- data/lib/chef-cli/configurable.rb +1 -1
- data/lib/chef-cli/cookbook_metadata.rb +1 -1
- data/lib/chef-cli/cookbook_omnifetch.rb +3 -3
- data/lib/chef-cli/cookbook_profiler/git.rb +1 -1
- data/lib/chef-cli/cookbook_profiler/identifiers.rb +1 -1
- data/lib/chef-cli/cookbook_profiler/null_scm.rb +1 -1
- data/lib/chef-cli/dist.rb +6 -0
- data/lib/chef-cli/exceptions.rb +1 -1
- data/lib/chef-cli/generator.rb +1 -1
- data/lib/chef-cli/helpers.rb +100 -5
- data/lib/chef-cli/licensing/base.rb +42 -0
- data/lib/chef-cli/licensing/config.rb +26 -0
- data/lib/chef-cli/pager.rb +1 -1
- data/lib/chef-cli/policyfile/artifactory_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/attribute_merge_checker.rb +1 -1
- data/lib/chef-cli/policyfile/chef_repo_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/chef_server_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/chef_server_lock_fetcher.rb +1 -1
- data/lib/chef-cli/policyfile/community_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/comparison_base.rb +1 -1
- data/lib/chef-cli/policyfile/cookbook_location_specification.rb +3 -2
- data/lib/chef-cli/policyfile/cookbook_locks.rb +1 -1
- data/lib/chef-cli/policyfile/cookbook_sources.rb +1 -1
- data/lib/chef-cli/policyfile/delivery_supermarket_source.rb +1 -1
- data/lib/chef-cli/policyfile/differ.rb +1 -1
- data/lib/chef-cli/policyfile/dsl.rb +7 -5
- data/lib/chef-cli/policyfile/git_lock_fetcher.rb +2 -2
- data/lib/chef-cli/policyfile/included_policies_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/lister.rb +1 -1
- data/lib/chef-cli/policyfile/local_lock_fetcher.rb +1 -1
- data/lib/chef-cli/policyfile/lock_applier.rb +1 -1
- data/lib/chef-cli/policyfile/lock_fetcher_mixin.rb +1 -1
- data/lib/chef-cli/policyfile/null_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/policyfile_location_specification.rb +1 -1
- data/lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb +1 -1
- data/lib/chef-cli/policyfile/remote_lock_fetcher.rb +1 -1
- data/lib/chef-cli/policyfile/reports/install.rb +1 -1
- data/lib/chef-cli/policyfile/reports/table_printer.rb +1 -1
- data/lib/chef-cli/policyfile/reports/upload.rb +1 -1
- data/lib/chef-cli/policyfile/solution_dependencies.rb +1 -1
- data/lib/chef-cli/policyfile/source_uri.rb +1 -1
- data/lib/chef-cli/policyfile/storage_config.rb +1 -1
- data/lib/chef-cli/policyfile/undo_record.rb +1 -1
- data/lib/chef-cli/policyfile/undo_stack.rb +1 -1
- data/lib/chef-cli/policyfile/uploader.rb +1 -1
- data/lib/chef-cli/policyfile_compiler.rb +5 -2
- data/lib/chef-cli/policyfile_lock.rb +1 -1
- data/lib/chef-cli/policyfile_services/clean_policies.rb +1 -1
- data/lib/chef-cli/policyfile_services/clean_policy_cookbooks.rb +1 -1
- data/lib/chef-cli/policyfile_services/export_repo.rb +1 -1
- data/lib/chef-cli/policyfile_services/install.rb +1 -1
- data/lib/chef-cli/policyfile_services/push.rb +1 -1
- data/lib/chef-cli/policyfile_services/push_archive.rb +1 -1
- data/lib/chef-cli/policyfile_services/rm_policy.rb +1 -1
- data/lib/chef-cli/policyfile_services/rm_policy_group.rb +1 -1
- data/lib/chef-cli/policyfile_services/show_policy.rb +1 -1
- data/lib/chef-cli/policyfile_services/undelete.rb +1 -1
- data/lib/chef-cli/policyfile_services/update_attributes.rb +1 -1
- data/lib/chef-cli/service_exception_inspectors/base.rb +1 -1
- data/lib/chef-cli/service_exception_inspectors/http.rb +1 -1
- data/lib/chef-cli/service_exception_inspectors.rb +1 -1
- data/lib/chef-cli/service_exceptions.rb +1 -1
- data/lib/chef-cli/shell_out.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README.md +3 -0
- data/lib/chef-cli/skeletons/code_generator/recipes/cookbook.rb +5 -5
- data/lib/chef-cli/skeletons/code_generator/recipes/profile.rb +1 -1
- data/lib/chef-cli/ui.rb +1 -1
- data/lib/chef-cli/version.rb +2 -2
- data/lib/chef-cli.rb +1 -1
- data/lib/kitchen/provisioner/chef_zero_capture.rb +2 -2
- data/lib/kitchen/provisioner/policyfile_zero.rb +2 -2
- data/spec/shared/fixture_cookbook_checksums.rb +1 -1
- data/spec/shared/setup_git_committer_config.rb +1 -1
- data/spec/shared/setup_git_cookbooks.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/test_helpers.rb +1 -1
- data/spec/unit/chef_runner_spec.rb +1 -1
- data/spec/unit/chef_server_api_multi_spec.rb +1 -1
- data/spec/unit/cli_spec.rb +3 -1
- data/spec/unit/command/base_spec.rb +1 -1
- data/spec/unit/command/clean_policy_cookbooks_spec.rb +1 -1
- data/spec/unit/command/clean_policy_revisions_spec.rb +1 -1
- data/spec/unit/command/delete_policy_group_spec.rb +1 -1
- data/spec/unit/command/delete_policy_spec.rb +1 -1
- data/spec/unit/command/diff_spec.rb +1 -1
- data/spec/unit/command/env_spec.rb +132 -2
- data/spec/unit/command/exec_spec.rb +2 -1
- data/spec/unit/command/export_spec.rb +1 -1
- data/spec/unit/command/generate_spec.rb +1 -1
- data/spec/unit/command/generator_commands/attribute_spec.rb +1 -1
- data/spec/unit/command/generator_commands/base_spec.rb +1 -1
- data/spec/unit/command/generator_commands/chef_exts/generator_desc_resource_spec.rb +1 -1
- data/spec/unit/command/generator_commands/chef_exts/recipe_dsl_ext_spec.rb +1 -1
- data/spec/unit/command/generator_commands/cookbook_file_spec.rb +1 -1
- data/spec/unit/command/generator_commands/cookbook_spec.rb +1 -1
- data/spec/unit/command/generator_commands/generator_generator_spec.rb +1 -1
- data/spec/unit/command/generator_commands/helpers_spec.rb +1 -1
- data/spec/unit/command/generator_commands/input_spec.rb +1 -1
- data/spec/unit/command/generator_commands/policyfile_spec.rb +1 -1
- data/spec/unit/command/generator_commands/profile_spec.rb +1 -1
- data/spec/unit/command/generator_commands/recipe_spec.rb +1 -1
- data/spec/unit/command/generator_commands/repo_spec.rb +1 -1
- data/spec/unit/command/generator_commands/resource_spec.rb +1 -1
- data/spec/unit/command/generator_commands/template_spec.rb +1 -1
- data/spec/unit/command/generator_commands/waiver_spec.rb +1 -1
- data/spec/unit/command/install_spec.rb +1 -1
- data/spec/unit/command/license_spec.rb +162 -0
- data/spec/unit/command/push_archive_spec.rb +1 -1
- data/spec/unit/command/push_spec.rb +1 -1
- data/spec/unit/command/shell_init_spec.rb +99 -1
- data/spec/unit/command/show_policy_spec.rb +1 -1
- data/spec/unit/command/undelete_spec.rb +1 -1
- data/spec/unit/command/update_spec.rb +1 -1
- data/spec/unit/commands_map_spec.rb +1 -1
- data/spec/unit/configurable_spec.rb +1 -1
- data/spec/unit/cookbook_metadata_spec.rb +1 -1
- data/spec/unit/cookbook_omnifetch.rb +1 -1
- data/spec/unit/cookbook_profiler/git_spec.rb +1 -1
- data/spec/unit/cookbook_profiler/identifiers_spec.rb +1 -1
- data/spec/unit/generator_spec.rb +1 -1
- data/spec/unit/helpers_spec.rb +35 -2
- data/spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb +1 -1
- data/spec/unit/pager_spec.rb +1 -1
- data/spec/unit/policyfile/artifactory_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/attribute_merge_checker_spec.rb +1 -1
- data/spec/unit/policyfile/chef_repo_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/chef_server_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/chef_server_lock_fetcher_spec.rb +1 -1
- data/spec/unit/policyfile/community_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/comparison_base_spec.rb +1 -1
- data/spec/unit/policyfile/cookbook_location_specification_spec.rb +1 -1
- data/spec/unit/policyfile/cookbook_locks_spec.rb +1 -1
- data/spec/unit/policyfile/delivery_supermarket_source_spec.rb +1 -1
- data/spec/unit/policyfile/differ_spec.rb +7 -7
- data/spec/unit/policyfile/git_lock_fetcher_spec.rb +1 -1
- data/spec/unit/policyfile/included_policies_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/lister_spec.rb +1 -1
- data/spec/unit/policyfile/local_lock_fetcher_spec.rb +1 -1
- data/spec/unit/policyfile/lock_applier_spec.rb +1 -1
- data/spec/unit/policyfile/lock_fetcher_mixin_spec.rb +1 -1
- data/spec/unit/policyfile/null_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +1 -1
- data/spec/unit/policyfile/remote_lock_fetcher_spec.rb +1 -1
- data/spec/unit/policyfile/reports/install_spec.rb +1 -1
- data/spec/unit/policyfile/reports/upload_spec.rb +1 -1
- data/spec/unit/policyfile/solution_dependencies_spec.rb +1 -1
- data/spec/unit/policyfile/source_uri_spec.rb +1 -1
- data/spec/unit/policyfile/storage_config_spec.rb +1 -1
- data/spec/unit/policyfile/undo_record_spec.rb +1 -1
- data/spec/unit/policyfile/undo_stack_spec.rb +1 -1
- data/spec/unit/policyfile/uploader_spec.rb +1 -1
- data/spec/unit/policyfile_demands_spec.rb +3 -1
- data/spec/unit/policyfile_evaluation_spec.rb +1 -1
- data/spec/unit/policyfile_includes_dsl_spec.rb +1 -1
- data/spec/unit/policyfile_includes_spec.rb +1 -1
- data/spec/unit/policyfile_install_with_includes_spec.rb +1 -1
- data/spec/unit/policyfile_lock_build_spec.rb +1 -1
- data/spec/unit/policyfile_lock_install_spec.rb +1 -1
- data/spec/unit/policyfile_lock_serialization_spec.rb +1 -1
- data/spec/unit/policyfile_lock_validation_spec.rb +1 -1
- data/spec/unit/policyfile_services/clean_policies_spec.rb +3 -3
- data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +1 -1
- data/spec/unit/policyfile_services/export_repo_spec.rb +1 -1
- data/spec/unit/policyfile_services/install_spec.rb +1 -1
- data/spec/unit/policyfile_services/push_archive_spec.rb +1 -1
- data/spec/unit/policyfile_services/push_spec.rb +1 -1
- data/spec/unit/policyfile_services/rm_policy_group_spec.rb +1 -1
- data/spec/unit/policyfile_services/rm_policy_spec.rb +1 -1
- data/spec/unit/policyfile_services/show_policy_spec.rb +1 -1
- data/spec/unit/policyfile_services/undelete_spec.rb +1 -1
- data/spec/unit/policyfile_services/update_attributes_spec.rb +1 -1
- data/spec/unit/policyfile_services/update_spec.rb +1 -1
- data/spec/unit/service_exception_inspectors/base_spec.rb +1 -1
- data/spec/unit/service_exception_inspectors/http_spec.rb +1 -1
- data/spec/unit/shell_out_spec.rb +1 -1
- metadata +53 -26
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
2
|
+
# Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -39,6 +39,7 @@ describe ChefCLI::Command::ShellInit do
|
|
|
39
39
|
|
|
40
40
|
before do
|
|
41
41
|
allow(::Dir).to receive(:exist?).and_call_original
|
|
42
|
+
allow(command_instance).to receive(:habitat_install?).and_return(false)
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
context "with no explicit omnibus directory" do
|
|
@@ -98,6 +99,7 @@ describe ChefCLI::Command::ShellInit do
|
|
|
98
99
|
shared_examples "a posix shell script" do |shell|
|
|
99
100
|
before do
|
|
100
101
|
stub_const("File::PATH_SEPARATOR", ":")
|
|
102
|
+
allow(command_instance).to receive(:habitat_install?).and_return(false)
|
|
101
103
|
end
|
|
102
104
|
|
|
103
105
|
let(:expected_environment_commands) do
|
|
@@ -114,6 +116,7 @@ describe ChefCLI::Command::ShellInit do
|
|
|
114
116
|
shared_examples "a powershell script" do |shell|
|
|
115
117
|
before do
|
|
116
118
|
stub_const("File::PATH_SEPARATOR", ";")
|
|
119
|
+
allow(command_instance).to receive(:habitat_install?).and_return(false)
|
|
117
120
|
end
|
|
118
121
|
|
|
119
122
|
let(:expected_environment_commands) do
|
|
@@ -163,8 +166,10 @@ describe ChefCLI::Command::ShellInit do
|
|
|
163
166
|
before do
|
|
164
167
|
# Stub this or else we'd have to update the test every time a new command
|
|
165
168
|
# is added.
|
|
169
|
+
allow(command_instance).to receive(:habitat_install?).and_return(false)
|
|
166
170
|
allow(command_instance.shell_completion_template_context).to receive(:commands)
|
|
167
171
|
.and_return(command_descriptions)
|
|
172
|
+
allow(command_instance.shell_completion_template_context).to receive(:habitat?).and_return(false)
|
|
168
173
|
|
|
169
174
|
allow(command_instance).to receive(:omnibus_embedded_bin_dir).and_return(omnibus_embedded_bin_dir)
|
|
170
175
|
allow(command_instance).to receive(:omnibus_bin_dir).and_return(omnibus_bin_dir)
|
|
@@ -228,6 +233,7 @@ describe ChefCLI::Command::ShellInit do
|
|
|
228
233
|
before do
|
|
229
234
|
# Stub this or else we'd have to update the test every time a new command
|
|
230
235
|
# is added.
|
|
236
|
+
allow(command_instance).to receive(:habitat_install?).and_return(false)
|
|
231
237
|
allow(command_instance.shell_completion_template_context).to receive(:commands)
|
|
232
238
|
.and_return(command_descriptions)
|
|
233
239
|
|
|
@@ -244,8 +250,10 @@ describe ChefCLI::Command::ShellInit do
|
|
|
244
250
|
|
|
245
251
|
context "for fish" do
|
|
246
252
|
before do
|
|
253
|
+
allow(command_instance).to receive(:habitat_install?).and_return(false)
|
|
247
254
|
stub_const("File::PATH_SEPARATOR", ":")
|
|
248
255
|
end
|
|
256
|
+
|
|
249
257
|
let(:expected_path) { [omnibus_bin_dir, user_bin_dir, omnibus_embedded_bin_dir, ENV["PATH"], git_bin_dir].join(":").split(":").join('" "') }
|
|
250
258
|
let(:expected_environment_commands) do
|
|
251
259
|
<<~EOH
|
|
@@ -336,4 +344,94 @@ describe ChefCLI::Command::ShellInit do
|
|
|
336
344
|
|
|
337
345
|
end
|
|
338
346
|
|
|
347
|
+
context "habitat standalone shell-init on bash" do
|
|
348
|
+
let(:cli_hab_path) { "/hab/pkgs/chef/chef-cli/1.0.0/123" }
|
|
349
|
+
|
|
350
|
+
let(:argv) { ["bash"] }
|
|
351
|
+
|
|
352
|
+
before do
|
|
353
|
+
allow(command_instance).to receive(:habitat_chef_dke?).and_return(false)
|
|
354
|
+
allow(command_instance).to receive(:habitat_standalone?).and_return(true)
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
it "should return the correct paths" do
|
|
358
|
+
expect(command_instance).to receive(:get_pkg_prefix).with("chef/chef-cli").twice.and_return(cli_hab_path)
|
|
359
|
+
|
|
360
|
+
command_instance.run(argv)
|
|
361
|
+
expect(stdout_io.string).to include("export PATH=\"#{cli_hab_path}/bin")
|
|
362
|
+
expect(stdout_io.string).to include("export GEM_HOME=\"#{cli_hab_path}/vendor")
|
|
363
|
+
expect(stdout_io.string).to include("export GEM_PATH=\"#{cli_hab_path}/vendor")
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
context "with chef-workstation habitat pkg shell-init on bash" do
|
|
368
|
+
|
|
369
|
+
let(:chef_dke_path) { "/hab/pkgs/chef/chef-workstation/1.0.0/123" }
|
|
370
|
+
let(:cli_hab_path) { "/hab/pkgs/chef/chef-cli/1.0.0/123" }
|
|
371
|
+
|
|
372
|
+
let(:argv) { ["bash"] }
|
|
373
|
+
|
|
374
|
+
before do
|
|
375
|
+
allow(command_instance).to receive(:habitat_chef_dke?).and_return(true)
|
|
376
|
+
allow(command_instance).to receive(:habitat_standalone?).and_return(false)
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
it "should return the correct paths" do
|
|
380
|
+
expect(command_instance).to receive(:get_pkg_prefix).with("chef/chef-workstation").and_return(chef_dke_path)
|
|
381
|
+
expect(command_instance).to receive(:get_pkg_prefix).with("chef/chef-cli").and_return(cli_hab_path)
|
|
382
|
+
|
|
383
|
+
command_instance.run(argv)
|
|
384
|
+
expect(stdout_io.string).to include("export PATH=\"#{chef_dke_path}/bin")
|
|
385
|
+
expect(stdout_io.string).to include("export GEM_HOME=\"#{cli_hab_path}/vendor")
|
|
386
|
+
expect(stdout_io.string).to include("export GEM_PATH=\"#{cli_hab_path}/vendor")
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
describe "autocompletion" do
|
|
390
|
+
let(:command_descriptions) do
|
|
391
|
+
{
|
|
392
|
+
"exec" => "Runs the command in context of the embedded ruby",
|
|
393
|
+
"env" => "Prints environment variables used by #{ChefCLI::Dist::PRODUCT}",
|
|
394
|
+
"gem" => "Runs the `gem` command in context of the embedded ruby",
|
|
395
|
+
"generate" => "Generate a new app, cookbook, or component",
|
|
396
|
+
}
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
let(:omnibus_bin_dir) { "/foo/bin" }
|
|
400
|
+
let(:omnibus_embedded_bin_dir) { "/foo/embedded/bin" }
|
|
401
|
+
|
|
402
|
+
let(:argv) { [ "bash" ] }
|
|
403
|
+
|
|
404
|
+
let(:expected_completion_function) do
|
|
405
|
+
<<~END_COMPLETION
|
|
406
|
+
_chef_comp() {
|
|
407
|
+
local COMMANDS="exec env gem generate"
|
|
408
|
+
COMPREPLY=($(compgen -W "$COMMANDS" -- ${COMP_WORDS[COMP_CWORD]} ))
|
|
409
|
+
}
|
|
410
|
+
complete -F _chef_comp chef-cli
|
|
411
|
+
END_COMPLETION
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
before do
|
|
415
|
+
# Stub this or else we'd have to update the test every time a new command
|
|
416
|
+
# is added.
|
|
417
|
+
allow(command_instance).to receive(:get_pkg_prefix).with("chef/chef-workstation").and_return(chef_dke_path)
|
|
418
|
+
allow(command_instance).to receive(:get_pkg_prefix).with("chef/chef-cli").and_return(cli_hab_path)
|
|
419
|
+
allow(command_instance.shell_completion_template_context).to receive(:commands)
|
|
420
|
+
.and_return(command_descriptions)
|
|
421
|
+
allow(command_instance.shell_completion_template_context).to receive(:habitat?).and_return(true)
|
|
422
|
+
|
|
423
|
+
allow(command_instance).to receive(:omnibus_embedded_bin_dir).and_return(omnibus_embedded_bin_dir)
|
|
424
|
+
allow(command_instance).to receive(:omnibus_bin_dir).and_return(omnibus_bin_dir)
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
it "generates a completion function for the chef command" do
|
|
428
|
+
command_instance.run(argv)
|
|
429
|
+
expect(stdout_io.string).to include(expected_completion_function)
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
it "should generate the autocompletion" do
|
|
433
|
+
|
|
434
|
+
end
|
|
435
|
+
end
|
|
436
|
+
end
|
|
339
437
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: Copyright (c)
|
|
2
|
+
# Copyright:: Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/spec/unit/generator_spec.rb
CHANGED
data/spec/unit/helpers_spec.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
2
2
|
# License:: Apache License, Version 2.0
|
|
3
3
|
#
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -19,6 +19,7 @@ require "chef-cli/helpers"
|
|
|
19
19
|
|
|
20
20
|
describe ChefCLI::Helpers do
|
|
21
21
|
context "path_check!" do
|
|
22
|
+
let(:ruby_path) { "/opt/chef-workstation/embedded/bin/ruby" }
|
|
22
23
|
|
|
23
24
|
before do
|
|
24
25
|
allow(Gem).to receive(:ruby).and_return(ruby_path)
|
|
@@ -38,7 +39,7 @@ describe ChefCLI::Helpers do
|
|
|
38
39
|
let(:expected_GEM_ROOT) { Gem.default_dir }
|
|
39
40
|
let(:expected_GEM_HOME) { Gem.user_dir }
|
|
40
41
|
let(:expected_GEM_PATH) { Gem.path.join(File::PATH_SEPARATOR) }
|
|
41
|
-
|
|
42
|
+
|
|
42
43
|
|
|
43
44
|
it "#omnibus_env path" do
|
|
44
45
|
allow(ChefCLI::Helpers).to receive(:omnibus_bin_dir).and_return("/opt/chef-workstation/bin")
|
|
@@ -107,5 +108,37 @@ describe ChefCLI::Helpers do
|
|
|
107
108
|
end
|
|
108
109
|
|
|
109
110
|
end
|
|
111
|
+
|
|
112
|
+
context "when installed with habitat" do
|
|
113
|
+
let(:chef_dke_path) { "/hab/pkgs/chef/chef-workstation/1.0.0/123" }
|
|
114
|
+
let(:cli_hab_path) { "/hab/pkgs/chef/chef-cli/1.0.0/123" }
|
|
115
|
+
let(:expected_gem_root) { Gem.default_dir }
|
|
116
|
+
let(:expected_path) { [File.join(chef_dke_path, "bin"), File.join(cli_hab_path, "vendor", "bin"), "/usr/bin:/bin"].flatten }
|
|
117
|
+
let(:expected_env) do
|
|
118
|
+
{
|
|
119
|
+
"PATH" => expected_path.join(File::PATH_SEPARATOR),
|
|
120
|
+
"GEM_ROOT" => expected_gem_root,
|
|
121
|
+
"GEM_HOME" => "#{cli_hab_path}/vendor",
|
|
122
|
+
"GEM_PATH" => "#{cli_hab_path}/vendor",
|
|
123
|
+
}
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
before do
|
|
127
|
+
allow(ChefCLI::Helpers).to receive(:habitat_chef_dke?).and_return true
|
|
128
|
+
allow(ChefCLI::Helpers).to receive(:habitat_standalone?).and_return false
|
|
129
|
+
allow(ENV).to receive(:[]).with("PATH").and_return("/usr/bin:/bin")
|
|
130
|
+
allow(ENV).to receive(:[]).with("CHEF_CLI_VERSION").and_return(nil)
|
|
131
|
+
allow(Dir).to receive(:exist?).with("#{cli_hab_path}/vendor").and_return(true) # <-- Add this line
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "should return the habitat env" do
|
|
135
|
+
allow(ChefCLI::Helpers).to receive(:fetch_chef_cli_version_pkg).and_return(nil) # Ensure no version override
|
|
136
|
+
expect(ChefCLI::Helpers).to receive(:get_pkg_prefix).with("chef/chef-workstation").and_return(chef_dke_path)
|
|
137
|
+
expect(ChefCLI::Helpers).to receive(:get_pkg_prefix).with("chef/chef-cli").and_return(cli_hab_path)
|
|
138
|
+
|
|
139
|
+
expect(ChefCLI::Helpers.habitat_env).to eq(expected_env)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
110
143
|
end
|
|
111
144
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#
|
|
2
2
|
# Author:: Marc Paradsie <marc.paradise@gmail.com>
|
|
3
3
|
#
|
|
4
|
-
# Copyright (
|
|
4
|
+
# Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
data/spec/unit/pager_spec.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
2
|
+
# Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -325,7 +325,7 @@ describe ChefCLI::Policyfile::Differ do
|
|
|
325
325
|
RUN LIST CHANGED
|
|
326
326
|
================
|
|
327
327
|
|
|
328
|
-
@@ -1,
|
|
328
|
+
@@ -1,4 +1,6 @@
|
|
329
329
|
recipe[java::default]
|
|
330
330
|
recipe[jenkins::master]
|
|
331
331
|
-recipe[policyfile_demo::whatever]
|
|
@@ -382,7 +382,7 @@ describe ChefCLI::Policyfile::Differ do
|
|
|
382
382
|
recipe[c::default]
|
|
383
383
|
recipe[d::default]
|
|
384
384
|
recipe[e::default]
|
|
385
|
-
@@ -12,
|
|
385
|
+
@@ -12,3 +11,7 @@
|
|
386
386
|
recipe[l::default]
|
|
387
387
|
recipe[m::default]
|
|
388
388
|
recipe[n::default]
|
|
@@ -438,7 +438,7 @@ describe ChefCLI::Policyfile::Differ do
|
|
|
438
438
|
apt
|
|
439
439
|
---
|
|
440
440
|
|
|
441
|
-
@@ -1,
|
|
441
|
+
@@ -1,11 +0,0 @@
|
|
442
442
|
-{
|
|
443
443
|
- "version": "2.7.0",
|
|
444
444
|
- "identifier": "16c57abbd056543f7d5a15dabbb03261024a9c5e",
|
|
@@ -511,7 +511,7 @@ describe ChefCLI::Policyfile::Differ do
|
|
|
511
511
|
bluepill
|
|
512
512
|
--------
|
|
513
513
|
|
|
514
|
-
@@ -
|
|
514
|
+
@@ -0,0 +1,11 @@
|
|
515
515
|
+{
|
|
516
516
|
+ "version": "2.3.2",
|
|
517
517
|
+ "identifier": "9c6990944d9a347dec8bd375e707ba0aecdc17cd",
|
|
@@ -623,7 +623,7 @@ describe ChefCLI::Policyfile::Differ do
|
|
|
623
623
|
DEFAULT ATTRIBUTES CHANGED
|
|
624
624
|
==========================
|
|
625
625
|
|
|
626
|
-
@@ -1,
|
|
626
|
+
@@ -1,3 +1,4 @@
|
|
627
627
|
{
|
|
628
628
|
- "greeting": "Attributes, f*** yeah"
|
|
629
629
|
+ "greeting": "Attributes, f*** yeah",
|
|
@@ -669,7 +669,7 @@ describe ChefCLI::Policyfile::Differ do
|
|
|
669
669
|
OVERRIDE ATTRIBUTES CHANGED
|
|
670
670
|
===========================
|
|
671
671
|
|
|
672
|
-
@@ -1,
|
|
672
|
+
@@ -1,3 +1,4 @@
|
|
673
673
|
{
|
|
674
674
|
- "attr_only_updating": "use -a"
|
|
675
675
|
+ "attr_only_updating": "use -a",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
2
|
+
# Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -209,6 +209,8 @@ describe ChefCLI::PolicyfileCompiler, "when expressing the Policyfile graph dema
|
|
|
209
209
|
|
|
210
210
|
instance_double("ChefCLI::Policyfile::CookbookLocationSpecification",
|
|
211
211
|
name: "remote-cb",
|
|
212
|
+
version: "1.1.1",
|
|
213
|
+
source_options: remote_cb_source_opts,
|
|
212
214
|
version_constraint: Semverse::Constraint.new("= 1.1.1"),
|
|
213
215
|
ensure_cached: nil,
|
|
214
216
|
to_s: s)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: Copyright (c)
|
|
2
|
+
# Copyright:: Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|