chef-cli 5.5.0 → 5.5.4
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 +2 -0
- data/lib/chef-cli/builtin_commands.rb +0 -3
- data/lib/chef-cli/command/generate.rb +0 -5
- data/lib/chef-cli/command/generator_commands/cookbook.rb +14 -40
- data/lib/chef-cli/skeletons/code_generator/recipes/cookbook.rb +0 -29
- data/lib/chef-cli/version.rb +1 -1
- data/spec/shared/custom_generator_cookbook.rb +0 -44
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/command/generate_spec.rb +0 -8
- data/spec/unit/command/generator_commands/cookbook_spec.rb +5 -335
- metadata +2 -5
- data/lib/chef-cli/command/provision.rb +0 -36
- data/lib/chef-cli/skeletons/code_generator/files/default/delivery-project.toml +0 -32
- data/lib/chef-cli/skeletons/code_generator/templates/default/delivery-project.toml.erb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfeb3741f305634bdb91164a529d57fda8ba8dd8ee1a74f942e4e38eb521e79f
|
4
|
+
data.tar.gz: 5f57c0483c71fc7732ad9fec53ee0954022ac35194ba0f4a5909239c10d17e2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8dc515d741fe02197afead1faa446a632b6a71f918370df34585c66b33ef8c760b6ff2f7c14bad37cfdeaaa24f3e98a3884065336912fd8b5982039d43012d5
|
7
|
+
data.tar.gz: 168e5f6b65ef26172869372c3d2af1f2bc2e0f910ae65c12303d3856d1c4e4dd715a3d1c59ef17067feeea217f03912864f30b5a90e1f6f13e0dc13005a48388
|
data/Gemfile
CHANGED
@@ -57,7 +57,4 @@ ChefCLI.commands do |c|
|
|
57
57
|
|
58
58
|
c.builtin "describe-cookbook", :DescribeCookbook, require_path: "chef-cli/command/describe_cookbook",
|
59
59
|
desc: "Prints cookbook checksum information used for cookbook identifier"
|
60
|
-
|
61
|
-
# deprecated command that throws a failure warning if used. This was removed 4.2019
|
62
|
-
c.builtin "provision", :Provision, desc: "Provision VMs and clusters via cookbook", hidden: true
|
63
60
|
end
|
@@ -55,7 +55,6 @@ module ChefCLI
|
|
55
55
|
generator(:repo, :Repo, "Generate a #{ChefCLI::Dist::INFRA_PRODUCT} code repository")
|
56
56
|
generator(:policyfile, :Policyfile, "Generate a Policyfile for use with the install/push commands")
|
57
57
|
generator(:generator, :GeneratorGenerator, "Copy #{ChefCLI::Dist::PRODUCT}'s generator cookbook so you can customize it")
|
58
|
-
generator(:'build-cookbook', :BuildCookbook, "DEPRECATED: Generate a build cookbook for use with #{ChefCLI::Dist::WORKFLOW}")
|
59
58
|
|
60
59
|
def self.banner_headline
|
61
60
|
<<~E
|
@@ -82,10 +81,6 @@ module ChefCLI
|
|
82
81
|
end
|
83
82
|
|
84
83
|
def run(params)
|
85
|
-
if params[0] == "build-cookbook"
|
86
|
-
warn "[DEPRECATION] Chef Workflow (Delivery) is end of life (EOL) as of December 31, 2020 and this generator subcommand has been removed".freeze
|
87
|
-
return 1
|
88
|
-
end
|
89
84
|
if ( generator_spec = generator_for(params[0]) )
|
90
85
|
params.shift
|
91
86
|
generator = GeneratorCommands.build(generator_spec.class_name, params)
|
@@ -65,7 +65,7 @@ module ChefCLI
|
|
65
65
|
option :workflow,
|
66
66
|
short: "-w",
|
67
67
|
long: "--workflow",
|
68
|
-
description: "
|
68
|
+
description: "REMOVED: #{ChefCLI::Dist::WORKFLOW} is EOL. This option has been removed.",
|
69
69
|
boolean: true,
|
70
70
|
default: false
|
71
71
|
|
@@ -85,7 +85,7 @@ module ChefCLI
|
|
85
85
|
|
86
86
|
option :pipeline,
|
87
87
|
long: "--pipeline PIPELINE",
|
88
|
-
description: "
|
88
|
+
description: "REMOVED: #{ChefCLI::Dist::WORKFLOW} is EOL. This option has been removed.",
|
89
89
|
default: "master"
|
90
90
|
|
91
91
|
options.merge!(SharedGeneratorOptions.options)
|
@@ -119,17 +119,12 @@ module ChefCLI
|
|
119
119
|
|
120
120
|
def emit_post_create_message
|
121
121
|
default_recipe_file = yaml ? "default.yml" : "default.rb"
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
msg("\nWhy not start by writing an InSpec test? Tests for the default recipe are stored at:\n")
|
129
|
-
msg("test/integration/default/default_test.rb")
|
130
|
-
msg("\nIf you'd prefer to dive right in, the default recipe can be found at:")
|
131
|
-
msg("\nrecipes/#{default_recipe_file}\n")
|
132
|
-
end
|
122
|
+
msg("Your cookbook is ready. Type `cd #{cookbook_name_or_path}` to enter it.")
|
123
|
+
msg("\nThere are several commands you can run to get started locally developing and testing your cookbook.")
|
124
|
+
msg("\nWhy not start by writing an InSpec test? Tests for the default recipe are stored at:\n")
|
125
|
+
msg("test/integration/default/default_test.rb")
|
126
|
+
msg("\nIf you'd prefer to dive right in, the default recipe can be found at:")
|
127
|
+
msg("\nrecipes/#{default_recipe_file}\n")
|
133
128
|
end
|
134
129
|
|
135
130
|
def setup_context
|
@@ -143,16 +138,10 @@ module ChefCLI
|
|
143
138
|
Generator.add_attr_to_context(:policy_run_list, policy_run_list)
|
144
139
|
Generator.add_attr_to_context(:policy_local_cookbook, ".")
|
145
140
|
|
146
|
-
Generator.add_attr_to_context(:enable_workflow, enable_workflow?)
|
147
|
-
Generator.add_attr_to_context(:workflow_project_dir, cookbook_full_path)
|
148
|
-
Generator.add_attr_to_context(:build_cookbook_parent_is_cookbook, true)
|
149
|
-
Generator.add_attr_to_context(:workflow_project_git_initialized, have_git? && !cookbook_path_in_git_repo?)
|
150
|
-
|
151
141
|
Generator.add_attr_to_context(:verbose, verbose?)
|
152
142
|
Generator.add_attr_to_context(:specs, specs?)
|
153
143
|
|
154
144
|
Generator.add_attr_to_context(:use_policyfile, policy_mode?)
|
155
|
-
Generator.add_attr_to_context(:pipeline, pipeline)
|
156
145
|
Generator.add_attr_to_context(:kitchen, kitchen)
|
157
146
|
Generator.add_attr_to_context(:vscode_dir, create_vscode_dir?)
|
158
147
|
Generator.add_attr_to_context(:yaml, yaml)
|
@@ -162,10 +151,6 @@ module ChefCLI
|
|
162
151
|
config[:kitchen]
|
163
152
|
end
|
164
153
|
|
165
|
-
def pipeline
|
166
|
-
config[:pipeline]
|
167
|
-
end
|
168
|
-
|
169
154
|
def yaml
|
170
155
|
config[:yaml]
|
171
156
|
end
|
@@ -202,10 +187,6 @@ module ChefCLI
|
|
202
187
|
@policy_mode
|
203
188
|
end
|
204
189
|
|
205
|
-
def enable_workflow?
|
206
|
-
config[:workflow]
|
207
|
-
end
|
208
|
-
|
209
190
|
def verbose?
|
210
191
|
@verbose
|
211
192
|
end
|
@@ -214,22 +195,10 @@ module ChefCLI
|
|
214
195
|
@specs
|
215
196
|
end
|
216
197
|
|
217
|
-
#
|
218
|
-
# Is there a .delivery/cli.toml in the current dir or any of the parent dirs
|
219
|
-
#
|
220
|
-
# @return [Boolean]
|
221
|
-
#
|
222
|
-
def have_delivery_config?
|
223
|
-
# delivery-cli's logic is to look recursively upward for
|
224
|
-
# .delivery/cli.toml starting from pwd:
|
225
|
-
# https://github.com/chef/delivery-cli/blob/22cbef3987ebd0aee98405b7e161a100edc87e49/src/delivery/config/mod.rs#L225-L247
|
226
|
-
|
227
|
-
Pathname.pwd.ascend.any? { |path| path.join(".delivery/cli.toml").exist? }
|
228
|
-
end
|
229
|
-
|
230
198
|
def read_and_validate_params
|
231
199
|
arguments = parse_options(params)
|
232
200
|
@cookbook_name_or_path = arguments[0]
|
201
|
+
|
233
202
|
if !@cookbook_name_or_path
|
234
203
|
@params_valid = false
|
235
204
|
elsif File.basename(@cookbook_name_or_path).include?("-")
|
@@ -241,6 +210,11 @@ module ChefCLI
|
|
241
210
|
@params_valid = false
|
242
211
|
end
|
243
212
|
|
213
|
+
if config[:workflow] || config[:pipeline]
|
214
|
+
err("[DEPRECATION] Chef Workflow (Delivery) is end of life (EOL) as of December 31, 2020 and the --workflow and --pipeline flags have been removed")
|
215
|
+
@params_valid = false
|
216
|
+
end
|
217
|
+
|
244
218
|
if config[:berks]
|
245
219
|
@policy_mode = false
|
246
220
|
end
|
@@ -131,20 +131,6 @@ else
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
# the same will be done below if workflow was enabled so avoid double work and skip this
|
135
|
-
unless context.enable_workflow
|
136
|
-
directory "#{cookbook_dir}/.delivery"
|
137
|
-
|
138
|
-
template "#{cookbook_dir}/.delivery/project.toml" do
|
139
|
-
variables(
|
140
|
-
specs: context.specs
|
141
|
-
)
|
142
|
-
source 'delivery-project.toml.erb'
|
143
|
-
helpers(ChefCLI::Generator::TemplateHelper)
|
144
|
-
action :create_if_missing
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
134
|
# git
|
149
135
|
if context.have_git
|
150
136
|
unless context.skip_git_init
|
@@ -189,18 +175,3 @@ if context.vscode_dir
|
|
189
175
|
CONTENT
|
190
176
|
end
|
191
177
|
end
|
192
|
-
|
193
|
-
if context.enable_workflow
|
194
|
-
warn "\n---------WARNING---------\nThe --workflow flag is deprecated as #{ChefCLI::Dist::WORKFLOW} is EOL as of December 2020.\n\nThis flag will be ignored and will be removed in a future release.\n-------------------------\n\n"
|
195
|
-
directory "#{cookbook_dir}/.delivery"
|
196
|
-
|
197
|
-
template "#{cookbook_dir}/.delivery/project.toml" do
|
198
|
-
variables(
|
199
|
-
specs: context.specs
|
200
|
-
)
|
201
|
-
source 'delivery-project.toml.erb'
|
202
|
-
helpers(ChefCLI::Generator::TemplateHelper)
|
203
|
-
action :create_if_missing
|
204
|
-
end
|
205
|
-
|
206
|
-
end
|
data/lib/chef-cli/version.rb
CHANGED
@@ -66,23 +66,6 @@ shared_examples_for "custom generator cookbook" do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
context "with an invalid generator-cookbook path" do
|
70
|
-
|
71
|
-
it "fails with an informative error" do
|
72
|
-
Dir.chdir(tempdir) do
|
73
|
-
allow(code_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
74
|
-
allow(code_generator).to receive(:stderr).and_return(stderr_io)
|
75
|
-
expect(code_generator.run).to eq(1)
|
76
|
-
end
|
77
|
-
|
78
|
-
cookbook_path = File.dirname(generator_cookbook_path)
|
79
|
-
expected_msg = %Q{ERROR: Could not find cookbook(s) to satisfy run list ["recipe[a_generator_cookbook::#{generator_name}]"] in #{cookbook_path}}
|
80
|
-
|
81
|
-
expect(stderr_io.string).to include(expected_msg)
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
69
|
context "with a generator-cookbook path to a specific cookbook" do
|
87
70
|
|
88
71
|
let(:metadata_file) { File.join(generator_cookbook_path, "metadata.rb") }
|
@@ -105,32 +88,5 @@ shared_examples_for "custom generator cookbook" do
|
|
105
88
|
end
|
106
89
|
|
107
90
|
end
|
108
|
-
|
109
|
-
context "with a generator-cookbook path to a directory containing a 'code_generator' cookbook" do
|
110
|
-
|
111
|
-
before do
|
112
|
-
FileUtils.mkdir_p(generator_cookbook_path)
|
113
|
-
FileUtils.cp_r(default_generator_cookbook_path, generator_cookbook_path)
|
114
|
-
|
115
|
-
allow(code_generator).to receive(:stderr).and_return(stderr_io)
|
116
|
-
end
|
117
|
-
|
118
|
-
it "creates the new_files (and warns about deprecated usage)" do
|
119
|
-
allow(code_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
120
|
-
|
121
|
-
Dir.chdir(tempdir) do
|
122
|
-
code_generator.run
|
123
|
-
end
|
124
|
-
generated_files = Dir.glob("#{tempdir}/#{generator_arg}/**/*", File::FNM_DOTMATCH)
|
125
|
-
expected_cookbook_files.each do |expected_file|
|
126
|
-
expect(generated_files).to include(expected_file)
|
127
|
-
end
|
128
|
-
|
129
|
-
code_generator_path = File.join(generator_cookbook_path, "code_generator")
|
130
|
-
warning_message = "WARN: Please configure the generator cookbook by giving the full path to the desired cookbook (like '#{code_generator_path}')"
|
131
|
-
|
132
|
-
expect(stderr_io.string).to include(warning_message)
|
133
|
-
end
|
134
|
-
end
|
135
91
|
end
|
136
92
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -137,13 +137,5 @@ describe ChefCLI::Command::Generate do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
end
|
140
|
-
|
141
|
-
describe "When build-cookbookis given as subcommand" do
|
142
|
-
it "shows deprecation warning when" do
|
143
|
-
result = generate.run(%w{build-cookbook example})
|
144
|
-
expect(result).to eq(1)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
140
|
end
|
149
141
|
end
|
@@ -87,7 +87,6 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
87
87
|
Your cookbook is ready. Type `cd new_cookbook` to enter it.
|
88
88
|
|
89
89
|
There are several commands you can run to get started locally developing and testing your cookbook.
|
90
|
-
Type `delivery local --help` to see a full list of local testing commands.
|
91
90
|
|
92
91
|
Why not start by writing an InSpec test? Tests for the default recipe are stored at:
|
93
92
|
|
@@ -152,7 +151,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
152
151
|
end
|
153
152
|
|
154
153
|
it "warns if a hyphenated cookbook name is passed" do
|
155
|
-
expect(with_argv(%w{my-cookbook}).run).to eq(
|
154
|
+
expect(with_argv(%w{my-cookbook}).run).to eq(1)
|
156
155
|
message = "Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/workstation/ctl_chef/#chef-generate-cookbook for more information."
|
157
156
|
expect(stdout_io.string).to include(message)
|
158
157
|
end
|
@@ -177,18 +176,6 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
177
176
|
expect(generator_context.specs).to be(false)
|
178
177
|
end
|
179
178
|
|
180
|
-
it "creates a new cookbook" do
|
181
|
-
|
182
|
-
Dir.chdir(tempdir) do
|
183
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
184
|
-
expect(cookbook_generator.run).to eq(0)
|
185
|
-
end
|
186
|
-
generated_files = Dir.glob("#{tempdir}/new_cookbook/**/*", File::FNM_DOTMATCH)
|
187
|
-
expected_cookbook_files.each do |expected_file|
|
188
|
-
expect(generated_files).to include(expected_file)
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
179
|
context "when given the specs flag" do
|
193
180
|
|
194
181
|
let(:argv) { %w{ new_cookbook --specs } }
|
@@ -198,17 +185,6 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
198
185
|
cookbook_generator.setup_context
|
199
186
|
expect(generator_context.specs).to be(true)
|
200
187
|
end
|
201
|
-
|
202
|
-
it "creates a new cookbook" do
|
203
|
-
Dir.chdir(tempdir) do
|
204
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
205
|
-
expect(cookbook_generator.run).to eq(0)
|
206
|
-
end
|
207
|
-
generated_files = Dir.glob("#{tempdir}/new_cookbook/**/*", File::FNM_DOTMATCH)
|
208
|
-
expected_cookbook_files_specs.each do |expected_file|
|
209
|
-
expect(generated_files).to include(expected_file)
|
210
|
-
end
|
211
|
-
end
|
212
188
|
end
|
213
189
|
|
214
190
|
context "when given the verbose flag" do
|
@@ -220,34 +196,19 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
220
196
|
cookbook_generator.setup_context
|
221
197
|
expect(generator_context.verbose).to be(true)
|
222
198
|
end
|
223
|
-
|
224
|
-
it "emits verbose output" do
|
225
|
-
Dir.chdir(tempdir) do
|
226
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
227
|
-
expect(cookbook_generator.run).to eq(0)
|
228
|
-
end
|
229
|
-
|
230
|
-
# The normal chef formatter puts a heading for each recipe like this.
|
231
|
-
# Full output is large and subject to change with minor changes in the
|
232
|
-
# generator cookbook, so we just look for this line
|
233
|
-
expected_line = "Recipe: code_generator::cookbook"
|
234
|
-
|
235
|
-
actual = stdout_io.string
|
236
|
-
|
237
|
-
expect(actual).to include(expected_line)
|
238
|
-
end
|
239
199
|
end
|
240
200
|
|
241
201
|
shared_examples_for "a generated file" do |context_var|
|
242
202
|
before do
|
243
203
|
Dir.chdir(tempdir) do
|
244
204
|
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
245
|
-
expect(cookbook_generator.run).to eq(
|
205
|
+
expect(cookbook_generator.run).to eq(1)
|
246
206
|
end
|
247
207
|
end
|
248
208
|
|
249
|
-
it "should
|
250
|
-
expect(File.
|
209
|
+
it "should not generate a file" do
|
210
|
+
expect(File.directory?(file)).to be false
|
211
|
+
expect(File).not_to exist(file)
|
251
212
|
end
|
252
213
|
end
|
253
214
|
|
@@ -267,297 +228,6 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
267
228
|
end
|
268
229
|
end
|
269
230
|
|
270
|
-
# This shared example group requires a let binding for
|
271
|
-
# `expected_kitchen_yml_content`
|
272
|
-
shared_examples_for "kitchen_yml_and_integration_tests" do
|
273
|
-
|
274
|
-
describe "Generating Test Kitchen and integration testing files" do
|
275
|
-
|
276
|
-
describe "generating kitchen config" do
|
277
|
-
|
278
|
-
before do
|
279
|
-
Dir.chdir(tempdir) do
|
280
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
281
|
-
expect(cookbook_generator.run).to eq(0)
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
let(:file) { File.join(tempdir, "new_cookbook", "kitchen.yml") }
|
286
|
-
|
287
|
-
it "creates a kitchen.yml with the expected content" do
|
288
|
-
expect(IO.read(file)).to eq(expected_kitchen_yml_content)
|
289
|
-
end
|
290
|
-
|
291
|
-
end
|
292
|
-
|
293
|
-
describe "test/integration/default/default_test.rb" do
|
294
|
-
let(:file) { File.join(tempdir, "new_cookbook", "test", "integration", "default", "default_test.rb") }
|
295
|
-
|
296
|
-
include_examples "a generated file", :cookbook_name do
|
297
|
-
let(:line) { "describe port" }
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
# This shared example group requires you to define a let binding for
|
304
|
-
# `expected_chefspec_spec_helper_content`
|
305
|
-
shared_examples_for "chefspec_spec_helper_file" do
|
306
|
-
|
307
|
-
describe "Generating ChefSpec files" do
|
308
|
-
|
309
|
-
before do
|
310
|
-
Dir.chdir(tempdir) do
|
311
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
312
|
-
expect(cookbook_generator.run).to eq(0)
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
let(:file) { File.join(tempdir, "new_cookbook", "spec", "spec_helper.rb") }
|
317
|
-
|
318
|
-
it "creates a spec/spec_helper.rb for ChefSpec with the expected content" do
|
319
|
-
expect(IO.read(file)).to eq(expected_chefspec_spec_helper_content)
|
320
|
-
end
|
321
|
-
|
322
|
-
end
|
323
|
-
|
324
|
-
end
|
325
|
-
|
326
|
-
context "when configured for Policyfiles" do
|
327
|
-
|
328
|
-
let(:argv) { %w{new_cookbook --policy} }
|
329
|
-
|
330
|
-
describe "Policyfile.rb" do
|
331
|
-
|
332
|
-
let(:file) { File.join(tempdir, "new_cookbook", "Policyfile.rb") }
|
333
|
-
|
334
|
-
let(:expected_content) do
|
335
|
-
<<~POLICYFILE_RB
|
336
|
-
# Policyfile.rb - Describe how you want Chef Infra Client to build your system.
|
337
|
-
#
|
338
|
-
# For more information on the Policyfile feature, visit
|
339
|
-
# https://docs.chef.io/policyfile/
|
340
|
-
|
341
|
-
# A name that describes what the system you're building with Chef does.
|
342
|
-
name 'new_cookbook'
|
343
|
-
|
344
|
-
# Where to find external cookbooks:
|
345
|
-
default_source :supermarket
|
346
|
-
|
347
|
-
# run_list: chef-client will run these recipes in the order specified.
|
348
|
-
run_list 'new_cookbook::default'
|
349
|
-
|
350
|
-
# Specify a custom source for a single cookbook:
|
351
|
-
cookbook 'new_cookbook', path: '.'
|
352
|
-
POLICYFILE_RB
|
353
|
-
end
|
354
|
-
|
355
|
-
before do
|
356
|
-
Dir.chdir(tempdir) do
|
357
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
358
|
-
expect(cookbook_generator.run).to eq(0)
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
it "has a run_list and cookbook path that will work out of the box" do
|
363
|
-
expect(IO.read(file)).to eq(expected_content)
|
364
|
-
end
|
365
|
-
|
366
|
-
end
|
367
|
-
|
368
|
-
include_examples "kitchen_yml_and_integration_tests" do
|
369
|
-
|
370
|
-
let(:expected_kitchen_yml_content) do
|
371
|
-
<<~KITCHEN_YML
|
372
|
-
---
|
373
|
-
driver:
|
374
|
-
name: vagrant
|
375
|
-
|
376
|
-
## The forwarded_port port feature lets you connect to ports on the VM guest
|
377
|
-
## via localhost on the host.
|
378
|
-
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
379
|
-
|
380
|
-
# network:
|
381
|
-
# - ["forwarded_port", {guest: 80, host: 8080}]
|
382
|
-
|
383
|
-
provisioner:
|
384
|
-
name: chef_zero
|
385
|
-
|
386
|
-
## product_name and product_version specifies a specific Chef product and version to install.
|
387
|
-
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
388
|
-
# product_name: chef
|
389
|
-
# product_version: 17
|
390
|
-
|
391
|
-
verifier:
|
392
|
-
name: inspec
|
393
|
-
|
394
|
-
platforms:
|
395
|
-
- name: ubuntu-20.04
|
396
|
-
- name: centos-8
|
397
|
-
|
398
|
-
suites:
|
399
|
-
- name: default
|
400
|
-
verifier:
|
401
|
-
inspec_tests:
|
402
|
-
- test/integration/default
|
403
|
-
KITCHEN_YML
|
404
|
-
end
|
405
|
-
|
406
|
-
end
|
407
|
-
|
408
|
-
include_examples "chefspec_spec_helper_file" do
|
409
|
-
let(:argv) { %w{ new_cookbook --policy --specs } }
|
410
|
-
|
411
|
-
let(:expected_chefspec_spec_helper_content) do
|
412
|
-
<<~SPEC_HELPER
|
413
|
-
require 'chefspec'
|
414
|
-
require 'chefspec/policyfile'
|
415
|
-
SPEC_HELPER
|
416
|
-
end
|
417
|
-
|
418
|
-
end
|
419
|
-
|
420
|
-
end
|
421
|
-
|
422
|
-
context "when YAML recipe flag is passed" do
|
423
|
-
|
424
|
-
let(:argv) { %w{new_cookbook --yaml} }
|
425
|
-
|
426
|
-
describe "recipes/default.yml" do
|
427
|
-
let(:file) { File.join(tempdir, "new_cookbook", "recipes", "default.yml") }
|
428
|
-
|
429
|
-
let(:expected_content_header) do
|
430
|
-
<<~DEFAULT_YML_HEADER
|
431
|
-
#
|
432
|
-
# Cookbook:: new_cookbook
|
433
|
-
# Recipe:: default
|
434
|
-
#
|
435
|
-
DEFAULT_YML_HEADER
|
436
|
-
end
|
437
|
-
|
438
|
-
let(:expected_content) do
|
439
|
-
<<~DEFAULT_YML_CONTENT
|
440
|
-
---
|
441
|
-
resources:
|
442
|
-
# Example Syntax
|
443
|
-
# Additional snippets are available using the Chef Infra Extension for Visual Studio Code
|
444
|
-
# - type: file
|
445
|
-
# name: '/path/to/file'
|
446
|
-
# content: 'content'
|
447
|
-
# owner: 'root'
|
448
|
-
# group: 'root'
|
449
|
-
# mode: '0755'
|
450
|
-
# action:
|
451
|
-
# - create
|
452
|
-
DEFAULT_YML_CONTENT
|
453
|
-
end
|
454
|
-
|
455
|
-
before do
|
456
|
-
Dir.chdir(tempdir) do
|
457
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
458
|
-
expect(cookbook_generator.run).to eq(0)
|
459
|
-
end
|
460
|
-
end
|
461
|
-
|
462
|
-
it "has a default.yml file with template contents" do
|
463
|
-
expect(IO.read(file)).to match(expected_content_header)
|
464
|
-
expect(IO.read(file)).to match(expected_content)
|
465
|
-
end
|
466
|
-
|
467
|
-
end
|
468
|
-
|
469
|
-
end
|
470
|
-
|
471
|
-
context "when configured for Berkshelf" do
|
472
|
-
|
473
|
-
let(:argv) { %w{new_cookbook --berks} }
|
474
|
-
|
475
|
-
describe "Berksfile" do
|
476
|
-
|
477
|
-
let(:file) { File.join(tempdir, "new_cookbook", "Berksfile") }
|
478
|
-
|
479
|
-
let(:expected_content) do
|
480
|
-
<<~POLICYFILE_RB
|
481
|
-
source 'https://supermarket.chef.io'
|
482
|
-
|
483
|
-
metadata
|
484
|
-
POLICYFILE_RB
|
485
|
-
end
|
486
|
-
|
487
|
-
before do
|
488
|
-
Dir.chdir(tempdir) do
|
489
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
490
|
-
expect(cookbook_generator.run).to eq(0)
|
491
|
-
end
|
492
|
-
end
|
493
|
-
|
494
|
-
it "pulls deps from metadata" do
|
495
|
-
expect(IO.read(file)).to eq(expected_content)
|
496
|
-
end
|
497
|
-
|
498
|
-
end
|
499
|
-
|
500
|
-
include_examples "kitchen_yml_and_integration_tests" do
|
501
|
-
|
502
|
-
let(:expected_kitchen_yml_content) do
|
503
|
-
<<~KITCHEN_YML
|
504
|
-
---
|
505
|
-
driver:
|
506
|
-
name: vagrant
|
507
|
-
|
508
|
-
## The forwarded_port port feature lets you connect to ports on the VM guest via
|
509
|
-
## localhost on the host.
|
510
|
-
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
511
|
-
|
512
|
-
# network:
|
513
|
-
# - ["forwarded_port", {guest: 80, host: 8080}]
|
514
|
-
|
515
|
-
provisioner:
|
516
|
-
name: chef_zero
|
517
|
-
# You may wish to disable always updating cookbooks in CI or other testing environments.
|
518
|
-
# For example:
|
519
|
-
# always_update_cookbooks: <%= !ENV['CI'] %>
|
520
|
-
always_update_cookbooks: true
|
521
|
-
|
522
|
-
## product_name and product_version specifies a specific Chef product and version to install.
|
523
|
-
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
524
|
-
# product_name: chef
|
525
|
-
# product_version: 17
|
526
|
-
|
527
|
-
verifier:
|
528
|
-
name: inspec
|
529
|
-
|
530
|
-
platforms:
|
531
|
-
- name: ubuntu-20.04
|
532
|
-
- name: centos-8
|
533
|
-
|
534
|
-
suites:
|
535
|
-
- name: default
|
536
|
-
run_list:
|
537
|
-
- recipe[new_cookbook::default]
|
538
|
-
verifier:
|
539
|
-
inspec_tests:
|
540
|
-
- test/integration/default
|
541
|
-
attributes:
|
542
|
-
KITCHEN_YML
|
543
|
-
end
|
544
|
-
|
545
|
-
end
|
546
|
-
|
547
|
-
include_examples "chefspec_spec_helper_file" do
|
548
|
-
let(:argv) { %w{ new_cookbook --berks --specs } }
|
549
|
-
|
550
|
-
let(:expected_chefspec_spec_helper_content) do
|
551
|
-
<<~SPEC_HELPER
|
552
|
-
require 'chefspec'
|
553
|
-
require 'chefspec/berkshelf'
|
554
|
-
SPEC_HELPER
|
555
|
-
end
|
556
|
-
|
557
|
-
end
|
558
|
-
|
559
|
-
end
|
560
|
-
|
561
231
|
describe "metadata.rb" do
|
562
232
|
let(:file) { File.join(tempdir, "new_cookbook", "metadata.rb") }
|
563
233
|
|
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.5.
|
4
|
+
version: 5.5.4
|
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: 2022-01-
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-cli
|
@@ -254,7 +254,6 @@ files:
|
|
254
254
|
- lib/chef-cli/command/generator_commands/resource.rb
|
255
255
|
- lib/chef-cli/command/generator_commands/template.rb
|
256
256
|
- lib/chef-cli/command/install.rb
|
257
|
-
- lib/chef-cli/command/provision.rb
|
258
257
|
- lib/chef-cli/command/push.rb
|
259
258
|
- lib/chef-cli/command/push_archive.rb
|
260
259
|
- lib/chef-cli/command/shell_init.rb
|
@@ -330,7 +329,6 @@ files:
|
|
330
329
|
- lib/chef-cli/skeletons/code_generator/files/default/chefignore
|
331
330
|
- lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md
|
332
331
|
- lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README.md
|
333
|
-
- lib/chef-cli/skeletons/code_generator/files/default/delivery-project.toml
|
334
332
|
- lib/chef-cli/skeletons/code_generator/files/default/gitignore
|
335
333
|
- lib/chef-cli/skeletons/code_generator/files/default/repo/README.md
|
336
334
|
- lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/README.md
|
@@ -367,7 +365,6 @@ files:
|
|
367
365
|
- lib/chef-cli/skeletons/code_generator/templates/default/README.md.erb
|
368
366
|
- lib/chef-cli/skeletons/code_generator/templates/default/attribute.rb.erb
|
369
367
|
- lib/chef-cli/skeletons/code_generator/templates/default/cookbook_file.erb
|
370
|
-
- lib/chef-cli/skeletons/code_generator/templates/default/delivery-project.toml.erb
|
371
368
|
- lib/chef-cli/skeletons/code_generator/templates/default/helpers.rb.erb
|
372
369
|
- lib/chef-cli/skeletons/code_generator/templates/default/inspec_default_test.rb.erb
|
373
370
|
- lib/chef-cli/skeletons/code_generator/templates/default/kitchen.yml.erb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Chef Software Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require_relative "base"
|
19
|
-
require_relative "../chef_runner"
|
20
|
-
require_relative "../dist"
|
21
|
-
|
22
|
-
module ChefCLI
|
23
|
-
|
24
|
-
module Command
|
25
|
-
|
26
|
-
class Provision < Base
|
27
|
-
|
28
|
-
banner("DEPRECATED: Chef provisioning has been removed from #{ChefCLI::Dist::PRODUCT}. If you require Chef Provisioning you will need to install an earlier version of these products!")
|
29
|
-
|
30
|
-
def run(params = [])
|
31
|
-
raise "Chef provisioning has been removed from #{ChefCLI::Dist::PRODUCT}. If you require Chef Provisioning you will need to install an earlier version of these products!"
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# Delivery for Local Phases Execution
|
2
|
-
#
|
3
|
-
# This file allows you to execute test phases locally on a workstation or
|
4
|
-
# in a CI pipeline. The delivery-cli will read this file and execute the
|
5
|
-
# command(s) that are configured for each phase. You can customize them
|
6
|
-
# by just modifying the phase key on this file.
|
7
|
-
#
|
8
|
-
# By default these phases are configured for Cookbook Workflow only
|
9
|
-
#
|
10
|
-
|
11
|
-
[local_phases]
|
12
|
-
unit = "chef exec rspec spec/"
|
13
|
-
lint = "chef exec cookstyle"
|
14
|
-
# foodcritic has been deprecated in favor of cookstyle so we skip the syntax
|
15
|
-
# phase now.
|
16
|
-
syntax = "echo skipping syntax phase. Use lint phase instead."
|
17
|
-
provision = "chef exec kitchen create"
|
18
|
-
deploy = "chef exec kitchen converge"
|
19
|
-
smoke = "chef exec kitchen verify"
|
20
|
-
# The functional phase is optional, you can define it by uncommenting
|
21
|
-
# the line below and running the command: `delivery local functional`
|
22
|
-
# functional = ""
|
23
|
-
cleanup = "chef exec kitchen destroy"
|
24
|
-
|
25
|
-
# Remote project.toml file
|
26
|
-
#
|
27
|
-
# Instead of the local phases above, you may specify a remote URI location for
|
28
|
-
# the `project.toml` file. This is useful for teams that wish to centrally
|
29
|
-
# manage the behavior of the `delivery local` command across many different
|
30
|
-
# projects.
|
31
|
-
#
|
32
|
-
# remote_file = "https://url/project.toml"
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# Delivery for Local Phases Execution
|
2
|
-
#
|
3
|
-
# This file allows you to execute test phases locally on a workstation or
|
4
|
-
# in a CI pipeline. The delivery-cli will read this file and execute the
|
5
|
-
# command(s) that are configured for each phase. You can customize them
|
6
|
-
# by just modifying the phase key on this file.
|
7
|
-
#
|
8
|
-
# By default these phases are configured for Cookbook Workflow only
|
9
|
-
#
|
10
|
-
|
11
|
-
[local_phases]
|
12
|
-
<% if @specs %>
|
13
|
-
unit = "chef exec rspec spec/"
|
14
|
-
<% else %>
|
15
|
-
unit = "echo skipping unit phase."
|
16
|
-
<% end %>
|
17
|
-
lint = "chef exec cookstyle"
|
18
|
-
# foodcritic has been deprecated in favor of cookstyle so we skip the syntax
|
19
|
-
# phase now.
|
20
|
-
syntax = "echo skipping syntax phase. Use lint phase instead."
|
21
|
-
provision = "chef exec kitchen create"
|
22
|
-
deploy = "chef exec kitchen converge"
|
23
|
-
smoke = "chef exec kitchen verify"
|
24
|
-
# The functional phase is optional, you can define it by uncommenting
|
25
|
-
# the line below and running the command: `delivery local functional`
|
26
|
-
# functional = ""
|
27
|
-
cleanup = "chef exec kitchen destroy"
|
28
|
-
|
29
|
-
# Remote project.toml file
|
30
|
-
#
|
31
|
-
# Instead of the local phases above, you may specify a remote URI location for
|
32
|
-
# the `project.toml` file. This is useful for teams that wish to centrally
|
33
|
-
# manage the behavior of the `delivery local` command across many different
|
34
|
-
# projects.
|
35
|
-
#
|
36
|
-
# remote_file = "https://url/project.toml"
|