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,19 +15,19 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/custom_generator_cookbook"
|
20
|
+
require "chef-dk/command/generator_commands/app"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::App do
|
23
23
|
|
24
|
-
let(:argv) { %w
|
24
|
+
let(:argv) { %w{new_app} }
|
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
|
.gitignore
|
32
32
|
.kitchen.yml
|
33
33
|
test
|
@@ -45,7 +45,7 @@ describe ChefDK::Command::GeneratorCommands::App do
|
|
45
45
|
cookbooks/new_app/spec/unit
|
46
46
|
cookbooks/new_app/spec/unit/recipes
|
47
47
|
cookbooks/new_app/spec/unit/recipes/default_spec.rb
|
48
|
-
|
48
|
+
}
|
49
49
|
end
|
50
50
|
|
51
51
|
let(:expected_cookbook_files) do
|
@@ -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/attribute"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::Attribute do
|
23
23
|
|
@@ -29,4 +29,3 @@ describe ChefDK::Command::GeneratorCommands::Attribute do
|
|
29
29
|
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
@@ -15,12 +15,12 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "pry"
|
19
|
+
require "spec_helper"
|
20
|
+
require "chef-dk/command/generator_commands/base"
|
21
21
|
|
22
22
|
describe ChefDK::Command::GeneratorCommands::Base do
|
23
|
-
describe
|
23
|
+
describe "parsing Chef configuration" do
|
24
24
|
let(:cli_args) do
|
25
25
|
[
|
26
26
|
"-C", "Business Man",
|
@@ -33,7 +33,7 @@ describe ChefDK::Command::GeneratorCommands::Base do
|
|
33
33
|
Chef::Config.reset
|
34
34
|
end
|
35
35
|
|
36
|
-
context
|
36
|
+
context "when generator configuration is defined" do
|
37
37
|
before do
|
38
38
|
Chef::Config.reset
|
39
39
|
Chef::Config.chefdk.generator.copyright_holder = "This Guy"
|
@@ -41,17 +41,17 @@ describe ChefDK::Command::GeneratorCommands::Base do
|
|
41
41
|
Chef::Config.chefdk.generator.license = "Two Thumbs License"
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it "uses the defined values" do
|
45
45
|
cmd = ChefDK::Command::GeneratorCommands::Base.new([])
|
46
46
|
cmd.parse_options
|
47
47
|
cmd.setup_context
|
48
48
|
cfg = cmd.config
|
49
|
-
expect(cfg[:copyright_holder]).to eq(
|
50
|
-
expect(cfg[:email]).to eq(
|
51
|
-
expect(cfg[:license]).to eq(
|
49
|
+
expect(cfg[:copyright_holder]).to eq("This Guy")
|
50
|
+
expect(cfg[:email]).to eq("this.guy@twothumbs.net")
|
51
|
+
expect(cfg[:license]).to eq("Two Thumbs License")
|
52
52
|
end
|
53
53
|
|
54
|
-
context
|
54
|
+
context "when cli overrides are provided" do
|
55
55
|
before do
|
56
56
|
Chef::Config.reset
|
57
57
|
Chef::Config.chefdk.generator.copyright_holder = "This Guy"
|
@@ -59,18 +59,18 @@ describe ChefDK::Command::GeneratorCommands::Base do
|
|
59
59
|
Chef::Config.chefdk.generator.license = "Two Thumbs License"
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
62
|
+
it "uses the cli args" do
|
63
63
|
cmd = ChefDK::Command::GeneratorCommands::Base.new(cli_args)
|
64
64
|
cmd.parse_options(cli_args)
|
65
65
|
cmd.setup_context
|
66
66
|
cfg = cmd.config
|
67
|
-
expect(cfg[:copyright_holder]).to eq(
|
68
|
-
expect(cfg[:email]).to eq(
|
69
|
-
expect(cfg[:license]).to eq(
|
67
|
+
expect(cfg[:copyright_holder]).to eq("Business Man")
|
68
|
+
expect(cfg[:email]).to eq("business.man@corporation.com")
|
69
|
+
expect(cfg[:license]).to eq("Serious Business")
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
context
|
73
|
+
context "when knife configuration is also defined" do
|
74
74
|
|
75
75
|
before do
|
76
76
|
Chef::Config.reset
|
@@ -82,19 +82,19 @@ describe ChefDK::Command::GeneratorCommands::Base do
|
|
82
82
|
Chef::Config.knife.cookbook_license = "GPLv9000"
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it "uses the generator configuration" do
|
86
86
|
cmd = ChefDK::Command::GeneratorCommands::Base.new([])
|
87
87
|
cmd.parse_options
|
88
88
|
cmd.setup_context
|
89
89
|
cfg = cmd.config
|
90
|
-
expect(cfg[:copyright_holder]).to eq(
|
91
|
-
expect(cfg[:email]).to eq(
|
92
|
-
expect(cfg[:license]).to eq(
|
90
|
+
expect(cfg[:copyright_holder]).to eq("This Guy")
|
91
|
+
expect(cfg[:email]).to eq("this.guy@twothumbs.net")
|
92
|
+
expect(cfg[:license]).to eq("Two Thumbs License")
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
context
|
97
|
+
context "when knife configuration is defined" do
|
98
98
|
before do
|
99
99
|
Chef::Config.reset
|
100
100
|
Chef::Config.knife.cookbook_copyright = "Knife User"
|
@@ -102,17 +102,17 @@ describe ChefDK::Command::GeneratorCommands::Base do
|
|
102
102
|
Chef::Config.knife.cookbook_license = "GPLv9000"
|
103
103
|
end
|
104
104
|
|
105
|
-
it
|
105
|
+
it "uses the defined values" do
|
106
106
|
cmd = ChefDK::Command::GeneratorCommands::Base.new([])
|
107
107
|
cmd.parse_options
|
108
108
|
cmd.setup_context
|
109
109
|
cfg = cmd.config
|
110
|
-
expect(cfg[:copyright_holder]).to eq(
|
111
|
-
expect(cfg[:email]).to eq(
|
112
|
-
expect(cfg[:license]).to eq(
|
110
|
+
expect(cfg[:copyright_holder]).to eq("Knife User")
|
111
|
+
expect(cfg[:email]).to eq("knife.user@example.com")
|
112
|
+
expect(cfg[:license]).to eq("GPLv9000")
|
113
113
|
end
|
114
114
|
|
115
|
-
context
|
115
|
+
context "when cli overrides are provided" do
|
116
116
|
|
117
117
|
before do
|
118
118
|
Chef::Config.reset
|
@@ -121,14 +121,14 @@ describe ChefDK::Command::GeneratorCommands::Base do
|
|
121
121
|
Chef::Config.knife.cookbook_license = "GPLv9000"
|
122
122
|
end
|
123
123
|
|
124
|
-
it
|
124
|
+
it "uses the cli args" do
|
125
125
|
cmd = ChefDK::Command::GeneratorCommands::Base.new(cli_args)
|
126
126
|
cmd.parse_options(cli_args)
|
127
127
|
cmd.setup_context
|
128
128
|
cfg = cmd.config
|
129
|
-
expect(cfg[:copyright_holder]).to eq(
|
130
|
-
expect(cfg[:email]).to eq(
|
131
|
-
expect(cfg[:license]).to eq(
|
129
|
+
expect(cfg[:copyright_holder]).to eq("Business Man")
|
130
|
+
expect(cfg[:email]).to eq("business.man@corporation.com")
|
131
|
+
expect(cfg[:license]).to eq("Serious Business")
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
@@ -136,44 +136,44 @@ describe ChefDK::Command::GeneratorCommands::Base do
|
|
136
136
|
|
137
137
|
describe '#have_git?' do
|
138
138
|
let(:cmd) { described_class.new([]) }
|
139
|
-
let(:path) {
|
139
|
+
let(:path) { "bin_path" }
|
140
140
|
|
141
141
|
before do
|
142
142
|
allow(File).to receive(:exist?)
|
143
|
-
allow(ENV).to receive(:[]).with(
|
144
|
-
allow(ENV).to receive(:[]).with(
|
145
|
-
allow(RbConfig::CONFIG).to receive(:[]).with(
|
143
|
+
allow(ENV).to receive(:[]).with("PATH").and_return(path)
|
144
|
+
allow(ENV).to receive(:[]).with("PATHEXT").and_return(nil)
|
145
|
+
allow(RbConfig::CONFIG).to receive(:[]).with("EXEEXT").and_return("")
|
146
146
|
end
|
147
147
|
|
148
|
-
describe
|
149
|
-
it
|
148
|
+
describe "when git executable exists" do
|
149
|
+
it "returns true" do
|
150
150
|
allow(File).to receive(:exist?).and_return(true)
|
151
151
|
expect(cmd.have_git?).to eq(true)
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
describe
|
156
|
-
it
|
155
|
+
describe "when git executable does not exist" do
|
156
|
+
it "returns false" do
|
157
157
|
allow(File).to receive(:exist?).and_return(false)
|
158
158
|
expect(cmd.have_git?).to eq(false)
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
-
it
|
163
|
-
expect(File).to receive(:exist?).with(File.join(path,
|
162
|
+
it "checks PATH for git executable" do
|
163
|
+
expect(File).to receive(:exist?).with(File.join(path, "git"))
|
164
164
|
cmd.have_git?
|
165
165
|
end
|
166
166
|
|
167
|
-
describe
|
167
|
+
describe "when on Windows" do
|
168
168
|
before do
|
169
|
-
allow(ENV).to receive(:[]).with(
|
170
|
-
allow(RbConfig::CONFIG).to receive(:[]).with(
|
169
|
+
allow(ENV).to receive(:[]).with("PATHEXT").and_return(".com;.exe;.bat")
|
170
|
+
allow(RbConfig::CONFIG).to receive(:[]).with("EXEEXT").and_return(".exe")
|
171
171
|
end
|
172
172
|
|
173
|
-
it
|
174
|
-
expect(File).to receive(:exist?).with(File.join(path,
|
175
|
-
expect(File).to receive(:exist?).with(File.join(path,
|
176
|
-
expect(File).to receive(:exist?).with(File.join(path,
|
173
|
+
it "checks PATH for git executable with an extension found in PATHEXT" do
|
174
|
+
expect(File).to receive(:exist?).with(File.join(path, "git.com"))
|
175
|
+
expect(File).to receive(:exist?).with(File.join(path, "git.exe"))
|
176
|
+
expect(File).to receive(:exist?).with(File.join(path, "git.bat"))
|
177
177
|
cmd.have_git?
|
178
178
|
end
|
179
179
|
end
|
@@ -15,23 +15,23 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
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/build_cookbook"
|
22
|
+
require "mixlib/shellout"
|
23
23
|
|
24
24
|
describe ChefDK::Command::GeneratorCommands::BuildCookbook do
|
25
25
|
|
26
26
|
include_context("setup_git_committer_config")
|
27
27
|
|
28
|
-
let(:argv) { %w
|
28
|
+
let(:argv) { %w{delivery_project} }
|
29
29
|
|
30
30
|
let(:stdout_io) { StringIO.new }
|
31
31
|
let(:stderr_io) { StringIO.new }
|
32
32
|
|
33
33
|
let(:expected_cookbook_file_relpaths) do
|
34
|
-
%w
|
34
|
+
%w{
|
35
35
|
.kitchen.yml
|
36
36
|
data_bags
|
37
37
|
data_bags/keys
|
@@ -62,7 +62,7 @@ describe ChefDK::Command::GeneratorCommands::BuildCookbook do
|
|
62
62
|
recipes/unit.rb
|
63
63
|
secrets
|
64
64
|
secrets/fakey-mcfakerton
|
65
|
-
|
65
|
+
}
|
66
66
|
end
|
67
67
|
|
68
68
|
let(:expected_cookbook_files) do
|
@@ -85,7 +85,7 @@ describe ChefDK::Command::GeneratorCommands::BuildCookbook do
|
|
85
85
|
|
86
86
|
it "configures the chef runner" do
|
87
87
|
expect(cookbook_generator.chef_runner).to be_a(ChefDK::ChefRunner)
|
88
|
-
expect(cookbook_generator.chef_runner.cookbook_path).to eq(File.expand_path(
|
88
|
+
expect(cookbook_generator.chef_runner.cookbook_path).to eq(File.expand_path("lib/chef-dk/skeletons", project_root))
|
89
89
|
end
|
90
90
|
|
91
91
|
context "when given invalid/incomplete arguments" do
|
@@ -94,7 +94,6 @@ describe ChefDK::Command::GeneratorCommands::BuildCookbook do
|
|
94
94
|
"Usage: chef generate build-cookbook NAME [options]\n"
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
97
|
def with_argv(argv)
|
99
98
|
generator = described_class.new(argv)
|
100
99
|
allow(generator).to receive(:stdout).and_return(stdout_io)
|
@@ -111,7 +110,7 @@ describe ChefDK::Command::GeneratorCommands::BuildCookbook do
|
|
111
110
|
|
112
111
|
context "when given the name of the delivery project" do
|
113
112
|
|
114
|
-
let(:argv) { %w
|
113
|
+
let(:argv) { %w{delivery_project} }
|
115
114
|
|
116
115
|
let(:project_dir) { File.join(tempdir, "delivery_project") }
|
117
116
|
|
@@ -199,6 +198,7 @@ maintainer 'The Authors'
|
|
199
198
|
maintainer_email 'you@example.com'
|
200
199
|
license 'all_rights'
|
201
200
|
version '0.1.0'
|
201
|
+
chef_version '>= 12.1' if respond_to?(:chef_version)
|
202
202
|
|
203
203
|
depends 'delivery-truck'
|
204
204
|
METADATA
|
@@ -216,7 +216,7 @@ METADATA
|
|
216
216
|
end
|
217
217
|
|
218
218
|
it "generates phase recipes which include the corresponding delivery truck recipe" do
|
219
|
-
%w
|
219
|
+
%w{
|
220
220
|
deploy.rb
|
221
221
|
functional.rb
|
222
222
|
lint.rb
|
@@ -227,10 +227,10 @@ METADATA
|
|
227
227
|
smoke.rb
|
228
228
|
syntax.rb
|
229
229
|
unit.rb
|
230
|
-
|
230
|
+
}.each do |phase_recipe|
|
231
231
|
recipe_file = File.join(tempdir, "delivery_project", ".delivery", "build_cookbook", "recipes", phase_recipe)
|
232
232
|
phase = File.basename(phase_recipe, ".rb")
|
233
|
-
expected_content = %Q
|
233
|
+
expected_content = %Q{include_recipe 'delivery-truck::#{phase}'}
|
234
234
|
expect(IO.read(recipe_file)).to include(expected_content)
|
235
235
|
end
|
236
236
|
end
|
@@ -273,7 +273,7 @@ METADATA
|
|
273
273
|
end
|
274
274
|
|
275
275
|
it "generates phase recipes that are empty" do
|
276
|
-
%w
|
276
|
+
%w{
|
277
277
|
deploy.rb
|
278
278
|
functional.rb
|
279
279
|
lint.rb
|
@@ -284,7 +284,7 @@ METADATA
|
|
284
284
|
smoke.rb
|
285
285
|
syntax.rb
|
286
286
|
unit.rb
|
287
|
-
|
287
|
+
}.each do |phase_recipe|
|
288
288
|
recipe_file = File.join(tempdir, "delivery_project", ".delivery", "build_cookbook", "recipes", phase_recipe)
|
289
289
|
expect(IO.read(recipe_file)).to_not include("include_recipe")
|
290
290
|
end
|
@@ -323,6 +323,40 @@ METADATA
|
|
323
323
|
end
|
324
324
|
|
325
325
|
end
|
326
|
+
|
327
|
+
context "when the delivery project has already a config.json and project.toml" do
|
328
|
+
|
329
|
+
let(:dot_delivery) { File.join(project_dir, ".delivery") }
|
330
|
+
let(:config_json) { File.join(dot_delivery, "config.json") }
|
331
|
+
let(:project_toml) { File.join(dot_delivery, "project.toml") }
|
332
|
+
|
333
|
+
def git!(cmd)
|
334
|
+
Mixlib::ShellOut.new("git #{cmd}", cwd: project_dir).tap do |c|
|
335
|
+
c.run_command
|
336
|
+
c.error!
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
before do
|
341
|
+
FileUtils.mkdir_p(dot_delivery)
|
342
|
+
FileUtils.touch(config_json)
|
343
|
+
FileUtils.touch(project_toml)
|
344
|
+
|
345
|
+
git!("init .")
|
346
|
+
git!("add .")
|
347
|
+
git!("commit -m \"initial commit\"")
|
348
|
+
|
349
|
+
Dir.chdir(tempdir) do
|
350
|
+
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
351
|
+
expect(cookbook_generator.run).to eq(0)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
it "does not overwrite the delivery config" do
|
356
|
+
expect(git!("log").stdout).to_not include("Add generated delivery configuration")
|
357
|
+
end
|
358
|
+
|
359
|
+
end
|
326
360
|
end
|
327
361
|
|
328
362
|
context "when given a path including the .delivery directory" do
|
@@ -15,18 +15,18 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "stringio"
|
20
20
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
21
|
+
require "chef/run_context"
|
22
|
+
require "chef/cookbook/cookbook_collection"
|
23
|
+
require "chef/node"
|
24
|
+
require "chef/event_dispatch/dispatcher"
|
25
|
+
require "chef/formatters/base"
|
26
26
|
|
27
|
-
require
|
27
|
+
require "ohai/system"
|
28
28
|
|
29
|
-
require
|
29
|
+
require "chef-dk/command/generator_commands/chef_exts/generator_desc_resource"
|
30
30
|
|
31
31
|
describe ChefDK::ChefResource::GeneratorDesc do
|
32
32
|
|
@@ -15,24 +15,24 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "stringio"
|
20
20
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
21
|
+
require "chef/config"
|
22
|
+
require "chef/recipe"
|
23
|
+
require "chef/run_context"
|
24
|
+
require "chef/event_dispatch/dispatcher"
|
25
|
+
require "chef/policy_builder"
|
26
|
+
require "chef/formatters/doc"
|
27
|
+
require "chef/cookbook/file_vendor"
|
28
|
+
require "chef/cookbook/file_system_file_vendor"
|
29
|
+
require "chef/cookbook/cookbook_collection"
|
30
|
+
require "chef/cookbook_loader"
|
31
31
|
|
32
|
-
require
|
32
|
+
require "ohai/system"
|
33
33
|
|
34
|
-
require
|
35
|
-
require
|
34
|
+
require "chef-dk/command/generator_commands/chef_exts/recipe_dsl_ext"
|
35
|
+
require "chef-dk/command/generator_commands/chef_exts/quieter_doc_formatter"
|
36
36
|
|
37
37
|
describe ChefDK::RecipeDSLExt do
|
38
38
|
|
@@ -56,7 +56,7 @@ describe ChefDK::RecipeDSLExt do
|
|
56
56
|
|
57
57
|
let(:ohai) do
|
58
58
|
Ohai::System.new.tap do |o|
|
59
|
-
o.all_plugins(
|
59
|
+
o.all_plugins(%w{platform platform_version})
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|