chef-cli 5.1.0 → 5.4.1
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/Rakefile +1 -1
- data/chef-cli.gemspec +2 -2
- data/lib/chef-cli.rb +1 -1
- data/lib/chef-cli/authenticated_http.rb +1 -1
- data/lib/chef-cli/builtin_commands.rb +1 -1
- 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 +1 -1
- data/lib/chef-cli/command/delete_policy_group.rb +1 -1
- data/lib/chef-cli/command/describe_cookbook.rb +17 -0
- data/lib/chef-cli/command/diff.rb +1 -1
- data/lib/chef-cli/command/env.rb +1 -1
- data/lib/chef-cli/command/exec.rb +1 -1
- data/lib/chef-cli/command/export.rb +14 -6
- data/lib/chef-cli/command/gem.rb +1 -1
- data/lib/chef-cli/command/generate.rb +1 -1
- data/lib/chef-cli/command/generator_commands.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/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/install.rb +1 -1
- data/lib/chef-cli/command/provision.rb +1 -1
- data/lib/chef-cli/command/push.rb +1 -1
- data/lib/chef-cli/command/push_archive.rb +1 -1
- data/lib/chef-cli/command/shell_init.rb +1 -1
- data/lib/chef-cli/command/show_policy.rb +1 -1
- data/lib/chef-cli/command/undelete.rb +1 -1
- 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 +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/exceptions.rb +13 -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/dsl.rb +16 -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/export_repo.rb +9 -13
- 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.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_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/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_policyfile.yml.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/metadata.rb.erb +1 -1
- data/lib/chef-cli/ui.rb +1 -1
- data/lib/chef-cli/version.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/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 +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 +1 -1
- data/spec/unit/command/exec_spec.rb +1 -1
- data/spec/unit/command/export_spec.rb +18 -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 +2 -2
- 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_metadata_spec.rb +20 -1
- data/spec/unit/cookbook_profiler/git_spec.rb +1 -1
- data/spec/unit/cookbook_profiler/identifiers_spec.rb +1 -1
- data/spec/unit/fixtures/example_cookbook_both_metadata/.gitignore +17 -0
- data/spec/unit/fixtures/example_cookbook_both_metadata/.kitchen.yml +16 -0
- data/spec/unit/fixtures/example_cookbook_both_metadata/Berksfile +3 -0
- data/spec/unit/fixtures/example_cookbook_both_metadata/README.md +4 -0
- data/spec/unit/fixtures/example_cookbook_both_metadata/chefignore +96 -0
- data/spec/unit/fixtures/example_cookbook_both_metadata/metadata.json +5 -0
- data/spec/unit/fixtures/example_cookbook_both_metadata/metadata.rb +9 -0
- data/spec/unit/fixtures/example_cookbook_both_metadata/recipes/default.rb +8 -0
- 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_evaluation_spec.rb +67 -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 +51 -2
- 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 +22 -6
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -555,6 +555,72 @@ describe ChefCLI::PolicyfileCompiler do
|
|
555
555
|
|
556
556
|
end
|
557
557
|
|
558
|
+
describe "the metadata DSL keyword used in a cookbook with metadata" do
|
559
|
+
let(:policyfile_rb) do
|
560
|
+
<<-EOH
|
561
|
+
run_list "foo"
|
562
|
+
metadata
|
563
|
+
EOH
|
564
|
+
end
|
565
|
+
it "reads the metadata from the current cookbook" do
|
566
|
+
expect(File).to receive(:exist?).with("./metadata.rb").and_return(true)
|
567
|
+
expect(ChefCLI::CookbookMetadata).to receive(:from_path).and_return(double(cookbook_name: "foo"))
|
568
|
+
expect(policyfile.errors.size).to eq(0)
|
569
|
+
expect(policyfile.errors.first).to eq(nil)
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
describe "the metadata DSL keyword used in a cookbook without metadata" do
|
574
|
+
let(:policyfile_rb) do
|
575
|
+
<<-EOH
|
576
|
+
run_list "foo"
|
577
|
+
metadata
|
578
|
+
EOH
|
579
|
+
end
|
580
|
+
it "throws a missing cookbook metadata error" do
|
581
|
+
expected = <<~EOH
|
582
|
+
Evaluation of policyfile 'TestPolicyfile.rb' raised an exception
|
583
|
+
Exception: ChefCLI::PolicyfileMissingCookbookMetadata "Policyfile specified to use cookbook metadata, but neither ./metadata.rb or ./metadata.json was found."
|
584
|
+
|
585
|
+
Relevant Code:
|
586
|
+
2: metadata
|
587
|
+
|
588
|
+
Backtrace:
|
589
|
+
TestPolicyfile.rb:2:in `eval_policyfile'
|
590
|
+
EOH
|
591
|
+
expect(File).to receive(:exist?).with("./metadata.rb").and_return(false)
|
592
|
+
expect(File).to receive(:exist?).with("./metadata.json").and_return(false)
|
593
|
+
expect(policyfile.errors.size).to eq(1)
|
594
|
+
expect(policyfile.errors.first).to eq(expected)
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
598
|
+
describe "the metadata DSL keyword used in a cookbook with bad metadata" do
|
599
|
+
let(:policyfile_rb) do
|
600
|
+
<<-EOH
|
601
|
+
run_list "foo"
|
602
|
+
metadata
|
603
|
+
EOH
|
604
|
+
end
|
605
|
+
it "throws a bad cookbook metadata error" do
|
606
|
+
expected = <<~EOH
|
607
|
+
Evaluation of policyfile 'TestPolicyfile.rb' raised an exception
|
608
|
+
Exception: ChefCLI::PolicyfileBadCookbookMetadata "Cookbook metadata for cookbook at . could not be parsed:
|
609
|
+
Original Exception: No such file or directory @ rb_sysopen - ./metadata.json"
|
610
|
+
|
611
|
+
Relevant Code:
|
612
|
+
2: metadata
|
613
|
+
|
614
|
+
Backtrace:
|
615
|
+
TestPolicyfile.rb:2:in `eval_policyfile'
|
616
|
+
EOH
|
617
|
+
expect(File).to receive(:exist?).with("./metadata.rb").and_return(true)
|
618
|
+
expect(File).to receive(:exist?).with("./metadata.json").and_return(true)
|
619
|
+
expect(policyfile.errors.size).to eq(1)
|
620
|
+
expect(policyfile.errors.first).to eq(expected)
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
558
624
|
describe "defining attributes" do
|
559
625
|
|
560
626
|
let(:policyfile_rb) do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright::
|
2
|
+
# Copyright:: Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -42,12 +42,15 @@ describe ChefCLI::PolicyfileServices::ExportRepo do
|
|
42
42
|
|
43
43
|
let(:archive) { false }
|
44
44
|
|
45
|
+
let(:policy_group) { nil }
|
46
|
+
|
45
47
|
subject(:export_service) do
|
46
48
|
described_class.new(policyfile: policyfile_rb_explicit_name,
|
47
49
|
root_dir: working_dir,
|
48
50
|
export_dir: export_dir,
|
49
51
|
archive: archive,
|
50
|
-
force: force_export
|
52
|
+
force: force_export,
|
53
|
+
policy_group: policy_group)
|
51
54
|
end
|
52
55
|
|
53
56
|
it "uses Policyfile.rb as the default Policyfile name" do
|
@@ -306,6 +309,52 @@ describe ChefCLI::PolicyfileServices::ExportRepo do
|
|
306
309
|
expect(File).to exist(readme_path)
|
307
310
|
end
|
308
311
|
|
312
|
+
context "when the policy_group is changed" do
|
313
|
+
let(:policy_group) { "production" }
|
314
|
+
it "creates a policy_group file for a specified policy group with the revision id of the exported policy" do
|
315
|
+
exported_policy_group_path = File.join(export_dir, "policy_groups", "production.json")
|
316
|
+
exported_policy_group_data = FFI_Yajl::Parser.parse(IO.read(exported_policy_group_path))
|
317
|
+
|
318
|
+
expected_data = { "policies" => { "install-example" => { "revision_id" => revision_id } } }
|
319
|
+
|
320
|
+
expect(exported_policy_group_data).to eq(expected_data)
|
321
|
+
end
|
322
|
+
|
323
|
+
it "creates a working local mode configuration file with the changed policy_group" do
|
324
|
+
expected_config_text = <<~CONFIG
|
325
|
+
### Chef Infra Client Configuration ###
|
326
|
+
# The settings in this file will configure chef to apply the exported policy in
|
327
|
+
# this directory. To use it, run:
|
328
|
+
#
|
329
|
+
# chef-client -z
|
330
|
+
#
|
331
|
+
|
332
|
+
policy_name 'install-example'
|
333
|
+
policy_group 'production'
|
334
|
+
|
335
|
+
use_policyfile true
|
336
|
+
policy_document_native_api true
|
337
|
+
|
338
|
+
# In order to use this repo, you need a version of Chef Infra Client and Chef Zero
|
339
|
+
# that supports policyfile "native mode" APIs:
|
340
|
+
current_version = Gem::Version.new(Chef::VERSION)
|
341
|
+
unless Gem::Requirement.new(">= 12.7").satisfied_by?(current_version)
|
342
|
+
puts("!" * 80)
|
343
|
+
puts(<<-MESSAGE)
|
344
|
+
This Chef Repo requires features introduced in Chef Infra Client 12.7, but you are using
|
345
|
+
Chef \#{Chef::VERSION}. Please upgrade to Chef Infra Client 12.7 or later.
|
346
|
+
MESSAGE
|
347
|
+
puts("!" * 80)
|
348
|
+
exit!(1)
|
349
|
+
end
|
350
|
+
|
351
|
+
CONFIG
|
352
|
+
config_path = File.join(export_dir, ".chef", "config.rb")
|
353
|
+
expect(File).to exist(config_path)
|
354
|
+
expect(IO.read(config_path)).to eq(expected_config_text)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
309
358
|
end
|
310
359
|
|
311
360
|
context "when the export dir is empty" do
|