chef-cli 5.3.1 → 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/Rakefile +1 -1
- data/chef-cli.gemspec +1 -1
- data/lib/chef-cli/authenticated_http.rb +1 -1
- data/lib/chef-cli/builtin_commands.rb +1 -4
- 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 +12 -1
- data/lib/chef-cli/command/clean_policy_cookbooks.rb +1 -12
- data/lib/chef-cli/command/clean_policy_revisions.rb +1 -12
- data/lib/chef-cli/command/delete_policy.rb +1 -12
- data/lib/chef-cli/command/delete_policy_group.rb +1 -12
- data/lib/chef-cli/command/describe_cookbook.rb +17 -0
- data/lib/chef-cli/command/diff.rb +1 -12
- data/lib/chef-cli/command/env.rb +1 -1
- data/lib/chef-cli/command/exec.rb +1 -1
- data/lib/chef-cli/command/gem.rb +1 -1
- data/lib/chef-cli/command/generate.rb +1 -6
- 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 +15 -41
- 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/policyfile.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.rb +1 -1
- data/lib/chef-cli/command/install.rb +1 -12
- data/lib/chef-cli/command/push.rb +1 -12
- data/lib/chef-cli/command/push_archive.rb +1 -12
- data/lib/chef-cli/command/shell_init.rb +1 -1
- data/lib/chef-cli/command/show_policy.rb +1 -12
- data/lib/chef-cli/command/undelete.rb +1 -12
- data/lib/chef-cli/command/update.rb +1 -1
- data/lib/chef-cli/commands_map.rb +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 +1 -1
- data/lib/chef-cli/cookbook_profiler/git.rb +3 -3
- 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/exceptions.rb +1 -1
- data/lib/chef-cli/generator.rb +1 -1
- data/lib/chef-cli/helpers.rb +1 -1
- 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 +1 -1
- 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/git_lock_fetcher.rb +1 -1
- 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 +1 -1
- 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/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/metadata.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/recipes/cookbook.rb +0 -29
- data/lib/chef-cli/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen.yml.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +3 -4
- data/lib/chef-cli/skeletons/code_generator/templates/default/metadata.rb.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/recipe_spec.rb.erb +2 -2
- data/lib/chef-cli/ui.rb +1 -1
- data/lib/chef-cli/version.rb +2 -2
- data/lib/chef-cli.rb +1 -1
- data/spec/shared/custom_generator_cookbook.rb +0 -44
- 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 +3 -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 +1 -1
- data/spec/unit/command/base_spec.rb +6 -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 +1 -1
- data/spec/unit/command/exec_spec.rb +1 -1
- data/spec/unit/command/generate_spec.rb +1 -9
- 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 +5 -336
- 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/policyfile_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/install_spec.rb +1 -1
- 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 +1 -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_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 +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 +1 -1
- 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 +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 +1 -1
- 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 +4 -7
- 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
|
@@ -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,298 +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 via
|
|
377
|
-
## 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: 16
|
|
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
|
-
attributes:
|
|
404
|
-
KITCHEN_YML
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
end
|
|
408
|
-
|
|
409
|
-
include_examples "chefspec_spec_helper_file" do
|
|
410
|
-
let(:argv) { %w{ new_cookbook --policy --specs } }
|
|
411
|
-
|
|
412
|
-
let(:expected_chefspec_spec_helper_content) do
|
|
413
|
-
<<~SPEC_HELPER
|
|
414
|
-
require 'chefspec'
|
|
415
|
-
require 'chefspec/policyfile'
|
|
416
|
-
SPEC_HELPER
|
|
417
|
-
end
|
|
418
|
-
|
|
419
|
-
end
|
|
420
|
-
|
|
421
|
-
end
|
|
422
|
-
|
|
423
|
-
context "when YAML recipe flag is passed" do
|
|
424
|
-
|
|
425
|
-
let(:argv) { %w{new_cookbook --yaml} }
|
|
426
|
-
|
|
427
|
-
describe "recipes/default.yml" do
|
|
428
|
-
let(:file) { File.join(tempdir, "new_cookbook", "recipes", "default.yml") }
|
|
429
|
-
|
|
430
|
-
let(:expected_content_header) do
|
|
431
|
-
<<~DEFAULT_YML_HEADER
|
|
432
|
-
#
|
|
433
|
-
# Cookbook:: new_cookbook
|
|
434
|
-
# Recipe:: default
|
|
435
|
-
#
|
|
436
|
-
DEFAULT_YML_HEADER
|
|
437
|
-
end
|
|
438
|
-
|
|
439
|
-
let(:expected_content) do
|
|
440
|
-
<<~DEFAULT_YML_CONTENT
|
|
441
|
-
---
|
|
442
|
-
resources:
|
|
443
|
-
# Example Syntax
|
|
444
|
-
# Additional snippets are available using the Chef Infra Extension for Visual Studio Code
|
|
445
|
-
# - type: file
|
|
446
|
-
# name: '/path/to/file'
|
|
447
|
-
# content: 'content'
|
|
448
|
-
# owner: 'root'
|
|
449
|
-
# group: 'root'
|
|
450
|
-
# mode: '0755'
|
|
451
|
-
# action:
|
|
452
|
-
# - create
|
|
453
|
-
DEFAULT_YML_CONTENT
|
|
454
|
-
end
|
|
455
|
-
|
|
456
|
-
before do
|
|
457
|
-
Dir.chdir(tempdir) do
|
|
458
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
|
459
|
-
expect(cookbook_generator.run).to eq(0)
|
|
460
|
-
end
|
|
461
|
-
end
|
|
462
|
-
|
|
463
|
-
it "has a default.yml file with template contents" do
|
|
464
|
-
expect(IO.read(file)).to match(expected_content_header)
|
|
465
|
-
expect(IO.read(file)).to match(expected_content)
|
|
466
|
-
end
|
|
467
|
-
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
end
|
|
471
|
-
|
|
472
|
-
context "when configured for Berkshelf" do
|
|
473
|
-
|
|
474
|
-
let(:argv) { %w{new_cookbook --berks} }
|
|
475
|
-
|
|
476
|
-
describe "Berksfile" do
|
|
477
|
-
|
|
478
|
-
let(:file) { File.join(tempdir, "new_cookbook", "Berksfile") }
|
|
479
|
-
|
|
480
|
-
let(:expected_content) do
|
|
481
|
-
<<~POLICYFILE_RB
|
|
482
|
-
source 'https://supermarket.chef.io'
|
|
483
|
-
|
|
484
|
-
metadata
|
|
485
|
-
POLICYFILE_RB
|
|
486
|
-
end
|
|
487
|
-
|
|
488
|
-
before do
|
|
489
|
-
Dir.chdir(tempdir) do
|
|
490
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
|
491
|
-
expect(cookbook_generator.run).to eq(0)
|
|
492
|
-
end
|
|
493
|
-
end
|
|
494
|
-
|
|
495
|
-
it "pulls deps from metadata" do
|
|
496
|
-
expect(IO.read(file)).to eq(expected_content)
|
|
497
|
-
end
|
|
498
|
-
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
include_examples "kitchen_yml_and_integration_tests" do
|
|
502
|
-
|
|
503
|
-
let(:expected_kitchen_yml_content) do
|
|
504
|
-
<<~KITCHEN_YML
|
|
505
|
-
---
|
|
506
|
-
driver:
|
|
507
|
-
name: vagrant
|
|
508
|
-
|
|
509
|
-
## The forwarded_port port feature lets you connect to ports on the VM guest via
|
|
510
|
-
## localhost on the host.
|
|
511
|
-
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
|
512
|
-
|
|
513
|
-
# network:
|
|
514
|
-
# - ["forwarded_port", {guest: 80, host: 8080}]
|
|
515
|
-
|
|
516
|
-
provisioner:
|
|
517
|
-
name: chef_zero
|
|
518
|
-
# You may wish to disable always updating cookbooks in CI or other testing environments.
|
|
519
|
-
# For example:
|
|
520
|
-
# always_update_cookbooks: <%= !ENV['CI'] %>
|
|
521
|
-
always_update_cookbooks: true
|
|
522
|
-
|
|
523
|
-
## product_name and product_version specifies a specific Chef product and version to install.
|
|
524
|
-
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
|
525
|
-
# product_name: chef
|
|
526
|
-
# product_version: 16
|
|
527
|
-
|
|
528
|
-
verifier:
|
|
529
|
-
name: inspec
|
|
530
|
-
|
|
531
|
-
platforms:
|
|
532
|
-
- name: ubuntu-20.04
|
|
533
|
-
- name: centos-8
|
|
534
|
-
|
|
535
|
-
suites:
|
|
536
|
-
- name: default
|
|
537
|
-
run_list:
|
|
538
|
-
- recipe[new_cookbook::default]
|
|
539
|
-
verifier:
|
|
540
|
-
inspec_tests:
|
|
541
|
-
- test/integration/default
|
|
542
|
-
attributes:
|
|
543
|
-
KITCHEN_YML
|
|
544
|
-
end
|
|
545
|
-
|
|
546
|
-
end
|
|
547
|
-
|
|
548
|
-
include_examples "chefspec_spec_helper_file" do
|
|
549
|
-
let(:argv) { %w{ new_cookbook --berks --specs } }
|
|
550
|
-
|
|
551
|
-
let(:expected_chefspec_spec_helper_content) do
|
|
552
|
-
<<~SPEC_HELPER
|
|
553
|
-
require 'chefspec'
|
|
554
|
-
require 'chefspec/berkshelf'
|
|
555
|
-
SPEC_HELPER
|
|
556
|
-
end
|
|
557
|
-
|
|
558
|
-
end
|
|
559
|
-
|
|
560
|
-
end
|
|
561
|
-
|
|
562
231
|
describe "metadata.rb" do
|
|
563
232
|
let(:file) { File.join(tempdir, "new_cookbook", "metadata.rb") }
|
|
564
233
|
|
data/spec/unit/generator_spec.rb
CHANGED
data/spec/unit/helpers_spec.rb
CHANGED
data/spec/unit/pager_spec.rb
CHANGED