chef-dk 1.2.22 → 1.3.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -12
- data/Gemfile.lock +120 -116
- data/README.md +4 -3
- data/Rakefile +54 -0
- data/acceptance/Gemfile.lock +36 -47
- data/bin/chef +1 -1
- data/chef-dk.gemspec +9 -9
- data/lib/chef-dk/authenticated_http.rb +6 -7
- data/lib/chef-dk/builtin_commands.rb +3 -4
- data/lib/chef-dk/chef_runner.rb +7 -8
- data/lib/chef-dk/cli.rb +11 -11
- data/lib/chef-dk/command/base.rb +4 -4
- data/lib/chef-dk/command/clean_policy_cookbooks.rb +4 -5
- data/lib/chef-dk/command/clean_policy_revisions.rb +4 -6
- data/lib/chef-dk/command/delete_policy.rb +4 -6
- data/lib/chef-dk/command/delete_policy_group.rb +6 -8
- data/lib/chef-dk/command/diff.rb +9 -10
- data/lib/chef-dk/command/env.rb +26 -27
- data/lib/chef-dk/command/exec.rb +5 -6
- data/lib/chef-dk/command/export.rb +8 -10
- data/lib/chef-dk/command/gem.rb +5 -5
- data/lib/chef-dk/command/generate.rb +19 -19
- data/lib/chef-dk/command/generator_commands.rb +8 -8
- data/lib/chef-dk/command/generator_commands/app.rb +2 -3
- data/lib/chef-dk/command/generator_commands/attribute.rb +2 -3
- data/lib/chef-dk/command/generator_commands/base.rb +13 -13
- data/lib/chef-dk/command/generator_commands/build_cookbook.rb +2 -2
- data/lib/chef-dk/command/generator_commands/chef_exts/generator_desc_resource.rb +2 -2
- data/lib/chef-dk/command/generator_commands/chef_exts/quieter_doc_formatter.rb +1 -2
- data/lib/chef-dk/command/generator_commands/chef_exts/recipe_dsl_ext.rb +1 -2
- data/lib/chef-dk/command/generator_commands/cookbook.rb +2 -2
- data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +3 -3
- data/lib/chef-dk/command/generator_commands/cookbook_file.rb +2 -2
- data/lib/chef-dk/command/generator_commands/generator_generator.rb +4 -7
- data/lib/chef-dk/command/generator_commands/lwrp.rb +2 -2
- data/lib/chef-dk/command/generator_commands/policyfile.rb +2 -3
- data/lib/chef-dk/command/generator_commands/recipe.rb +2 -2
- data/lib/chef-dk/command/generator_commands/repo.rb +1 -3
- data/lib/chef-dk/command/generator_commands/template.rb +2 -2
- data/lib/chef-dk/command/install.rb +4 -5
- data/lib/chef-dk/command/provision.rb +12 -14
- data/lib/chef-dk/command/push.rb +5 -6
- data/lib/chef-dk/command/push_archive.rb +4 -5
- data/lib/chef-dk/command/shell_init.rb +15 -16
- data/lib/chef-dk/command/show_policy.rb +5 -7
- data/lib/chef-dk/command/undelete.rb +6 -7
- data/lib/chef-dk/command/update.rb +5 -6
- data/lib/chef-dk/command/verify.rb +30 -31
- data/lib/chef-dk/commands_map.rb +1 -3
- data/lib/chef-dk/component_test.rb +13 -13
- data/lib/chef-dk/configurable.rb +2 -2
- data/lib/chef-dk/cookbook_metadata.rb +2 -2
- data/lib/chef-dk/cookbook_omnifetch.rb +7 -8
- data/lib/chef-dk/cookbook_profiler/git.rb +8 -8
- data/lib/chef-dk/cookbook_profiler/identifiers.rb +7 -7
- data/lib/chef-dk/cookbook_profiler/null_scm.rb +0 -1
- data/lib/chef-dk/exceptions.rb +1 -1
- data/lib/chef-dk/generator.rb +9 -7
- data/lib/chef-dk/helpers.rb +15 -15
- data/lib/chef-dk/pager.rb +2 -3
- data/lib/chef-dk/policyfile/chef_repo_cookbook_source.rb +4 -4
- data/lib/chef-dk/policyfile/chef_server_cookbook_source.rb +6 -6
- data/lib/chef-dk/policyfile/community_cookbook_source.rb +4 -5
- data/lib/chef-dk/policyfile/comparison_base.rb +3 -4
- data/lib/chef-dk/policyfile/cookbook_location_specification.rb +6 -6
- data/lib/chef-dk/policyfile/cookbook_locks.rb +11 -11
- data/lib/chef-dk/policyfile/cookbook_sources.rb +5 -5
- data/lib/chef-dk/policyfile/delivery_supermarket_source.rb +8 -9
- data/lib/chef-dk/policyfile/differ.rb +7 -10
- data/lib/chef-dk/policyfile/dsl.rb +10 -11
- data/lib/chef-dk/policyfile/lister.rb +3 -6
- data/lib/chef-dk/policyfile/null_cookbook_source.rb +3 -3
- data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +3 -3
- data/lib/chef-dk/policyfile/reports/install.rb +3 -4
- data/lib/chef-dk/policyfile/reports/table_printer.rb +0 -1
- data/lib/chef-dk/policyfile/reports/upload.rb +4 -4
- data/lib/chef-dk/policyfile/solution_dependencies.rb +22 -22
- data/lib/chef-dk/policyfile/source_uri.rb +2 -2
- data/lib/chef-dk/policyfile/storage_config.rb +4 -5
- data/lib/chef-dk/policyfile/undo_record.rb +6 -9
- data/lib/chef-dk/policyfile/undo_stack.rb +5 -7
- data/lib/chef-dk/policyfile/uploader.rb +8 -8
- data/lib/chef-dk/policyfile_compiler.rb +16 -20
- data/lib/chef-dk/policyfile_lock.rb +10 -11
- data/lib/chef-dk/policyfile_services/clean_policies.rb +3 -3
- data/lib/chef-dk/policyfile_services/clean_policy_cookbooks.rb +3 -5
- data/lib/chef-dk/policyfile_services/export_repo.rb +13 -14
- data/lib/chef-dk/policyfile_services/install.rb +6 -6
- data/lib/chef-dk/policyfile_services/push.rb +6 -8
- data/lib/chef-dk/policyfile_services/push_archive.rb +6 -10
- data/lib/chef-dk/policyfile_services/rm_policy.rb +4 -5
- data/lib/chef-dk/policyfile_services/rm_policy_group.rb +4 -5
- data/lib/chef-dk/policyfile_services/show_policy.rb +5 -6
- data/lib/chef-dk/policyfile_services/undelete.rb +3 -3
- data/lib/chef-dk/policyfile_services/update_attributes.rb +4 -6
- data/lib/chef-dk/service_exception_inspectors.rb +2 -3
- data/lib/chef-dk/service_exception_inspectors/base.rb +0 -1
- data/lib/chef-dk/service_exception_inspectors/http.rb +1 -3
- data/lib/chef-dk/service_exceptions.rb +1 -2
- data/lib/chef-dk/shell_out.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/.kitchen.yml +2 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/README.md +2 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/metadata.rb +0 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/app.rb +6 -6
- data/lib/chef-dk/skeletons/code_generator/recipes/attribute.rb +3 -3
- data/lib/chef-dk/skeletons/code_generator/recipes/build_cookbook.rb +43 -39
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +31 -22
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook_file.rb +5 -5
- data/lib/chef-dk/skeletons/code_generator/recipes/lwrp.rb +4 -4
- data/lib/chef-dk/skeletons/code_generator/recipes/policyfile.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/recipe.rb +8 -8
- data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +15 -15
- data/lib/chef-dk/skeletons/code_generator/recipes/template.rb +6 -6
- data/lib/chef-dk/skeletons/code_generator/templates/default/build_cookbook/Berksfile.erb +0 -2
- data/lib/chef-dk/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +1 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +4 -4
- data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen.yml.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +4 -3
- data/lib/chef-dk/skeletons/code_generator/templates/default/recipe_spec.rb.erb +4 -2
- data/lib/chef-dk/ui.rb +0 -1
- data/lib/chef-dk/version.rb +1 -1
- data/lib/kitchen/provisioner/policyfile_zero.rb +7 -7
- data/omnibus_overrides.rb +3 -3
- data/spec/shared/a_file_generator.rb +3 -3
- data/spec/shared/custom_generator_cookbook.rb +6 -6
- data/spec/shared/fixture_cookbook_checksums.rb +2 -3
- data/spec/shared/setup_git_committer_config.rb +1 -1
- data/spec/shared/setup_git_cookbooks.rb +2 -2
- data/spec/spec_helper.rb +5 -5
- data/spec/test_helpers.rb +2 -2
- data/spec/unit/chef_runner_spec.rb +5 -7
- data/spec/unit/cli_spec.rb +36 -37
- data/spec/unit/command/base_spec.rb +4 -5
- data/spec/unit/command/clean_policy_cookbooks_spec.rb +8 -9
- data/spec/unit/command/clean_policy_revisions_spec.rb +8 -9
- data/spec/unit/command/delete_policy_group_spec.rb +11 -12
- data/spec/unit/command/delete_policy_spec.rb +11 -12
- data/spec/unit/command/diff_spec.rb +5 -6
- data/spec/unit/command/env_spec.rb +5 -5
- data/spec/unit/command/exec_spec.rb +18 -19
- data/spec/unit/command/export_spec.rb +5 -6
- data/spec/unit/command/generate_spec.rb +10 -10
- data/spec/unit/command/generator_commands/app_spec.rb +6 -6
- data/spec/unit/command/generator_commands/attribute_spec.rb +3 -4
- data/spec/unit/command/generator_commands/base_spec.rb +46 -46
- data/spec/unit/command/generator_commands/build_cookbook_spec.rb +50 -16
- data/spec/unit/command/generator_commands/chef_exts/generator_desc_resource_spec.rb +9 -9
- data/spec/unit/command/generator_commands/chef_exts/recipe_dsl_ext_spec.rb +16 -16
- data/spec/unit/command/generator_commands/cookbook_file_spec.rb +3 -4
- data/spec/unit/command/generator_commands/cookbook_spec.rb +23 -26
- data/spec/unit/command/generator_commands/generator_generator_spec.rb +4 -6
- data/spec/unit/command/generator_commands/lwrp_spec.rb +3 -4
- data/spec/unit/command/generator_commands/policyfile_spec.rb +3 -5
- data/spec/unit/command/generator_commands/recipe_spec.rb +4 -4
- data/spec/unit/command/generator_commands/repo_spec.rb +11 -11
- data/spec/unit/command/generator_commands/template_spec.rb +3 -4
- data/spec/unit/command/install_spec.rb +6 -6
- data/spec/unit/command/provision_spec.rb +27 -30
- data/spec/unit/command/push_archive_spec.rb +3 -3
- data/spec/unit/command/push_spec.rb +5 -6
- data/spec/unit/command/shell_init_spec.rb +17 -19
- data/spec/unit/command/show_policy_spec.rb +11 -12
- data/spec/unit/command/undelete_spec.rb +12 -14
- data/spec/unit/command/update_spec.rb +8 -8
- data/spec/unit/command/verify_spec.rb +10 -10
- data/spec/unit/commands_map_spec.rb +4 -4
- data/spec/unit/component_test_spec.rb +3 -3
- data/spec/unit/configurable_spec.rb +7 -7
- data/spec/unit/cookbook_metadata_spec.rb +5 -7
- data/spec/unit/cookbook_profiler/git_spec.rb +6 -7
- data/spec/unit/cookbook_profiler/identifiers_spec.rb +5 -7
- data/spec/unit/fixtures/command/cli_test_command.rb +2 -2
- data/spec/unit/fixtures/configurable/test_configurable.rb +1 -1
- data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +13 -16
- data/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/berkshelf/verify_me +1 -1
- data/spec/unit/gemfile_util_spec.rb +4 -4
- data/spec/unit/generator_spec.rb +10 -10
- data/spec/unit/helpers_spec.rb +31 -31
- data/spec/unit/pager_spec.rb +5 -7
- data/spec/unit/policyfile/chef_repo_cookbook_source_spec.rb +11 -11
- data/spec/unit/policyfile/chef_server_cookbook_source_spec.rb +13 -13
- data/spec/unit/policyfile/community_cookbook_source_spec.rb +3 -4
- data/spec/unit/policyfile/comparison_base_spec.rb +3 -6
- data/spec/unit/policyfile/cookbook_location_specification_spec.rb +3 -3
- data/spec/unit/policyfile/cookbook_locks_spec.rb +7 -9
- data/spec/unit/policyfile/delivery_supermarket_source_spec.rb +16 -17
- data/spec/unit/policyfile/differ_spec.rb +4 -5
- data/spec/unit/policyfile/lister_spec.rb +31 -35
- data/spec/unit/policyfile/null_cookbook_source_spec.rb +2 -3
- data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +3 -3
- data/spec/unit/policyfile/reports/install_spec.rb +4 -5
- data/spec/unit/policyfile/reports/upload_spec.rb +4 -6
- data/spec/unit/policyfile/solution_dependencies_spec.rb +13 -13
- data/spec/unit/policyfile/source_uri_spec.rb +5 -5
- data/spec/unit/policyfile/storage_config_spec.rb +3 -7
- data/spec/unit/policyfile/undo_record_spec.rb +21 -23
- data/spec/unit/policyfile/undo_stack_spec.rb +5 -6
- data/spec/unit/policyfile/uploader_spec.rb +73 -75
- data/spec/unit/policyfile_demands_spec.rb +93 -99
- data/spec/unit/policyfile_evaluation_spec.rb +14 -14
- data/spec/unit/policyfile_lock_build_spec.rb +64 -65
- data/spec/unit/policyfile_lock_install_spec.rb +5 -6
- data/spec/unit/policyfile_lock_serialization_spec.rb +14 -15
- data/spec/unit/policyfile_lock_validation_spec.rb +17 -20
- data/spec/unit/policyfile_services/clean_policies_spec.rb +16 -16
- data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +26 -29
- data/spec/unit/policyfile_services/export_repo_spec.rb +3 -6
- data/spec/unit/policyfile_services/install_spec.rb +5 -7
- data/spec/unit/policyfile_services/push_archive_spec.rb +4 -8
- data/spec/unit/policyfile_services/push_spec.rb +3 -3
- data/spec/unit/policyfile_services/rm_policy_group_spec.rb +16 -20
- data/spec/unit/policyfile_services/rm_policy_spec.rb +14 -17
- data/spec/unit/policyfile_services/show_policy_spec.rb +78 -80
- data/spec/unit/policyfile_services/undelete_spec.rb +5 -7
- data/spec/unit/policyfile_services/update_attributes_spec.rb +34 -35
- data/spec/unit/service_exception_inspectors/base_spec.rb +2 -4
- data/spec/unit/service_exception_inspectors/http_spec.rb +9 -11
- data/spec/unit/shell_out_spec.rb +2 -2
- data/spec/unit/tasks/helpers_spec.rb +2 -2
- data/tasks/bin/bundle-platform +1 -1
- data/tasks/bundle_util.rb +1 -1
- data/tasks/dependencies.rb +21 -7
- data/tasks/gemfile_util.rb +1 -1
- data/tasks/helpers.rb +2 -2
- data/tasks/version.rb +26 -1
- data/version_policy.rb +6 -6
- metadata +3 -3
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/a_file_generator"
|
20
|
+
require "chef-dk/command/generator_commands/cookbook_file"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::CookbookFile do
|
23
23
|
|
@@ -29,4 +29,3 @@ describe ChefDK::Command::GeneratorCommands::CookbookFile do
|
|
29
29
|
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
@@ -15,22 +15,22 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/custom_generator_cookbook"
|
20
|
+
require "shared/setup_git_committer_config"
|
21
|
+
require "chef-dk/command/generator_commands/cookbook"
|
22
22
|
|
23
23
|
describe ChefDK::Command::GeneratorCommands::Cookbook do
|
24
24
|
|
25
25
|
include_context("setup_git_committer_config")
|
26
26
|
|
27
|
-
let(:argv) { %w
|
27
|
+
let(:argv) { %w{new_cookbook} }
|
28
28
|
|
29
29
|
let(:stdout_io) { StringIO.new }
|
30
30
|
let(:stderr_io) { StringIO.new }
|
31
31
|
|
32
32
|
let(:expected_cookbook_file_relpaths) do
|
33
|
-
%w
|
33
|
+
%w{
|
34
34
|
.gitignore
|
35
35
|
.kitchen.yml
|
36
36
|
test
|
@@ -47,7 +47,7 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
|
|
47
47
|
spec/unit
|
48
48
|
spec/unit/recipes
|
49
49
|
spec/unit/recipes/default_spec.rb
|
50
|
-
|
50
|
+
}
|
51
51
|
end
|
52
52
|
|
53
53
|
let(:expected_cookbook_files) do
|
@@ -56,8 +56,8 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
|
-
<<-EOF
|
59
|
+
let(:non_delivery_breadcrumb) do
|
60
|
+
<<-EOF
|
61
61
|
Your cookbook is ready. Type `cd new_cookbook` to enter it.
|
62
62
|
|
63
63
|
There are several commands you can run to get started locally developing and testing your cookbook.
|
@@ -71,7 +71,7 @@ If you'd prefer to dive right in, the default recipe can be found at:
|
|
71
71
|
|
72
72
|
recipes/default.rb
|
73
73
|
EOF
|
74
|
-
|
74
|
+
end
|
75
75
|
|
76
76
|
subject(:cookbook_generator) do
|
77
77
|
g = described_class.new(argv)
|
@@ -98,7 +98,7 @@ EOF
|
|
98
98
|
|
99
99
|
it "configures the chef runner" do
|
100
100
|
expect(cookbook_generator.chef_runner).to be_a(ChefDK::ChefRunner)
|
101
|
-
expect(cookbook_generator.chef_runner.cookbook_path).to eq(File.expand_path(
|
101
|
+
expect(cookbook_generator.chef_runner.cookbook_path).to eq(File.expand_path("lib/chef-dk/skeletons", project_root))
|
102
102
|
end
|
103
103
|
|
104
104
|
context "when given invalid/incomplete arguments" do
|
@@ -107,7 +107,6 @@ EOF
|
|
107
107
|
"Usage: chef generate cookbook NAME [options]\n"
|
108
108
|
end
|
109
109
|
|
110
|
-
|
111
110
|
def with_argv(argv)
|
112
111
|
generator = described_class.new(argv)
|
113
112
|
allow(generator).to receive(:stdout).and_return(stdout_io)
|
@@ -136,7 +135,7 @@ EOF
|
|
136
135
|
|
137
136
|
context "when given the name of the cookbook to generate" do
|
138
137
|
|
139
|
-
let(:argv) { %w
|
138
|
+
let(:argv) { %w{new_cookbook} }
|
140
139
|
|
141
140
|
before do
|
142
141
|
reset_tempdir
|
@@ -287,15 +286,13 @@ source 'https://supermarket.chef.io'
|
|
287
286
|
metadata
|
288
287
|
|
289
288
|
group :delivery do
|
290
|
-
cookbook 'delivery_build', git: 'https://github.com/chef-cookbooks/delivery_build'
|
291
|
-
cookbook 'delivery-base', git: 'https://github.com/chef-cookbooks/delivery-base'
|
292
289
|
cookbook 'test', path: './test/fixtures/cookbooks/test'
|
293
290
|
end
|
294
291
|
CONFIG_DOT_JSON
|
295
292
|
end
|
296
293
|
|
297
294
|
it "sets the sources for delivery library cookbooks to github" do
|
298
|
-
|
295
|
+
expect(IO.read(file)).to include(expected_content)
|
299
296
|
end
|
300
297
|
|
301
298
|
end
|
@@ -303,9 +300,9 @@ end
|
|
303
300
|
|
304
301
|
context "when passed delivery option" do
|
305
302
|
|
306
|
-
let(:argv) { %w
|
303
|
+
let(:argv) { %w{new_cookbook --delivery} }
|
307
304
|
|
308
|
-
it
|
305
|
+
it "still works with no action" do
|
309
306
|
Dir.chdir(tempdir) do
|
310
307
|
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
311
308
|
expect(cookbook_generator.run).to eq(0)
|
@@ -315,7 +312,7 @@ end
|
|
315
312
|
|
316
313
|
context "when given the verbose flag" do
|
317
314
|
|
318
|
-
let(:argv) { %w
|
315
|
+
let(:argv) { %w{ new_cookbook --verbose } }
|
319
316
|
|
320
317
|
it "configures the generator context with verbose mode enabled" do
|
321
318
|
cookbook_generator.read_and_validate_params
|
@@ -506,7 +503,7 @@ OUTPUT
|
|
506
503
|
|
507
504
|
context "when configured for Policyfiles" do
|
508
505
|
|
509
|
-
let(:argv) { %w
|
506
|
+
let(:argv) { %w{new_cookbook --policy} }
|
510
507
|
|
511
508
|
describe "Policyfile.rb" do
|
512
509
|
|
@@ -575,7 +572,7 @@ verifier:
|
|
575
572
|
|
576
573
|
platforms:
|
577
574
|
- name: ubuntu-16.04
|
578
|
-
- name: centos-7.
|
575
|
+
- name: centos-7.3
|
579
576
|
|
580
577
|
suites:
|
581
578
|
- name: default
|
@@ -603,7 +600,7 @@ SPEC_HELPER
|
|
603
600
|
|
604
601
|
context "when configured for Berkshelf" do
|
605
602
|
|
606
|
-
let(:argv) { %w
|
603
|
+
let(:argv) { %w{new_cookbook --berks} }
|
607
604
|
|
608
605
|
describe "Berksfile" do
|
609
606
|
|
@@ -650,7 +647,7 @@ verifier:
|
|
650
647
|
|
651
648
|
platforms:
|
652
649
|
- name: ubuntu-16.04
|
653
|
-
- name: centos-7.
|
650
|
+
- name: centos-7.3
|
654
651
|
|
655
652
|
suites:
|
656
653
|
- name: default
|
@@ -730,19 +727,19 @@ SPEC_HELPER
|
|
730
727
|
it "configures the generator context for long form option key1" do
|
731
728
|
cookbook_generator.read_and_validate_params
|
732
729
|
cookbook_generator.setup_context
|
733
|
-
expect(generator_context.key1).to eq(
|
730
|
+
expect(generator_context.key1).to eq("value1")
|
734
731
|
end
|
735
732
|
|
736
733
|
it "configures the generator context for short form option key2" do
|
737
734
|
cookbook_generator.read_and_validate_params
|
738
735
|
cookbook_generator.setup_context
|
739
|
-
expect(generator_context.key2).to eq(
|
736
|
+
expect(generator_context.key2).to eq("value2")
|
740
737
|
end
|
741
738
|
|
742
739
|
it "configures the generator context for key3 containing additional spaces" do
|
743
740
|
cookbook_generator.read_and_validate_params
|
744
741
|
cookbook_generator.setup_context
|
745
|
-
expect(generator_context.key3).to eq(
|
742
|
+
expect(generator_context.key3).to eq("value3")
|
746
743
|
end
|
747
744
|
|
748
745
|
end
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "pathname"
|
20
|
+
require "chef-dk/command/generator_commands/generator_generator"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::GeneratorGenerator do
|
23
23
|
|
@@ -41,7 +41,6 @@ describe ChefDK::Command::GeneratorCommands::GeneratorGenerator do
|
|
41
41
|
|
42
42
|
subject(:generator_generator) { described_class.new(argv) }
|
43
43
|
|
44
|
-
|
45
44
|
before do
|
46
45
|
# This has to be the very first thing we do for any tests
|
47
46
|
reset_tempdir
|
@@ -212,7 +211,7 @@ METADATA
|
|
212
211
|
|
213
212
|
context "with too many arguments" do
|
214
213
|
|
215
|
-
let(:argv) { %w
|
214
|
+
let(:argv) { %w{ one extra } }
|
216
215
|
|
217
216
|
it "fails" do
|
218
217
|
expect(generator_generator.run).to eq(1)
|
@@ -226,4 +225,3 @@ METADATA
|
|
226
225
|
end
|
227
226
|
|
228
227
|
end
|
229
|
-
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/a_file_generator"
|
20
|
+
require "chef-dk/command/generator_commands/lwrp"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::LWRP do
|
23
23
|
|
@@ -29,4 +29,3 @@ describe ChefDK::Command::GeneratorCommands::LWRP do
|
|
29
29
|
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/a_file_generator"
|
20
|
+
require "chef-dk/command/generator_commands/policyfile"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::Policyfile do
|
23
23
|
|
@@ -221,5 +221,3 @@ POLICYFILE_RB
|
|
221
221
|
end
|
222
222
|
|
223
223
|
end
|
224
|
-
|
225
|
-
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/a_file_generator"
|
20
|
+
require "chef-dk/command/generator_commands/recipe"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::Recipe do
|
23
23
|
|
@@ -27,7 +27,7 @@ describe ChefDK::Command::GeneratorCommands::Recipe do
|
|
27
27
|
let(:generated_files) { [ "recipes/new_recipe.rb",
|
28
28
|
"spec/spec_helper.rb",
|
29
29
|
"spec/unit/recipes/new_recipe_spec.rb",
|
30
|
-
"test/smoke/default/
|
30
|
+
"test/smoke/default/new_recipe_test.rb",
|
31
31
|
] }
|
32
32
|
let(:new_file_name) { "new_recipe" }
|
33
33
|
|
@@ -15,21 +15,21 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/a_generated_file"
|
20
|
+
require "chef-dk/command/generator_commands/repo"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::Repo do
|
23
23
|
|
24
|
-
let(:argv) { %w
|
24
|
+
let(:argv) { %w{new_repo} }
|
25
25
|
|
26
26
|
let(:stdout_io) { StringIO.new }
|
27
27
|
let(:stderr_io) { StringIO.new }
|
28
28
|
|
29
29
|
let(:expected_cookbook_file_relpaths) do
|
30
|
-
%w
|
30
|
+
%w{
|
31
31
|
LICENSE
|
32
|
-
|
32
|
+
}
|
33
33
|
end
|
34
34
|
|
35
35
|
let(:file) { "" }
|
@@ -62,7 +62,7 @@ describe ChefDK::Command::GeneratorCommands::Repo do
|
|
62
62
|
|
63
63
|
context "when conflicting --roles and --policy are given" do
|
64
64
|
|
65
|
-
let(:argv) { %w
|
65
|
+
let(:argv) { %w{ new-repo --roles --policy } }
|
66
66
|
|
67
67
|
it "emits an error saying that the options are exclusive" do
|
68
68
|
expected_message = "Roles and Policyfiles are exclusive. Please only select one."
|
@@ -248,7 +248,7 @@ describe ChefDK::Command::GeneratorCommands::Repo do
|
|
248
248
|
let(:file) { "cookbooks/example/attributes/default.rb" }
|
249
249
|
|
250
250
|
it "has the right contents" do
|
251
|
-
expect(file_contents).to match(/default\[
|
251
|
+
expect(file_contents).to match(/default\['example'\]\['name'\] = 'Sam Doe'/)
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
@@ -256,7 +256,7 @@ describe ChefDK::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, \#\{node\[
|
259
|
+
expect(file_contents).to match(/log "Welcome to Chef, \#\{node\['example'\]\['name'\]\}!" do/)
|
260
260
|
end
|
261
261
|
end
|
262
262
|
end
|
@@ -281,7 +281,7 @@ describe ChefDK::Command::GeneratorCommands::Repo do
|
|
281
281
|
|
282
282
|
context "when Policyfiles are enabled" do
|
283
283
|
|
284
|
-
let(:argv) { %w
|
284
|
+
let(:argv) { %w{ new_repo --policy } }
|
285
285
|
|
286
286
|
it "does not create a roles directory" do
|
287
287
|
expect(File).to_not exist(File.join(repo_path, "roles"))
|
@@ -313,7 +313,7 @@ README
|
|
313
313
|
|
314
314
|
context "when roles/environments are enabled" do
|
315
315
|
|
316
|
-
let(:argv) { %w
|
316
|
+
let(:argv) { %w{new_repo --roles} }
|
317
317
|
|
318
318
|
it "does not create a policies directory" do
|
319
319
|
expect(File).to_not exist(File.join(repo_path, "policies"))
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/a_file_generator"
|
20
|
+
require "chef-dk/command/generator_commands/template"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::Template do
|
23
23
|
|
@@ -29,4 +29,3 @@ describe ChefDK::Command::GeneratorCommands::Template do
|
|
29
29
|
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/command_with_ui_object"
|
20
|
+
require "chef-dk/command/install"
|
21
21
|
|
22
22
|
describe ChefDK::Command::Install do
|
23
23
|
|
@@ -52,7 +52,7 @@ describe ChefDK::Command::Install do
|
|
52
52
|
|
53
53
|
context "when an explicit config file path is given" do
|
54
54
|
|
55
|
-
let(:params) { %w
|
55
|
+
let(:params) { %w{ -c ~/.chef/alternate_config.rb } }
|
56
56
|
|
57
57
|
let(:chef_config_loader) { instance_double("Chef::WorkstationConfigLoader") }
|
58
58
|
|
@@ -144,7 +144,7 @@ describe ChefDK::Command::Install do
|
|
144
144
|
end
|
145
145
|
|
146
146
|
it "displays the exception and cause" do
|
147
|
-
expected_error_text
|
147
|
+
expected_error_text = <<-E
|
148
148
|
Error: install failed
|
149
149
|
Reason: (StandardError) some operation failed
|
150
150
|
|
@@ -159,7 +159,7 @@ E
|
|
159
159
|
let(:params) { ["-D"] }
|
160
160
|
|
161
161
|
it "displays the exception and cause with backtrace" do
|
162
|
-
expected_error_text
|
162
|
+
expected_error_text = <<-E
|
163
163
|
Error: install failed
|
164
164
|
Reason: (StandardError) some operation failed
|
165
165
|
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/command_with_ui_object"
|
20
|
+
require "chef-dk/command/provision"
|
21
21
|
|
22
22
|
describe ChefDK::Command::Provision do
|
23
23
|
|
@@ -65,7 +65,7 @@ describe ChefDK::Command::Provision do
|
|
65
65
|
|
66
66
|
context "when --no-policy is combined with policy arguments" do
|
67
67
|
|
68
|
-
let(:params) { %w
|
68
|
+
let(:params) { %w{ --no-policy some-policy-group } }
|
69
69
|
|
70
70
|
it "prints usage and exits non-zero" do
|
71
71
|
expect(command.run(params)).to eq(1)
|
@@ -76,7 +76,7 @@ describe ChefDK::Command::Provision do
|
|
76
76
|
|
77
77
|
context "when a POLICY_GROUP is given but neither of --sync or --policy-name are given" do
|
78
78
|
|
79
|
-
let(:params) { %w
|
79
|
+
let(:params) { %w{ some-policy-group } }
|
80
80
|
|
81
81
|
it "prints usage and exits non-zero" do
|
82
82
|
expect(command.run(params)).to eq(1)
|
@@ -87,7 +87,7 @@ describe ChefDK::Command::Provision do
|
|
87
87
|
|
88
88
|
context "when both --sync and --policy-name are given" do
|
89
89
|
|
90
|
-
let(:params) { %w
|
90
|
+
let(:params) { %w{ some-policy-group --policy-name foo --sync} }
|
91
91
|
|
92
92
|
it "prints usage and exits non-zero" do
|
93
93
|
expect(command.run(params)).to eq(1)
|
@@ -98,7 +98,7 @@ describe ChefDK::Command::Provision do
|
|
98
98
|
|
99
99
|
context "when too many arguments are given" do
|
100
100
|
|
101
|
-
let(:params) { %w
|
101
|
+
let(:params) { %w{ policygroup extraneous-argument --sync } }
|
102
102
|
|
103
103
|
it "prints usage and exits non-zero" do
|
104
104
|
expect(command.run(params)).to eq(1)
|
@@ -112,7 +112,7 @@ describe ChefDK::Command::Provision do
|
|
112
112
|
|
113
113
|
let(:context) { ChefDK::ProvisioningData.context }
|
114
114
|
|
115
|
-
shared_examples
|
115
|
+
shared_examples "common_optional_options" do
|
116
116
|
|
117
117
|
context "with default option values" do
|
118
118
|
|
@@ -127,7 +127,7 @@ describe ChefDK::Command::Provision do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
it "sets the cookbook name to 'provision'" do
|
130
|
-
expect(command.provisioning_cookbook_name).to eq(
|
130
|
+
expect(command.provisioning_cookbook_name).to eq("provision")
|
131
131
|
end
|
132
132
|
|
133
133
|
it "sets the recipe to 'default'" do
|
@@ -144,7 +144,7 @@ describe ChefDK::Command::Provision do
|
|
144
144
|
|
145
145
|
context "with -n NODE_NAME" do
|
146
146
|
|
147
|
-
let(:extra_params) { %w
|
147
|
+
let(:extra_params) { %w{ -n example-node } }
|
148
148
|
|
149
149
|
it "sets the default requested node name" do
|
150
150
|
expect(command.node_name).to eq("example-node")
|
@@ -155,7 +155,7 @@ describe ChefDK::Command::Provision do
|
|
155
155
|
|
156
156
|
context "with --cookbook COOKBOOK_PATH" do
|
157
157
|
|
158
|
-
let(:extra_params) { %w
|
158
|
+
let(:extra_params) { %w{ --cookbook ~/mystuff/my-provision-cookbook } }
|
159
159
|
|
160
160
|
let(:expected_cookbook_path) { File.expand_path("~/mystuff") }
|
161
161
|
let(:expected_cookbook_name) { "my-provision-cookbook" }
|
@@ -186,7 +186,7 @@ describe ChefDK::Command::Provision do
|
|
186
186
|
|
187
187
|
context "with -r MACHINE_RECIPE" do
|
188
188
|
|
189
|
-
let(:extra_params) { %w
|
189
|
+
let(:extra_params) { %w{ -r ec2cluster } }
|
190
190
|
|
191
191
|
it "sets the recipe to run as specified" do
|
192
192
|
expect(command.recipe).to eq("ec2cluster")
|
@@ -197,7 +197,7 @@ describe ChefDK::Command::Provision do
|
|
197
197
|
|
198
198
|
context "with --target" do
|
199
199
|
|
200
|
-
let(:extra_params) { %w
|
200
|
+
let(:extra_params) { %w{ -t 192.168.255.123 } }
|
201
201
|
|
202
202
|
it "sets the target host to the given value" do
|
203
203
|
expect(context.target).to eq("192.168.255.123")
|
@@ -207,7 +207,7 @@ describe ChefDK::Command::Provision do
|
|
207
207
|
|
208
208
|
context "with --opt" do
|
209
209
|
context "with one user-specified option" do
|
210
|
-
let(:extra_params) { %w
|
210
|
+
let(:extra_params) { %w{ --opt color=ebfg } }
|
211
211
|
|
212
212
|
it "sets the given option name to the given value" do
|
213
213
|
expect(context.opts.color).to eq("ebfg")
|
@@ -216,7 +216,7 @@ describe ChefDK::Command::Provision do
|
|
216
216
|
|
217
217
|
context "with an option given as a quoted arg with spaces" do
|
218
218
|
|
219
|
-
let(:extra_params) { [
|
219
|
+
let(:extra_params) { [ "--opt", "color = ebfg" ] }
|
220
220
|
|
221
221
|
it "sets the given option name to the given value" do
|
222
222
|
expect(context.opts.color).to eq("ebfg")
|
@@ -225,7 +225,7 @@ describe ChefDK::Command::Provision do
|
|
225
225
|
|
226
226
|
context "with an option with an '=' in it" do
|
227
227
|
|
228
|
-
let(:extra_params) { [
|
228
|
+
let(:extra_params) { [ "--opt", "api_key=abcdef==" ] }
|
229
229
|
|
230
230
|
it "sets the given option name to the given value" do
|
231
231
|
expect(context.opts.api_key).to eq("abcdef==")
|
@@ -234,7 +234,7 @@ describe ChefDK::Command::Provision do
|
|
234
234
|
|
235
235
|
context "with an option with a space in it" do
|
236
236
|
|
237
|
-
let(:extra_params) { [
|
237
|
+
let(:extra_params) { [ "--opt", "full_name=Bobo T. Clown" ] }
|
238
238
|
|
239
239
|
it "sets the given option name to the given value" do
|
240
240
|
expect(context.opts.full_name).to eq("Bobo T. Clown")
|
@@ -242,7 +242,7 @@ describe ChefDK::Command::Provision do
|
|
242
242
|
end
|
243
243
|
|
244
244
|
context "with multiple options given" do
|
245
|
-
let(:extra_params) { %w
|
245
|
+
let(:extra_params) { %w{ --opt color=ebfg --opt nope=seppb } }
|
246
246
|
|
247
247
|
it "sets the given option name to the given value" do
|
248
248
|
expect(context.opts.color).to eq("ebfg")
|
@@ -253,7 +253,7 @@ describe ChefDK::Command::Provision do
|
|
253
253
|
|
254
254
|
context "with -d" do
|
255
255
|
|
256
|
-
let(:extra_params) { %w
|
256
|
+
let(:extra_params) { %w{ -d } }
|
257
257
|
|
258
258
|
it "sets the default action to destroy" do
|
259
259
|
expect(command.default_action).to eq(:destroy)
|
@@ -277,7 +277,7 @@ describe ChefDK::Command::Provision do
|
|
277
277
|
end
|
278
278
|
|
279
279
|
let(:extra_params) { [] }
|
280
|
-
let(:params) { %w
|
280
|
+
let(:params) { %w{ --no-policy } + extra_params }
|
281
281
|
|
282
282
|
it "disables policyfile integration" do
|
283
283
|
expect(command.enable_policyfile?).to be(false)
|
@@ -319,7 +319,7 @@ CONFIG
|
|
319
319
|
|
320
320
|
let(:given_policy_group) { "some-policy-group" }
|
321
321
|
|
322
|
-
let(:params) { [ given_policy_group,
|
322
|
+
let(:params) { [ given_policy_group, "--sync", given_policyfile_path ] }
|
323
323
|
|
324
324
|
it "sets policy group" do
|
325
325
|
expect(command.policy_group).to eq(given_policy_group)
|
@@ -341,7 +341,7 @@ CONFIG
|
|
341
341
|
|
342
342
|
let(:extra_params) { [] }
|
343
343
|
|
344
|
-
let(:params) { [ given_policy_group,
|
344
|
+
let(:params) { [ given_policy_group, "--sync" ] + extra_params }
|
345
345
|
|
346
346
|
before do
|
347
347
|
allow(chef_config).to receive(:ssl_verify_mode).and_return(:verify_peer)
|
@@ -373,7 +373,6 @@ CONFIG
|
|
373
373
|
expect(context.chef_config).to eq(expected_config)
|
374
374
|
end
|
375
375
|
|
376
|
-
|
377
376
|
include_examples "common_optional_options"
|
378
377
|
|
379
378
|
end
|
@@ -386,8 +385,7 @@ CONFIG
|
|
386
385
|
|
387
386
|
let(:extra_params) { [] }
|
388
387
|
|
389
|
-
let(:params) { [ given_policy_group,
|
390
|
-
|
388
|
+
let(:params) { [ given_policy_group, "--policy-name", "myapp" ] + extra_params }
|
391
389
|
|
392
390
|
before do
|
393
391
|
command.apply_params!(params)
|
@@ -444,7 +442,7 @@ CONFIG
|
|
444
442
|
|
445
443
|
let(:chef_runner) { instance_double("ChefDK::ChefRunner") }
|
446
444
|
|
447
|
-
let(:params) { %w
|
445
|
+
let(:params) { %w{ policygroup --sync } }
|
448
446
|
|
449
447
|
context "when the provision cookbook doesn't exist" do
|
450
448
|
|
@@ -495,7 +493,7 @@ CONFIG
|
|
495
493
|
end
|
496
494
|
|
497
495
|
it "prints an error and exits non-zero" do
|
498
|
-
|
496
|
+
expected_output = <<-E
|
499
497
|
Error: push failed
|
500
498
|
Reason: (StandardError) some operation failed
|
501
499
|
|
@@ -547,7 +545,7 @@ E
|
|
547
545
|
|
548
546
|
context "when using --no-policy" do
|
549
547
|
|
550
|
-
let(:params) { %w
|
548
|
+
let(:params) { %w{ --no-policy } }
|
551
549
|
|
552
550
|
it "exits 0" do
|
553
551
|
return_value = command.run(params)
|
@@ -559,7 +557,7 @@ E
|
|
559
557
|
|
560
558
|
context "with --policy-name" do
|
561
559
|
|
562
|
-
let(:params) { %w
|
560
|
+
let(:params) { %w{ policygroup --policy-name otherapp } }
|
563
561
|
|
564
562
|
it "exits 0" do
|
565
563
|
return_value = command.run(params)
|
@@ -589,4 +587,3 @@ E
|
|
589
587
|
|
590
588
|
end
|
591
589
|
end
|
592
|
-
|