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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright:: Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
# License:: Apache License, Version 2.0
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
require_relative "base"
|
|
21
|
+
require "chef-cli/licensing/base"
|
|
22
|
+
require_relative "../configurable"
|
|
23
|
+
|
|
24
|
+
module ChefCLI
|
|
25
|
+
module Command
|
|
26
|
+
|
|
27
|
+
# This class will manage the license command in the chef-cli
|
|
28
|
+
class License < Base
|
|
29
|
+
|
|
30
|
+
include Configurable
|
|
31
|
+
|
|
32
|
+
MAIN_COMMAND_HELP = <<~HELP.freeze
|
|
33
|
+
Usage: #{ChefCLI::Dist::EXEC} license [SUBCOMMAND]
|
|
34
|
+
|
|
35
|
+
`#{ChefCLI::Dist::EXEC} license` command will validate the existing license
|
|
36
|
+
or will help you interactively generate new free/trial license and activate the
|
|
37
|
+
commercial license the chef team has sent you through email.
|
|
38
|
+
HELP
|
|
39
|
+
|
|
40
|
+
SUB_COMMANDS = [
|
|
41
|
+
{ name: "list", description: "List details of the license(s) installed on the system." },
|
|
42
|
+
{ name: "add", description: "Create & install a Free/ Trial license or install a Commercial license on the system." },
|
|
43
|
+
].freeze
|
|
44
|
+
|
|
45
|
+
option :chef_license_key,
|
|
46
|
+
long: "--chef-license-key LICENSE",
|
|
47
|
+
description: "New license key to accept and store in the system"
|
|
48
|
+
|
|
49
|
+
attr_accessor :ui
|
|
50
|
+
|
|
51
|
+
def self.banner
|
|
52
|
+
<<~BANNER
|
|
53
|
+
#{MAIN_COMMAND_HELP}
|
|
54
|
+
Subcommands:
|
|
55
|
+
#{SUB_COMMANDS.map do |c|
|
|
56
|
+
" #{c[:name].ljust(7)}#{c[:description]}"
|
|
57
|
+
end.join("\n") }
|
|
58
|
+
|
|
59
|
+
Options:
|
|
60
|
+
BANNER
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def initialize
|
|
64
|
+
super
|
|
65
|
+
|
|
66
|
+
@ui = UI.new
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def run(params)
|
|
70
|
+
config_license_debug if debug?
|
|
71
|
+
remaining_args = parse_options(params)
|
|
72
|
+
return 1 unless validate_params!(remaining_args)
|
|
73
|
+
|
|
74
|
+
if remaining_args.empty?
|
|
75
|
+
ChefCLI::Licensing::Base.validate
|
|
76
|
+
else
|
|
77
|
+
ChefCLI::Licensing::Base.send(remaining_args[0])
|
|
78
|
+
end
|
|
79
|
+
rescue ChefLicensing::LicenseKeyFetcher::LicenseKeyNotFetchedError
|
|
80
|
+
ui.msg("License key not fetched. Please try again.")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def debug?
|
|
84
|
+
!!config[:debug]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def validate_params!(args)
|
|
88
|
+
if args.length > 1
|
|
89
|
+
ui.err("Too many arguments")
|
|
90
|
+
return false
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
valid_subcommands = SUB_COMMANDS.collect { |c| c[:name] }
|
|
94
|
+
args.each do |arg|
|
|
95
|
+
next if valid_subcommands.include?(arg)
|
|
96
|
+
|
|
97
|
+
ui.err("Invalid option: #{arg}")
|
|
98
|
+
return false
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
true
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
private
|
|
105
|
+
|
|
106
|
+
def config_license_debug
|
|
107
|
+
ChefLicensing.output = ui
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -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");
|
|
@@ -84,10 +84,10 @@ module ChefCLI
|
|
|
84
84
|
|
|
85
85
|
def push
|
|
86
86
|
@push ||= PolicyfileServices::Push.new(policyfile: policyfile_relative_path,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
ui:,
|
|
88
|
+
policy_group:,
|
|
89
|
+
config: chef_config,
|
|
90
|
+
root_dir: Dir.pwd)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def handle_error(error)
|
|
@@ -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");
|
|
@@ -29,6 +29,7 @@ end
|
|
|
29
29
|
module ChefCLI
|
|
30
30
|
|
|
31
31
|
class ShellCompletionTemplateContext
|
|
32
|
+
include ChefCLI::Helpers
|
|
32
33
|
|
|
33
34
|
def commands
|
|
34
35
|
ChefCLI.commands_map.command_specs.inject({}) do |cmd_info, (_key, cmd_spec)|
|
|
@@ -40,6 +41,10 @@ module ChefCLI
|
|
|
40
41
|
def get_binding
|
|
41
42
|
binding
|
|
42
43
|
end
|
|
44
|
+
|
|
45
|
+
def habitat?
|
|
46
|
+
habitat_install?
|
|
47
|
+
end
|
|
43
48
|
end
|
|
44
49
|
|
|
45
50
|
module Command
|
|
@@ -103,7 +108,7 @@ module ChefCLI
|
|
|
103
108
|
return 1
|
|
104
109
|
end
|
|
105
110
|
|
|
106
|
-
env = omnibus_env.dup
|
|
111
|
+
env = (habitat_install? ? habitat_env : omnibus_env).dup
|
|
107
112
|
path = env.delete("PATH")
|
|
108
113
|
export(shell_name, "PATH", path)
|
|
109
114
|
env.each do |var_name, value|
|
|
@@ -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");
|
|
@@ -87,12 +87,12 @@ module ChefCLI
|
|
|
87
87
|
def show_policy_service
|
|
88
88
|
@policy_list_service ||=
|
|
89
89
|
PolicyfileServices::ShowPolicy.new(config: chef_config,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
ui:,
|
|
91
|
+
policy_name:,
|
|
92
|
+
policy_group:,
|
|
93
|
+
show_orphans: show_orphans?,
|
|
94
|
+
summary_diff: show_summary_diff?,
|
|
95
|
+
pager: enable_pager?)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def debug?
|
|
@@ -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");
|
|
@@ -93,8 +93,8 @@ module ChefCLI
|
|
|
93
93
|
def undelete_service
|
|
94
94
|
@undelete_service ||=
|
|
95
95
|
PolicyfileServices::Undelete.new(config: chef_config,
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
ui:,
|
|
97
|
+
undo_record_id:)
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
def debug?
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
set -l chef_commands <%= commands.keys.join(' ') %>;
|
|
6
6
|
|
|
7
7
|
<% commands.each do |command, desc| -%>
|
|
8
|
-
complete -c chef -f -n "not __fish_seen_subcommand_from $chef_commands" -a <%= command %> -d "<%= desc %>";
|
|
8
|
+
complete -c <%= habitat? ? "chef-cli" : "chef" %> -f -n "not __fish_seen_subcommand_from $chef_commands" -a <%= command %> -d "<%= desc %>";
|
|
9
9
|
<% end -%>
|
|
@@ -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");
|
|
@@ -40,7 +40,7 @@ CookbookOmnifetch.configure do |c|
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
ChefCLI::ChefServerAPIMulti.new(Chef::Config.chef_server_url,
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
signing_key_filename: Chef::Config.client_key,
|
|
44
|
+
client_name: Chef::Config.node_name)
|
|
45
45
|
end
|
|
46
46
|
end
|
data/lib/chef-cli/dist.rb
CHANGED
|
@@ -6,10 +6,16 @@ module ChefCLI
|
|
|
6
6
|
PRODUCT = "Chef Workstation".freeze
|
|
7
7
|
PRODUCT_PKG_HOME = "chef-workstation".freeze
|
|
8
8
|
|
|
9
|
+
CHEF_DK_CLI_PACKAGE = "Chef Workstation".freeze
|
|
10
|
+
CHEF_CLI_PACKAGE = "Chef-Cli".freeze
|
|
11
|
+
|
|
9
12
|
# the name of the chef-cli gem
|
|
10
13
|
CLI_PRODUCT = "Chef CLI".freeze
|
|
11
14
|
CLI_GEM = "chef-cli".freeze
|
|
12
15
|
|
|
16
|
+
CHEF_DKE_PKG_NAME = "chef/chef-workstation".freeze
|
|
17
|
+
HAB_PKG_NAME = "chef/chef-cli".freeze
|
|
18
|
+
|
|
13
19
|
# the name of the overall infra product
|
|
14
20
|
INFRA_PRODUCT = "Chef Infra".freeze
|
|
15
21
|
|
data/lib/chef-cli/exceptions.rb
CHANGED
data/lib/chef-cli/generator.rb
CHANGED
data/lib/chef-cli/helpers.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");
|
|
@@ -60,6 +60,21 @@ module ChefCLI
|
|
|
60
60
|
File.exist?(expected_omnibus_root) && File.exist?(File.join(expected_omnibus_root, "version-manifest.json"))
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
+
# The habitat version of the chef-cli can be installed with standalone or chef-workstation
|
|
64
|
+
# This method checks if the habitat version of chef-cli is installed as standalone
|
|
65
|
+
def habitat_standalone?
|
|
66
|
+
@hab_standalone ||= (hab_pkg_installed?(ChefCLI::Dist::HAB_PKG_NAME) && !habitat_chef_dke?)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# This method checks if the habitat version of chef-cli is installed with chef-workstation
|
|
70
|
+
def habitat_chef_dke?
|
|
71
|
+
@hab_dke ||= hab_pkg_installed?(ChefCLI::Dist::CHEF_DKE_PKG_NAME)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def habitat_install?
|
|
75
|
+
habitat_chef_dke? || habitat_standalone?
|
|
76
|
+
end
|
|
77
|
+
|
|
63
78
|
def omnibus_root
|
|
64
79
|
@omnibus_root ||= omnibus_expand_path(expected_omnibus_root)
|
|
65
80
|
end
|
|
@@ -83,6 +98,32 @@ module ChefCLI
|
|
|
83
98
|
end
|
|
84
99
|
end
|
|
85
100
|
|
|
101
|
+
# Function to return the Chef CLI path based on standalone or Chef-DKE-enabled package
|
|
102
|
+
def get_pkg_install_path
|
|
103
|
+
# Check Chef-DKE package path
|
|
104
|
+
chef_dk_path = get_pkg_prefix(ChefCLI::Dist::CHEF_DKE_PKG_NAME)
|
|
105
|
+
return chef_dk_path if chef_dk_path
|
|
106
|
+
|
|
107
|
+
# Check Standalone Chef-CLI package path
|
|
108
|
+
chef_cli_path = fetch_chef_cli_version_pkg || get_pkg_prefix(ChefCLI::Dist::HAB_PKG_NAME)
|
|
109
|
+
chef_cli_path
|
|
110
|
+
|
|
111
|
+
rescue => e
|
|
112
|
+
ChefCLI::UI.new.err("Error fetching Chef-CLI path: #{e.message}")
|
|
113
|
+
nil
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Check Standalone Chef-cli environment variable for version
|
|
117
|
+
def fetch_chef_cli_version_pkg
|
|
118
|
+
chef_cli_version = ENV["CHEF_CLI_VERSION"]
|
|
119
|
+
return unless chef_cli_version
|
|
120
|
+
|
|
121
|
+
pkg_path = get_pkg_prefix("#{ChefCLI::Dist::HAB_PKG_NAME}/#{chef_cli_version}")
|
|
122
|
+
return pkg_path if pkg_path && Dir.exist?(pkg_path)
|
|
123
|
+
|
|
124
|
+
nil
|
|
125
|
+
end
|
|
126
|
+
|
|
86
127
|
# Returns the directory that contains our main symlinks.
|
|
87
128
|
# On Mac we place all of our symlinks under /usr/local/bin on other
|
|
88
129
|
# platforms they are under /usr/bin
|
|
@@ -110,6 +151,44 @@ module ChefCLI
|
|
|
110
151
|
@git_windows_bin_dir ||= File.expand_path(File.join(omnibus_root, "embedded", "git", "usr", "bin"))
|
|
111
152
|
end
|
|
112
153
|
|
|
154
|
+
#
|
|
155
|
+
# environment vars for habitat
|
|
156
|
+
#
|
|
157
|
+
def habitat_env(show_warning: false)
|
|
158
|
+
@habitat_env ||= begin
|
|
159
|
+
if habitat_chef_dke?
|
|
160
|
+
bin_pkg_prefix = get_pkg_prefix(ChefCLI::Dist::CHEF_DKE_PKG_NAME)
|
|
161
|
+
end
|
|
162
|
+
versioned_pkg_prefix = fetch_chef_cli_version_pkg if ENV["CHEF_CLI_VERSION"]
|
|
163
|
+
|
|
164
|
+
if show_warning && ENV["CHEF_CLI_VERSION"] && !versioned_pkg_prefix
|
|
165
|
+
ChefCLI::UI.new.msg("Warning: Habitat package '#{ChefCLI::Dist::HAB_PKG_NAME}' with version '#{ENV["CHEF_CLI_VERSION"]}' not found.")
|
|
166
|
+
end
|
|
167
|
+
# Use the first available package for bin_pkg_prefix
|
|
168
|
+
bin_pkg_prefix ||= versioned_pkg_prefix || get_pkg_prefix(ChefCLI::Dist::HAB_PKG_NAME)
|
|
169
|
+
raise "Error: Could not determine the Habitat package prefix. Ensure #{ChefCLI::Dist::HAB_PKG_NAME} is installed and CHEF_CLI_VERSION is set correctly." unless bin_pkg_prefix
|
|
170
|
+
|
|
171
|
+
# Determine vendor_dir by prioritizing the versioned package first
|
|
172
|
+
vendor_pkg_prefix = versioned_pkg_prefix || get_pkg_prefix(ChefCLI::Dist::HAB_PKG_NAME)
|
|
173
|
+
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
|
|
174
|
+
|
|
175
|
+
vendor_dir = File.join(vendor_pkg_prefix, "vendor")
|
|
176
|
+
# Construct PATH
|
|
177
|
+
path = [
|
|
178
|
+
File.join(bin_pkg_prefix, "bin"),
|
|
179
|
+
File.join(vendor_dir, "bin"),
|
|
180
|
+
ENV["PATH"].split(File::PATH_SEPARATOR), # Preserve existing PATH
|
|
181
|
+
].flatten.uniq
|
|
182
|
+
|
|
183
|
+
{
|
|
184
|
+
"PATH" => path.join(File::PATH_SEPARATOR),
|
|
185
|
+
"GEM_ROOT" => Gem.default_dir, # Default directory for gems
|
|
186
|
+
"GEM_HOME" => vendor_dir, # Set only if vendor_dir exists
|
|
187
|
+
"GEM_PATH" => vendor_dir, # Set only if vendor_dir exists
|
|
188
|
+
}
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
113
192
|
#
|
|
114
193
|
# environment vars for omnibus
|
|
115
194
|
#
|
|
@@ -121,14 +200,20 @@ module ChefCLI
|
|
|
121
200
|
path << git_bin_dir if Dir.exist?(git_bin_dir)
|
|
122
201
|
path << git_windows_bin_dir if Dir.exist?(git_windows_bin_dir)
|
|
123
202
|
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
203
|
+
"PATH" => path.flatten.uniq.join(File::PATH_SEPARATOR),
|
|
204
|
+
"GEM_ROOT" => Gem.default_dir,
|
|
205
|
+
"GEM_HOME" => Gem.user_dir,
|
|
206
|
+
"GEM_PATH" => Gem.path.join(File::PATH_SEPARATOR),
|
|
128
207
|
}
|
|
129
208
|
end
|
|
130
209
|
end
|
|
131
210
|
|
|
211
|
+
def get_pkg_prefix(pkg_name)
|
|
212
|
+
stderr_redirect = Chef::Platform.windows? ? "2>NUL" : "2>/dev/null"
|
|
213
|
+
path = `hab pkg path #{pkg_name} #{stderr_redirect}`.strip
|
|
214
|
+
path if !path.empty? && Dir.exist?(path) # Return path only if it exists
|
|
215
|
+
end
|
|
216
|
+
|
|
132
217
|
def omnibus_expand_path(*paths)
|
|
133
218
|
dir = File.expand_path(File.join(paths))
|
|
134
219
|
raise OmnibusInstallNotFound.new unless dir && File.directory?(dir)
|
|
@@ -173,5 +258,15 @@ module ChefCLI
|
|
|
173
258
|
def macos?
|
|
174
259
|
!!(RUBY_PLATFORM =~ /darwin/)
|
|
175
260
|
end
|
|
261
|
+
|
|
262
|
+
# @return [Boolean] Checks if a habitat package is installed.
|
|
263
|
+
# If habitat itself is not installed, this method will return false.
|
|
264
|
+
#
|
|
265
|
+
# @api private
|
|
266
|
+
#
|
|
267
|
+
def hab_pkg_installed?(pkg_name)
|
|
268
|
+
stderr_redirect = Chef::Platform.windows? ? "2>NUL" : "2>/dev/null"
|
|
269
|
+
`hab pkg list #{pkg_name} #{stderr_redirect}`.include?(pkg_name) rescue false
|
|
270
|
+
end
|
|
176
271
|
end
|
|
177
272
|
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
4
|
+
# License:: Apache License, Version 2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
require "chef-licensing"
|
|
20
|
+
require_relative "config"
|
|
21
|
+
|
|
22
|
+
module ChefCLI
|
|
23
|
+
module Licensing
|
|
24
|
+
class Base
|
|
25
|
+
class << self
|
|
26
|
+
def validate
|
|
27
|
+
ChefLicensing.fetch_and_persist.each do |license_key|
|
|
28
|
+
puts "License Key: #{license_key}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def list
|
|
33
|
+
ChefLicensing.list_license_keys_info
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def add
|
|
37
|
+
ChefLicensing.add_license
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
4
|
+
# License:: Apache License, Version 2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
require "chef-licensing"
|
|
20
|
+
|
|
21
|
+
ChefLicensing.configure do |config|
|
|
22
|
+
config.chef_product_name = "workstation"
|
|
23
|
+
config.chef_entitlement_id = "x6f3bc76-a94f-4b6c-bc97-4b7ed2b045c0"
|
|
24
|
+
config.chef_executable_name = "chef"
|
|
25
|
+
config.license_server_url = "https://services.chef.io/licensing"
|
|
26
|
+
end
|
data/lib/chef-cli/pager.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");
|
|
@@ -89,7 +89,8 @@ module ChefCLI
|
|
|
89
89
|
def errors
|
|
90
90
|
error_messages = []
|
|
91
91
|
if source_options_invalid?
|
|
92
|
-
|
|
92
|
+
formatted_opts = source_options.map { |k, v| "#{k.inspect}=>#{v.inspect}" }.join(", ")
|
|
93
|
+
error_messages << "Cookbook `#{name}' has invalid source options `{#{formatted_opts}}'"
|
|
93
94
|
end
|
|
94
95
|
error_messages
|
|
95
96
|
end
|