chef-cli 5.6.14 → 5.6.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -13
- data/chef-cli.gemspec +2 -2
- 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 +2 -2
- data/lib/chef-cli/command/delete_policy_group.rb +2 -2
- data/lib/chef-cli/command/diff.rb +3 -3
- data/lib/chef-cli/command/export.rb +1 -1
- data/lib/chef-cli/command/install.rb +1 -1
- data/lib/chef-cli/command/push.rb +2 -2
- data/lib/chef-cli/command/push_archive.rb +3 -3
- data/lib/chef-cli/command/show_policy.rb +3 -3
- data/lib/chef-cli/command/undelete.rb +2 -2
- data/lib/chef-cli/command/update.rb +2 -2
- data/lib/chef-cli/helpers.rb +1 -1
- data/lib/chef-cli/policyfile/artifactory_cookbook_source.rb +19 -10
- data/lib/chef-cli/policyfile/chef_server_cookbook_source.rb +6 -10
- data/lib/chef-cli/policyfile/community_cookbook_source.rb +5 -7
- data/lib/chef-cli/policyfile/delivery_supermarket_source.rb +6 -8
- data/lib/chef-cli/policyfile/dsl.rb +3 -3
- data/lib/chef-cli/policyfile/git_lock_fetcher.rb +1 -1
- data/lib/chef-cli/policyfile/policyfile_location_specification.rb +13 -17
- data/lib/chef-cli/policyfile/solution_dependencies.rb +1 -1
- data/lib/chef-cli/policyfile/uploader.rb +1 -1
- data/lib/chef-cli/policyfile_compiler.rb +2 -2
- data/lib/chef-cli/policyfile_lock.rb +1 -1
- data/lib/chef-cli/policyfile_services/export_repo.rb +6 -6
- data/lib/chef-cli/policyfile_services/install.rb +2 -2
- data/lib/chef-cli/policyfile_services/push.rb +2 -2
- data/lib/chef-cli/policyfile_services/push_archive.rb +2 -2
- data/lib/chef-cli/policyfile_services/update_attributes.rb +2 -2
- data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/recipes/helpers.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen.yml.erb +12 -4
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb +34 -5
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +12 -4
- data/lib/chef-cli/version.rb +1 -1
- data/spec/unit/command/generator_commands/cookbook_spec.rb +24 -8
- data/spec/unit/command/generator_commands/repo_spec.rb +1 -1
- data/spec/unit/policyfile/artifactory_cookbook_source_spec.rb +26 -0
- data/spec/unit/policyfile_lock_serialization_spec.rb +1 -1
- data/spec/unit/policyfile_services/clean_policies_spec.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff005199291ce09bdcddf494ad3d120301f7e1df06245fddffe6d710fe1e8691
|
4
|
+
data.tar.gz: ddbf80db9d5297b41505b3ee13143939476407e5cc47814a814d0b0be007c93a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b04956edc2501af9b15ab09af37acbe105bf9c425d6135c3c463f56624828b1d16da77dc4e051d39f6418414149d0d5a1f85fa86d315ee0ae54f1d9a2f14989
|
7
|
+
data.tar.gz: 261ee52bf70ee9d0158e3d7106cea31b72b296d481e0f2bfa349bee32c23a09f566943f83733b1f656ae3cd45aa00785de24fc3335d4398c7e14ec789088d553
|
data/Gemfile
CHANGED
@@ -2,24 +2,16 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
+
gem "logger", "< 1.6" # 1.6 causes errors with mixlib-log < 3.1.1
|
6
|
+
|
5
7
|
group :test do
|
6
8
|
gem "rake"
|
7
9
|
gem "rspec", "~> 3.8"
|
8
10
|
gem "rspec-expectations", "~> 3.8"
|
9
11
|
gem "rspec-mocks", "~> 3.8"
|
10
|
-
gem "cookstyle"
|
11
|
-
gem "chefstyle"
|
12
|
-
gem "test-kitchen"
|
13
|
-
|
14
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6")
|
15
|
-
gem "chef-zero", "~> 14"
|
16
|
-
gem "chef", "~> 15"
|
17
|
-
gem "chef-utils", "=16.6.14"
|
18
|
-
end
|
19
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7")
|
20
|
-
gem "ohai", "~> 16"
|
21
|
-
end
|
22
|
-
|
12
|
+
gem "cookstyle"
|
13
|
+
gem "chefstyle"
|
14
|
+
gem "test-kitchen"
|
23
15
|
gem "simplecov", require: false
|
24
16
|
end
|
25
17
|
|
data/chef-cli.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
|
|
29
29
|
gem.license = "Apache-2.0"
|
30
30
|
gem.homepage = "https://www.chef.io/"
|
31
31
|
|
32
|
-
gem.required_ruby_version = ">=
|
32
|
+
gem.required_ruby_version = ">= 3.1"
|
33
33
|
|
34
34
|
gem.files = %w{Rakefile LICENSE} +
|
35
35
|
Dir.glob("Gemfile*") + # Includes Gemfile and locks
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
|
|
43
43
|
gem.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
|
44
44
|
gem.add_dependency "ffi-yajl", ">= 1.0", "< 3.0"
|
45
45
|
gem.add_dependency "minitar", "~> 0.6"
|
46
|
-
gem.add_dependency "chef", "
|
46
|
+
gem.add_dependency "chef", "~> 18.0"
|
47
47
|
gem.add_dependency "solve", "< 5.0", "> 2.0"
|
48
48
|
gem.add_dependency "addressable", ">= 2.3.5", "< 2.9"
|
49
49
|
gem.add_dependency "cookbook-omnifetch", "~> 0.5"
|
@@ -70,7 +70,7 @@ module ChefCLI
|
|
70
70
|
|
71
71
|
def clean_policy_cookbooks_service
|
72
72
|
@clean_policy_cookbooks_service ||=
|
73
|
-
PolicyfileServices::CleanPolicyCookbooks.new(config: chef_config, ui:
|
73
|
+
PolicyfileServices::CleanPolicyCookbooks.new(config: chef_config, ui:)
|
74
74
|
end
|
75
75
|
|
76
76
|
def debug?
|
@@ -145,10 +145,10 @@ module ChefCLI
|
|
145
145
|
|
146
146
|
def differ(ui = self.ui)
|
147
147
|
Policyfile::Differ.new(old_name: old_base.name,
|
148
|
-
old_lock
|
148
|
+
old_lock:,
|
149
149
|
new_name: new_base.name,
|
150
|
-
new_lock
|
151
|
-
ui:
|
150
|
+
new_lock:,
|
151
|
+
ui:)
|
152
152
|
end
|
153
153
|
|
154
154
|
def http_client
|
@@ -127,7 +127,7 @@ module ChefCLI
|
|
127
127
|
def export_service
|
128
128
|
@export_service ||= PolicyfileServices::ExportRepo.new(
|
129
129
|
policyfile: policyfile_relative_path,
|
130
|
-
export_dir
|
130
|
+
export_dir:,
|
131
131
|
root_dir: Dir.pwd,
|
132
132
|
archive: archive?,
|
133
133
|
force: config[:force],
|
@@ -74,7 +74,7 @@ module ChefCLI
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def installer
|
77
|
-
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui
|
77
|
+
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui:, root_dir: Dir.pwd, config: chef_config)
|
78
78
|
end
|
79
79
|
|
80
80
|
def debug?
|
@@ -83,9 +83,9 @@ module ChefCLI
|
|
83
83
|
def push_archive_service
|
84
84
|
@push_archive_service ||=
|
85
85
|
ChefCLI::PolicyfileServices::PushArchive.new(
|
86
|
-
archive_file
|
87
|
-
policy_group
|
88
|
-
ui
|
86
|
+
archive_file:,
|
87
|
+
policy_group:,
|
88
|
+
ui:,
|
89
89
|
config: chef_config
|
90
90
|
)
|
91
91
|
end
|
@@ -87,9 +87,9 @@ module ChefCLI
|
|
87
87
|
def show_policy_service
|
88
88
|
@policy_list_service ||=
|
89
89
|
PolicyfileServices::ShowPolicy.new(config: chef_config,
|
90
|
-
ui
|
91
|
-
policy_name
|
92
|
-
policy_group
|
90
|
+
ui:,
|
91
|
+
policy_name:,
|
92
|
+
policy_group:,
|
93
93
|
show_orphans: show_orphans?,
|
94
94
|
summary_diff: show_summary_diff?,
|
95
95
|
pager: enable_pager?)
|
@@ -100,12 +100,12 @@ module ChefCLI
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def installer
|
103
|
-
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui
|
103
|
+
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui:, root_dir: Dir.pwd, config: chef_config, overwrite: true)
|
104
104
|
end
|
105
105
|
|
106
106
|
def attributes_updater
|
107
107
|
@attributes_updater ||=
|
108
|
-
PolicyfileServices::UpdateAttributes.new(policyfile: policyfile_relative_path, ui
|
108
|
+
PolicyfileServices::UpdateAttributes.new(policyfile: policyfile_relative_path, ui:, root_dir: Dir.pwd, chef_config:)
|
109
109
|
end
|
110
110
|
|
111
111
|
def debug?
|
data/lib/chef-cli/helpers.rb
CHANGED
@@ -144,7 +144,7 @@ module ChefCLI
|
|
144
144
|
|
145
145
|
def default_package_home
|
146
146
|
if Chef::Platform.windows?
|
147
|
-
File.join(ENV["LOCALAPPDATA"], ChefCLI::Dist::PRODUCT_PKG_HOME)
|
147
|
+
File.join(ENV["LOCALAPPDATA"], ChefCLI::Dist::PRODUCT_PKG_HOME).gsub("\\", "/")
|
148
148
|
else
|
149
149
|
File.expand_path("~/.#{ChefCLI::Dist::PRODUCT_PKG_HOME}")
|
150
150
|
end
|
@@ -54,14 +54,12 @@ module ChefCLI
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def universe_graph
|
57
|
-
@universe_graph ||=
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
deps_by_version
|
62
|
-
end
|
63
|
-
normalized_graph
|
57
|
+
@universe_graph ||= full_community_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)|
|
58
|
+
normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)|
|
59
|
+
deps_by_version[version] = metadata["dependencies"]
|
60
|
+
deps_by_version
|
64
61
|
end
|
62
|
+
normalized_graph
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
@@ -83,14 +81,25 @@ module ChefCLI
|
|
83
81
|
end
|
84
82
|
|
85
83
|
def artifactory_api_key
|
86
|
-
chef_config&.artifactory_api_key || ENV["ARTIFACTORY_API_KEY"]
|
84
|
+
chef_config&.artifactory_api_key || (ENV["ARTIFACTORY_API_KEY"] unless ENV["ARTIFACTORY_API_KEY"].to_s.strip.empty?)
|
85
|
+
end
|
86
|
+
|
87
|
+
def artifactory_identity_token
|
88
|
+
chef_config&.artifactory_identity_token || (ENV["ARTIFACTORY_IDENTITY_TOKEN"] unless ENV["ARTIFACTORY_IDENTITY_TOKEN"].to_s.strip.empty?)
|
87
89
|
end
|
88
90
|
|
89
91
|
private
|
90
92
|
|
93
|
+
def auth_headers
|
94
|
+
if artifactory_identity_token
|
95
|
+
{ "Authorization" => "Bearer #{artifactory_identity_token}" }
|
96
|
+
else
|
97
|
+
{ "X-Jfrog-Art-API" => artifactory_api_key }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
91
101
|
def http_connection_for(base_url)
|
92
|
-
|
93
|
-
@http_connections[base_url] ||= Chef::HTTP::Simple.new(base_url, headers: headers)
|
102
|
+
@http_connections[base_url] ||= Chef::HTTP::Simple.new(base_url, headers: auth_headers)
|
94
103
|
end
|
95
104
|
|
96
105
|
def full_community_graph
|
@@ -52,14 +52,12 @@ module ChefCLI
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def universe_graph
|
55
|
-
@universe_graph ||=
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
deps_by_version
|
60
|
-
end
|
61
|
-
normalized_graph
|
55
|
+
@universe_graph ||= full_chef_server_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)|
|
56
|
+
normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)|
|
57
|
+
deps_by_version[version] = metadata["dependencies"]
|
58
|
+
deps_by_version
|
62
59
|
end
|
60
|
+
normalized_graph
|
63
61
|
end
|
64
62
|
end
|
65
63
|
|
@@ -90,9 +88,7 @@ module ChefCLI
|
|
90
88
|
|
91
89
|
def full_chef_server_graph
|
92
90
|
@full_chef_server_graph ||=
|
93
|
-
|
94
|
-
http_connection_for(uri.to_s).get("/universe")
|
95
|
-
end
|
91
|
+
http_connection_for(uri.to_s).get("/universe")
|
96
92
|
end
|
97
93
|
end
|
98
94
|
end
|
@@ -52,14 +52,12 @@ module ChefCLI
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def universe_graph
|
55
|
-
@universe_graph ||=
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
deps_by_version
|
60
|
-
end
|
61
|
-
normalized_graph
|
55
|
+
@universe_graph ||= full_community_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)|
|
56
|
+
normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)|
|
57
|
+
deps_by_version[version] = metadata["dependencies"]
|
58
|
+
deps_by_version
|
62
59
|
end
|
60
|
+
normalized_graph
|
63
61
|
end
|
64
62
|
end
|
65
63
|
|
@@ -66,15 +66,13 @@ module ChefCLI
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def universe_graph
|
69
|
-
@universe_graph ||=
|
70
|
-
|
71
|
-
|
72
|
-
Semverse::Version.new(version_string)
|
73
|
-
end
|
74
|
-
greatest_version = sorted_versions.last
|
75
|
-
truncated[cookbook_name] = { greatest_version => version_and_deps_list[greatest_version] }
|
76
|
-
truncated
|
69
|
+
@universe_graph ||= @community_source.universe_graph.inject({}) do |truncated, (cookbook_name, version_and_deps_list)|
|
70
|
+
sorted_versions = version_and_deps_list.keys.sort_by do |version_string|
|
71
|
+
Semverse::Version.new(version_string)
|
77
72
|
end
|
73
|
+
greatest_version = sorted_versions.last
|
74
|
+
truncated[cookbook_name] = { greatest_version => version_and_deps_list[greatest_version] }
|
75
|
+
truncated
|
78
76
|
end
|
79
77
|
end
|
80
78
|
|
@@ -27,7 +27,7 @@ module ChefCLI
|
|
27
27
|
module Policyfile
|
28
28
|
class DSL
|
29
29
|
|
30
|
-
RUN_LIST_ITEM_COMPONENT = /^[.[:alnum:]_-]
|
30
|
+
RUN_LIST_ITEM_COMPONENT = /^[.[:alnum:]_-]+$/
|
31
31
|
|
32
32
|
include StorageConfigDelegation
|
33
33
|
|
@@ -203,7 +203,7 @@ module ChefCLI
|
|
203
203
|
if source_uri.nil?
|
204
204
|
@errors << "You must specify the server's URI when using a default_source :chef_server"
|
205
205
|
else
|
206
|
-
set_default_source(ChefServerCookbookSource.new(source_uri, chef_config
|
206
|
+
set_default_source(ChefServerCookbookSource.new(source_uri, chef_config:, &block))
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
@@ -211,7 +211,7 @@ module ChefCLI
|
|
211
211
|
if source_uri.nil?
|
212
212
|
@errors << "You must specify the server's URI when using a default_source :artifactory"
|
213
213
|
else
|
214
|
-
set_default_source(ArtifactoryCookbookSource.new(source_uri, chef_config
|
214
|
+
set_default_source(ArtifactoryCookbookSource.new(source_uri, chef_config:, &block))
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
@@ -62,20 +62,18 @@ module ChefCLI
|
|
62
62
|
|
63
63
|
# @return A policyfile lock fetcher compatible with the given source_options
|
64
64
|
def fetcher
|
65
|
-
@fetcher ||=
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
)
|
78
|
-
end
|
65
|
+
@fetcher ||= if source_options[:path] && !source_options[:git]
|
66
|
+
Policyfile::LocalLockFetcher.new(name, source_options, storage_config)
|
67
|
+
elsif source_options[:remote]
|
68
|
+
Policyfile::RemoteLockFetcher.new(name, source_options)
|
69
|
+
elsif source_options[:server]
|
70
|
+
Policyfile::ChefServerLockFetcher.new(name, source_options, chef_config)
|
71
|
+
elsif source_options[:git]
|
72
|
+
Policyfile::GitLockFetcher.new(name, source_options, storage_config)
|
73
|
+
else
|
74
|
+
raise ChefCLI::InvalidPolicyfileLocation.new(
|
75
|
+
"Invalid policyfile lock location type. The supported locations are: #{LOCATION_TYPES.join(", ")}"
|
76
|
+
)
|
79
77
|
end
|
80
78
|
end
|
81
79
|
|
@@ -106,9 +104,7 @@ module ChefCLI
|
|
106
104
|
#
|
107
105
|
# @return [PolicyfileLock] the loaded policyfile lock
|
108
106
|
def policyfile_lock
|
109
|
-
@policyfile_lock ||=
|
110
|
-
PolicyfileLock.new(storage_config, ui: ui).build_from_lock_data(fetcher.lock_data)
|
111
|
-
end
|
107
|
+
@policyfile_lock ||= PolicyfileLock.new(storage_config, ui:).build_from_lock_data(fetcher.lock_data)
|
112
108
|
end
|
113
109
|
|
114
110
|
# @return [Hash] The source_options that describe how to fetch this exact lock again
|
@@ -207,7 +207,7 @@ module ChefCLI
|
|
207
207
|
remote_already_has_cookbook?(cb_with_lock.cookbook)
|
208
208
|
end
|
209
209
|
|
210
|
-
Reports::Upload.new(reused_cbs
|
210
|
+
Reports::Upload.new(reused_cbs:, uploaded_cbs:, ui:).show
|
211
211
|
|
212
212
|
true
|
213
213
|
end
|
@@ -42,7 +42,7 @@ module ChefCLI
|
|
42
42
|
SOURCE_TYPES_WITH_FIXED_VERSIONS = %i{git path}.freeze
|
43
43
|
|
44
44
|
def self.evaluate(policyfile_string, policyfile_filename, ui: nil, chef_config: nil)
|
45
|
-
compiler = new(ui
|
45
|
+
compiler = new(ui:, chef_config:)
|
46
46
|
compiler.evaluate_policyfile(policyfile_string, policyfile_filename)
|
47
47
|
compiler
|
48
48
|
end
|
@@ -61,7 +61,7 @@ module ChefCLI
|
|
61
61
|
|
62
62
|
def initialize(ui: nil, chef_config: nil)
|
63
63
|
@storage_config = Policyfile::StorageConfig.new
|
64
|
-
@dsl = Policyfile::DSL.new(storage_config, chef_config:
|
64
|
+
@dsl = Policyfile::DSL.new(storage_config, chef_config:)
|
65
65
|
@artifact_server_cookbook_location_specs = {}
|
66
66
|
|
67
67
|
@merged_graph = nil
|
@@ -121,12 +121,12 @@ module ChefCLI
|
|
121
121
|
random_string = SecureRandom.hex(2)
|
122
122
|
path = "chef-export-#{random_string}"
|
123
123
|
Dir.mktmpdir(path) do |d|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
124
|
+
|
125
|
+
@staging_dir = d
|
126
|
+
yield
|
127
|
+
ensure
|
128
|
+
@staging_dir = nil
|
129
|
+
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -73,7 +73,7 @@ module ChefCLI
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def policyfile_compiler
|
76
|
-
@policyfile_compiler ||= ChefCLI::PolicyfileCompiler.evaluate(policyfile_content, policyfile_expanded_path, ui
|
76
|
+
@policyfile_compiler ||= ChefCLI::PolicyfileCompiler.evaluate(policyfile_content, policyfile_expanded_path, ui:, chef_config:)
|
77
77
|
end
|
78
78
|
|
79
79
|
def expanded_run_list
|
@@ -89,7 +89,7 @@ module ChefCLI
|
|
89
89
|
|
90
90
|
@policyfile_lock ||= begin
|
91
91
|
lock_data = FFI_Yajl::Parser.new.parse(policyfile_lock_content)
|
92
|
-
PolicyfileLock.new(storage_config, ui:
|
92
|
+
PolicyfileLock.new(storage_config, ui:).build_from_lock_data(lock_data)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -69,8 +69,8 @@ module ChefCLI
|
|
69
69
|
# @api private
|
70
70
|
def uploader
|
71
71
|
ChefCLI::Policyfile::Uploader.new(policyfile_lock, policy_group,
|
72
|
-
ui
|
73
|
-
http_client
|
72
|
+
ui:,
|
73
|
+
http_client:,
|
74
74
|
policy_document_native_api: config.policy_document_native_api)
|
75
75
|
end
|
76
76
|
|
@@ -78,7 +78,7 @@ module ChefCLI
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def policyfile_compiler
|
81
|
-
@policyfile_compiler ||= ChefCLI::PolicyfileCompiler.evaluate(policyfile_content, policyfile_expanded_path, ui
|
81
|
+
@policyfile_compiler ||= ChefCLI::PolicyfileCompiler.evaluate(policyfile_content, policyfile_expanded_path, ui:, chef_config:)
|
82
82
|
end
|
83
83
|
|
84
84
|
def policyfile_lock_content
|
@@ -88,7 +88,7 @@ module ChefCLI
|
|
88
88
|
def policyfile_lock
|
89
89
|
@policyfile_lock ||= begin
|
90
90
|
lock_data = FFI_Yajl::Parser.new.parse(policyfile_lock_content)
|
91
|
-
PolicyfileLock.new(storage_config, ui:
|
91
|
+
PolicyfileLock.new(storage_config, ui:).build_from_lock_data(lock_data)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# This is a Chef Infra Client recipe file. It can be used to specify resources
|
2
2
|
# which will apply configuration to a server.
|
3
3
|
|
4
|
-
log "Welcome to Chef Infra Client, #{node[
|
4
|
+
log "Welcome to Chef Infra Client, #{node["example"]["name"]}!" do
|
5
5
|
level :info
|
6
6
|
end
|
7
7
|
|
@@ -15,5 +15,5 @@ helper_class_name = "#{camelize(context.new_file_basename)}Helpers"
|
|
15
15
|
template helpers_path do
|
16
16
|
source 'helpers.rb.erb'
|
17
17
|
helpers(ChefCLI::Generator::TemplateHelper)
|
18
|
-
variables(cookbook_class_name
|
18
|
+
variables(cookbook_class_name:, helper_class_name:)
|
19
19
|
end
|
@@ -10,7 +10,7 @@ driver:
|
|
10
10
|
# - ["forwarded_port", {guest: 80, host: 8080}]
|
11
11
|
|
12
12
|
provisioner:
|
13
|
-
name:
|
13
|
+
name: chef_infra
|
14
14
|
# You may wish to disable always updating cookbooks in CI or other testing environments.
|
15
15
|
# For example:
|
16
16
|
# always_update_cookbooks: <%%= !ENV['CI'] %>
|
@@ -19,14 +19,22 @@ provisioner:
|
|
19
19
|
## product_name and product_version specifies a specific Chef product and version to install.
|
20
20
|
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
21
21
|
# product_name: chef
|
22
|
-
# product_version:
|
22
|
+
# product_version: 18
|
23
23
|
|
24
24
|
verifier:
|
25
25
|
name: inspec
|
26
26
|
|
27
27
|
platforms:
|
28
|
-
- name:
|
29
|
-
- name:
|
28
|
+
- name: almalinux-9
|
29
|
+
- name: amazonlinux-2023
|
30
|
+
- name: centos-stream-9
|
31
|
+
- name: debian-12
|
32
|
+
- name: fedora-latest
|
33
|
+
- name: freebsd-14
|
34
|
+
- name: opensuse-leap-15
|
35
|
+
- name: oraclelinux-9
|
36
|
+
- name: rockylinux-9
|
37
|
+
- name: ubuntu-24.04
|
30
38
|
|
31
39
|
suites:
|
32
40
|
- name: default
|
@@ -15,17 +15,46 @@ verifier:
|
|
15
15
|
platforms:
|
16
16
|
# @see https://github.com/chef-cookbooks/testing_examples/blob/main/kitchen.dokken.yml
|
17
17
|
# @see https://hub.docker.com/u/dokken
|
18
|
-
- name:
|
18
|
+
- name: almalinux-9
|
19
19
|
driver:
|
20
|
-
image: dokken/
|
20
|
+
image: dokken/almalinux-9
|
21
|
+
pid_one_command: /usr/lib/systemd/systemd
|
22
|
+
- name: amazonlinux-2023
|
23
|
+
driver:
|
24
|
+
image: dokken/amazonlinux-2023
|
25
|
+
pid_one_command: /usr/lib/systemd/systemd
|
26
|
+
- name: centos-stream-9
|
27
|
+
driver:
|
28
|
+
image: dokken/centos-stream-9
|
29
|
+
pid_one_command: /usr/lib/systemd/systemd
|
30
|
+
- name: debian-12
|
31
|
+
driver:
|
32
|
+
image: dokken/debian-12
|
21
33
|
pid_one_command: /bin/systemd
|
22
34
|
intermediate_instructions:
|
23
35
|
- RUN /usr/bin/apt-get update
|
24
|
-
|
25
|
-
|
36
|
+
- name: fedora-latest
|
37
|
+
driver:
|
38
|
+
image: dokken/fedora-latest
|
39
|
+
pid_one_command: /usr/lib/systemd/systemd
|
40
|
+
- name: opensuse-leap-15
|
26
41
|
driver:
|
27
|
-
image: dokken/
|
42
|
+
image: dokken/opensuse-leap-15
|
28
43
|
pid_one_command: /usr/lib/systemd/systemd
|
44
|
+
- name: oraclelinux-9
|
45
|
+
driver:
|
46
|
+
image: dokken/oraclelinux-9
|
47
|
+
pid_one_command: /usr/lib/systemd/systemd
|
48
|
+
- name: rockylinux-9
|
49
|
+
driver:
|
50
|
+
image: dokken/rockylinux-9
|
51
|
+
pid_one_command: /usr/lib/systemd/systemd
|
52
|
+
- name: ubuntu-24.04
|
53
|
+
driver:
|
54
|
+
image: dokken/ubuntu-24.04
|
55
|
+
pid_one_command: /bin/systemd
|
56
|
+
intermediate_instructions:
|
57
|
+
- RUN /usr/bin/apt-get update
|
29
58
|
|
30
59
|
suites:
|
31
60
|
- name: default
|
@@ -10,19 +10,27 @@ driver:
|
|
10
10
|
# - ["forwarded_port", {guest: 80, host: 8080}]
|
11
11
|
|
12
12
|
provisioner:
|
13
|
-
name:
|
13
|
+
name: chef_infra
|
14
14
|
|
15
15
|
## product_name and product_version specifies a specific Chef product and version to install.
|
16
16
|
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
17
17
|
# product_name: chef
|
18
|
-
# product_version:
|
18
|
+
# product_version: 18
|
19
19
|
|
20
20
|
verifier:
|
21
21
|
name: inspec
|
22
22
|
|
23
23
|
platforms:
|
24
|
-
- name:
|
25
|
-
- name:
|
24
|
+
- name: almalinux-9
|
25
|
+
- name: amazonlinux-2023
|
26
|
+
- name: centos-stream-9
|
27
|
+
- name: debian-12
|
28
|
+
- name: fedora-latest
|
29
|
+
- name: freebsd-14
|
30
|
+
- name: opensuse-leap-15
|
31
|
+
- name: oraclelinux-9
|
32
|
+
- name: rockylinux-9
|
33
|
+
- name: ubuntu-24.04
|
26
34
|
|
27
35
|
suites:
|
28
36
|
- name: default
|
data/lib/chef-cli/version.rb
CHANGED
@@ -388,19 +388,27 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
388
388
|
# - ["forwarded_port", {guest: 80, host: 8080}]
|
389
389
|
|
390
390
|
provisioner:
|
391
|
-
name:
|
391
|
+
name: chef_infra
|
392
392
|
|
393
393
|
## product_name and product_version specifies a specific Chef product and version to install.
|
394
394
|
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
395
395
|
# product_name: chef
|
396
|
-
# product_version:
|
396
|
+
# product_version: 18
|
397
397
|
|
398
398
|
verifier:
|
399
399
|
name: inspec
|
400
400
|
|
401
401
|
platforms:
|
402
|
-
- name:
|
403
|
-
- name:
|
402
|
+
- name: almalinux-9
|
403
|
+
- name: amazonlinux-2023
|
404
|
+
- name: centos-stream-9
|
405
|
+
- name: debian-12
|
406
|
+
- name: fedora-latest
|
407
|
+
- name: freebsd-14
|
408
|
+
- name: opensuse-leap-15
|
409
|
+
- name: oraclelinux-9
|
410
|
+
- name: rockylinux-9
|
411
|
+
- name: ubuntu-24.04
|
404
412
|
|
405
413
|
suites:
|
406
414
|
- name: default
|
@@ -520,7 +528,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
520
528
|
# - ["forwarded_port", {guest: 80, host: 8080}]
|
521
529
|
|
522
530
|
provisioner:
|
523
|
-
name:
|
531
|
+
name: chef_infra
|
524
532
|
# You may wish to disable always updating cookbooks in CI or other testing environments.
|
525
533
|
# For example:
|
526
534
|
# always_update_cookbooks: <%= !ENV['CI'] %>
|
@@ -529,14 +537,22 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
529
537
|
## product_name and product_version specifies a specific Chef product and version to install.
|
530
538
|
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
531
539
|
# product_name: chef
|
532
|
-
# product_version:
|
540
|
+
# product_version: 18
|
533
541
|
|
534
542
|
verifier:
|
535
543
|
name: inspec
|
536
544
|
|
537
545
|
platforms:
|
538
|
-
- name:
|
539
|
-
- name:
|
546
|
+
- name: almalinux-9
|
547
|
+
- name: amazonlinux-2023
|
548
|
+
- name: centos-stream-9
|
549
|
+
- name: debian-12
|
550
|
+
- name: fedora-latest
|
551
|
+
- name: freebsd-14
|
552
|
+
- name: opensuse-leap-15
|
553
|
+
- name: oraclelinux-9
|
554
|
+
- name: rockylinux-9
|
555
|
+
- name: ubuntu-24.04
|
540
556
|
|
541
557
|
suites:
|
542
558
|
- name: default
|
@@ -256,7 +256,7 @@ describe ChefCLI::Command::GeneratorCommands::Repo do
|
|
256
256
|
let(:file) { "cookbooks/example/recipes/default.rb" }
|
257
257
|
|
258
258
|
it "has the right contents" do
|
259
|
-
expect(file_contents).to match(/log "Welcome to Chef Infra Client, \#\{node\[
|
259
|
+
expect(file_contents).to match(/log "Welcome to Chef Infra Client, \#\{node\["example"\]\["name"\]\}!" do/)
|
260
260
|
end
|
261
261
|
end
|
262
262
|
end
|
@@ -82,4 +82,30 @@ describe ChefCLI::Policyfile::ArtifactoryCookbookSource do
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
|
+
|
86
|
+
describe "#artifactory_identity_token" do
|
87
|
+
before do
|
88
|
+
ENV["ARTIFACTORY_IDENTITY_TOKEN"] = "test"
|
89
|
+
end
|
90
|
+
|
91
|
+
context "when config is not present" do
|
92
|
+
let(:config) { nil }
|
93
|
+
it "should get artifactory key from the env" do
|
94
|
+
expect(subject.artifactory_identity_token).to eq("test")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when config is present" do
|
99
|
+
let(:config) { double("Chef::Config") }
|
100
|
+
it "should get artifactory key from config when key is present" do
|
101
|
+
expect(config).to receive(:artifactory_identity_token).and_return "test1"
|
102
|
+
expect(subject.artifactory_identity_token).to eq("test1")
|
103
|
+
end
|
104
|
+
it "should get artifactory key from env when config is present but has a nil key" do
|
105
|
+
expect(config).to receive(:artifactory_identity_token).and_return nil
|
106
|
+
expect(subject.artifactory_identity_token).to eq("test")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
85
111
|
end
|
@@ -137,7 +137,7 @@ describe ChefCLI::PolicyfileLock, "when reading a Policyfile.lock" do
|
|
137
137
|
|
138
138
|
it "requires the values in named_run_lists to be valid run lists" do
|
139
139
|
bad_named_run_lists = valid_lock_data.dup
|
140
|
-
bad_named_run_lists["named_run_lists"] = { "bad" => [ 42 ] }
|
140
|
+
bad_named_run_lists["named_run_lists"] = { "bad" => [ "42" ] }
|
141
141
|
|
142
142
|
expect { lockfile.build_from_lock_data(bad_named_run_lists) }.to raise_error(ChefCLI::InvalidLockfile)
|
143
143
|
end
|
@@ -215,7 +215,7 @@ describe ChefCLI::PolicyfileServices::CleanPolicies do
|
|
215
215
|
# this will continue to print that out until they remove HTTPServerException
|
216
216
|
expected_message = <<~ERROR
|
217
217
|
Failed to delete some policy revisions:
|
218
|
-
- appserver (4444444444444444444444444444444444444444444444444444444444444444): Net::
|
218
|
+
- appserver (4444444444444444444444444444444444444444444444444444444444444444): Net::HTTPClientException 403 \"Unauthorized\"
|
219
219
|
ERROR
|
220
220
|
|
221
221
|
expect { clean_policies_service.run }.to raise_error do |error|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.6.
|
4
|
+
version: 5.6.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-cli
|
@@ -88,16 +88,16 @@ dependencies:
|
|
88
88
|
name: chef
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- - "
|
91
|
+
- - "~>"
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
93
|
+
version: '18.0'
|
94
94
|
type: :runtime
|
95
95
|
prerelease: false
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- - "
|
98
|
+
- - "~>"
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: '
|
100
|
+
version: '18.0'
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
102
|
name: solve
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -607,14 +607,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
607
607
|
requirements:
|
608
608
|
- - ">="
|
609
609
|
- !ruby/object:Gem::Version
|
610
|
-
version: '
|
610
|
+
version: '3.1'
|
611
611
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
612
612
|
requirements:
|
613
613
|
- - ">="
|
614
614
|
- !ruby/object:Gem::Version
|
615
615
|
version: '0'
|
616
616
|
requirements: []
|
617
|
-
rubygems_version: 3.
|
617
|
+
rubygems_version: 3.2.3
|
618
618
|
signing_key:
|
619
619
|
specification_version: 4
|
620
620
|
summary: A streamlined development and deployment workflow for Chef platform.
|