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
@@ -4,14 +4,30 @@ cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
|
4
4
|
|
5
5
|
silence_chef_formatter unless context.verbose
|
6
6
|
|
7
|
-
generator_desc(
|
7
|
+
generator_desc('Ensuring correct cookbook file content')
|
8
8
|
|
9
9
|
# cookbook root dir
|
10
10
|
directory cookbook_dir
|
11
11
|
|
12
12
|
# metadata.rb
|
13
|
+
spdx_license = case context.license
|
14
|
+
when 'apachev2'
|
15
|
+
'Apache-2.0'
|
16
|
+
when 'mit'
|
17
|
+
'MIT'
|
18
|
+
when 'gplv2'
|
19
|
+
'GPL-2.0'
|
20
|
+
when 'gplv3'
|
21
|
+
'GPL-3.0'
|
22
|
+
else
|
23
|
+
'All Rights Reserved'
|
24
|
+
end
|
25
|
+
|
13
26
|
template "#{cookbook_dir}/metadata.rb" do
|
14
27
|
helpers(ChefDK::Generator::TemplateHelper)
|
28
|
+
variables(
|
29
|
+
spdx_license: spdx_license
|
30
|
+
)
|
15
31
|
action :create_if_missing
|
16
32
|
end
|
17
33
|
|
@@ -34,16 +50,14 @@ else
|
|
34
50
|
|
35
51
|
# Policyfile
|
36
52
|
template "#{cookbook_dir}/Policyfile.rb" do
|
37
|
-
source
|
53
|
+
source 'Policyfile.rb.erb'
|
38
54
|
helpers(ChefDK::Generator::TemplateHelper)
|
39
55
|
end
|
40
56
|
|
41
57
|
end
|
42
58
|
|
43
|
-
|
44
59
|
# Test Kitchen
|
45
60
|
template "#{cookbook_dir}/.kitchen.yml" do
|
46
|
-
|
47
61
|
if context.use_berkshelf
|
48
62
|
source 'kitchen.yml.erb'
|
49
63
|
else
|
@@ -71,18 +85,17 @@ directory "#{cookbook_dir}/spec/unit/recipes" do
|
|
71
85
|
end
|
72
86
|
|
73
87
|
cookbook_file "#{cookbook_dir}/spec/spec_helper.rb" do
|
74
|
-
|
75
88
|
if context.use_berkshelf
|
76
|
-
source
|
89
|
+
source 'spec_helper.rb'
|
77
90
|
else
|
78
|
-
source
|
91
|
+
source 'spec_helper_policyfile.rb'
|
79
92
|
end
|
80
93
|
|
81
94
|
action :create_if_missing
|
82
95
|
end
|
83
96
|
|
84
97
|
template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
|
85
|
-
source
|
98
|
+
source 'recipe_spec.rb.erb'
|
86
99
|
helpers(ChefDK::Generator::TemplateHelper)
|
87
100
|
action :create_if_missing
|
88
101
|
end
|
@@ -92,7 +105,7 @@ end
|
|
92
105
|
directory "#{cookbook_dir}/recipes"
|
93
106
|
|
94
107
|
template "#{cookbook_dir}/recipes/default.rb" do
|
95
|
-
source
|
108
|
+
source 'recipe.rb.erb'
|
96
109
|
helpers(ChefDK::Generator::TemplateHelper)
|
97
110
|
action :create_if_missing
|
98
111
|
end
|
@@ -101,35 +114,31 @@ end
|
|
101
114
|
if context.have_git
|
102
115
|
unless context.skip_git_init
|
103
116
|
|
104
|
-
generator_desc(
|
117
|
+
generator_desc('Committing cookbook files to git')
|
105
118
|
|
106
|
-
execute(
|
107
|
-
command(
|
119
|
+
execute('initialize-git') do
|
120
|
+
command('git init .')
|
108
121
|
cwd cookbook_dir
|
109
122
|
end
|
110
123
|
|
111
124
|
end
|
112
125
|
|
113
126
|
cookbook_file "#{cookbook_dir}/.gitignore" do
|
114
|
-
source
|
127
|
+
source 'gitignore'
|
115
128
|
end
|
116
129
|
|
117
130
|
unless context.skip_git_init
|
118
131
|
|
119
|
-
execute(
|
120
|
-
command(
|
132
|
+
execute('git-add-new-files') do
|
133
|
+
command('git add .')
|
121
134
|
cwd cookbook_dir
|
122
135
|
end
|
123
136
|
|
124
|
-
execute(
|
125
|
-
command(
|
137
|
+
execute('git-commit-new-files') do
|
138
|
+
command('git commit -m "Add generated cookbook content"')
|
126
139
|
cwd cookbook_dir
|
127
140
|
end
|
128
141
|
end
|
129
142
|
end
|
130
143
|
|
131
|
-
if context.enable_delivery
|
132
|
-
|
133
|
-
include_recipe "::build_cookbook"
|
134
|
-
|
135
|
-
end
|
144
|
+
include_recipe '::build_cookbook' if context.enable_delivery
|
@@ -1,23 +1,23 @@
|
|
1
1
|
|
2
2
|
context = ChefDK::Generator.context
|
3
3
|
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
-
files_dir = File.join(cookbook_dir,
|
5
|
-
cookbook_file_path = File.join(cookbook_dir,
|
4
|
+
files_dir = File.join(cookbook_dir, 'files', 'default')
|
5
|
+
cookbook_file_path = File.join(cookbook_dir, 'files', 'default', context.new_file_basename)
|
6
6
|
|
7
7
|
directory files_dir do
|
8
8
|
recursive true
|
9
9
|
end
|
10
10
|
|
11
|
-
if
|
11
|
+
if context.content_source
|
12
12
|
|
13
13
|
file cookbook_file_path do
|
14
|
-
content(IO.read(
|
14
|
+
content(IO.read(context.context_source))
|
15
15
|
end
|
16
16
|
|
17
17
|
else
|
18
18
|
|
19
19
|
template cookbook_file_path do
|
20
|
-
source
|
20
|
+
source 'cookbook_file.erb'
|
21
21
|
helpers(ChefDK::Generator::TemplateHelper)
|
22
22
|
end
|
23
23
|
|
@@ -2,22 +2,22 @@
|
|
2
2
|
context = ChefDK::Generator.context
|
3
3
|
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
4
|
|
5
|
-
resource_dir = File.join(cookbook_dir,
|
5
|
+
resource_dir = File.join(cookbook_dir, 'resources')
|
6
6
|
resource_path = File.join(resource_dir, "#{context.new_file_basename}.rb")
|
7
7
|
|
8
|
-
provider_dir = File.join(cookbook_dir,
|
8
|
+
provider_dir = File.join(cookbook_dir, 'providers')
|
9
9
|
provider_path = File.join(provider_dir, "#{context.new_file_basename}.rb")
|
10
10
|
|
11
11
|
directory resource_dir
|
12
12
|
|
13
13
|
template resource_path do
|
14
|
-
source
|
14
|
+
source 'resource.rb.erb'
|
15
15
|
helpers(ChefDK::Generator::TemplateHelper)
|
16
16
|
end
|
17
17
|
|
18
18
|
directory provider_dir
|
19
19
|
|
20
20
|
template provider_path do
|
21
|
-
source
|
21
|
+
source 'provider.rb.erb'
|
22
22
|
helpers(ChefDK::Generator::TemplateHelper)
|
23
23
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
|
2
2
|
context = ChefDK::Generator.context
|
3
3
|
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
-
recipe_path = File.join(cookbook_dir,
|
5
|
-
spec_helper_path = File.join(cookbook_dir,
|
6
|
-
spec_dir = File.join(cookbook_dir,
|
4
|
+
recipe_path = File.join(cookbook_dir, 'recipes', "#{context.new_file_basename}.rb")
|
5
|
+
spec_helper_path = File.join(cookbook_dir, 'spec', 'spec_helper.rb')
|
6
|
+
spec_dir = File.join(cookbook_dir, 'spec', 'unit', 'recipes')
|
7
7
|
spec_path = File.join(spec_dir, "#{context.new_file_basename}_spec.rb")
|
8
|
-
inspec_dir = File.join(cookbook_dir,
|
9
|
-
inspec_path = File.join(inspec_dir, "#{context.new_file_basename}.rb")
|
8
|
+
inspec_dir = File.join(cookbook_dir, 'test', 'smoke', 'default')
|
9
|
+
inspec_path = File.join(inspec_dir, "#{context.new_file_basename}_test.rb")
|
10
10
|
|
11
|
-
if File.directory?(File.join(cookbook_dir,
|
11
|
+
if File.directory?(File.join(cookbook_dir, 'test', 'recipes'))
|
12
12
|
Chef::Log.deprecation <<-EOH
|
13
13
|
It appears that you have Inspec tests located at "test/recipes". This location can
|
14
14
|
cause issues with Foodcritic and has been deprecated in favor of "test/smoke/default".
|
@@ -28,7 +28,7 @@ cookbook_file spec_helper_path do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
template spec_path do
|
31
|
-
source
|
31
|
+
source 'recipe_spec.rb.erb'
|
32
32
|
helpers(ChefDK::Generator::TemplateHelper)
|
33
33
|
action :create_if_missing
|
34
34
|
end
|
@@ -46,6 +46,6 @@ end
|
|
46
46
|
|
47
47
|
# Recipe
|
48
48
|
template recipe_path do
|
49
|
-
source
|
49
|
+
source 'recipe.rb.erb'
|
50
50
|
helpers(ChefDK::Generator::TemplateHelper)
|
51
51
|
end
|
@@ -12,27 +12,27 @@ template "#{repo_dir}/LICENSE" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
cookbook_file "#{repo_dir}/.chef-repo.txt" do
|
15
|
-
source
|
15
|
+
source 'repo/dot-chef-repo.txt'
|
16
16
|
action :create_if_missing
|
17
17
|
end
|
18
18
|
|
19
19
|
cookbook_file "#{repo_dir}/README.md" do
|
20
|
-
source
|
20
|
+
source 'repo/README.md'
|
21
21
|
action :create_if_missing
|
22
22
|
end
|
23
23
|
|
24
24
|
cookbook_file "#{repo_dir}/chefignore" do
|
25
|
-
source
|
25
|
+
source 'chefignore'
|
26
26
|
action :create_if_missing
|
27
27
|
end
|
28
28
|
|
29
|
-
directories_to_create = %w
|
29
|
+
directories_to_create = %w( cookbooks data_bags )
|
30
30
|
|
31
|
-
if context.use_roles
|
32
|
-
|
33
|
-
else
|
34
|
-
|
35
|
-
end
|
31
|
+
directories_to_create += if context.use_roles
|
32
|
+
%w( roles environments )
|
33
|
+
else
|
34
|
+
%w( policies )
|
35
|
+
end
|
36
36
|
|
37
37
|
directories_to_create.each do |tlo|
|
38
38
|
remote_directory "#{repo_dir}/#{tlo}" do
|
@@ -43,24 +43,24 @@ end
|
|
43
43
|
|
44
44
|
cookbook_file "#{repo_dir}/cookbooks/README.md" do
|
45
45
|
if context.policy_only
|
46
|
-
source
|
46
|
+
source 'cookbook_readmes/README-policy.md'
|
47
47
|
else
|
48
|
-
source
|
48
|
+
source 'cookbook_readmes/README.md'
|
49
49
|
end
|
50
50
|
action :create_if_missing
|
51
51
|
end
|
52
52
|
|
53
53
|
# git
|
54
54
|
if context.have_git
|
55
|
-
|
56
|
-
execute(
|
57
|
-
command(
|
55
|
+
unless context.skip_git_init
|
56
|
+
execute('initialize-git') do
|
57
|
+
command('git init .')
|
58
58
|
cwd repo_dir
|
59
59
|
not_if { File.exist?("#{repo_dir}/.gitignore") }
|
60
60
|
end
|
61
61
|
end
|
62
62
|
template "#{repo_dir}/.gitignore" do
|
63
|
-
source
|
63
|
+
source 'repo/gitignore.erb'
|
64
64
|
helpers(ChefDK::Generator::TemplateHelper)
|
65
65
|
action :create_if_missing
|
66
66
|
end
|
@@ -1,31 +1,31 @@
|
|
1
1
|
|
2
2
|
context = ChefDK::Generator.context
|
3
3
|
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
-
template_dir = File.join(cookbook_dir,
|
4
|
+
template_dir = File.join(cookbook_dir, 'templates', 'default')
|
5
5
|
template_filename = context.new_file_basename
|
6
6
|
|
7
|
-
unless File.extname(template_filename) ==
|
7
|
+
unless File.extname(template_filename) == '.erb'
|
8
8
|
# new_file_basename is a frozen string, so we have to create an entirely
|
9
9
|
# new string here instead of using concat.
|
10
10
|
template_filename = "#{template_filename}.erb"
|
11
11
|
end
|
12
12
|
|
13
|
-
template_path = File.join(cookbook_dir,
|
13
|
+
template_path = File.join(cookbook_dir, 'templates', template_filename)
|
14
14
|
|
15
15
|
directory template_dir do
|
16
16
|
recursive true
|
17
17
|
end
|
18
18
|
|
19
|
-
if
|
19
|
+
if context.content_source
|
20
20
|
|
21
21
|
file template_path do
|
22
|
-
content(IO.read(
|
22
|
+
content(IO.read(context.context_source))
|
23
23
|
end
|
24
24
|
|
25
25
|
else
|
26
26
|
|
27
27
|
template template_path do
|
28
|
-
source
|
28
|
+
source 'template.erb'
|
29
29
|
helpers(ChefDK::Generator::TemplateHelper)
|
30
30
|
end
|
31
31
|
|
@@ -3,7 +3,5 @@ source 'https://supermarket.chef.io'
|
|
3
3
|
metadata
|
4
4
|
|
5
5
|
group :delivery do
|
6
|
-
cookbook 'delivery_build', git: 'https://github.com/chef-cookbooks/delivery_build'
|
7
|
-
cookbook 'delivery-base', git: 'https://github.com/chef-cookbooks/delivery-base'
|
8
6
|
cookbook 'test', path: './test/fixtures/cookbooks/test'
|
9
7
|
end
|
@@ -6,13 +6,13 @@
|
|
6
6
|
# found at http://inspec.io/docs/reference/resources/
|
7
7
|
|
8
8
|
unless os.windows?
|
9
|
-
|
9
|
+
# This is an example test, replace with your own test.
|
10
|
+
describe user('root'), :skip do
|
10
11
|
it { should exist }
|
11
|
-
skip 'This is an example test, replace with your own test.'
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
# This is an example test, replace it with your own test.
|
16
|
+
describe port(80), :skip do
|
16
17
|
it { should_not be_listening }
|
17
|
-
skip 'This is an example test, replace with your own test.'
|
18
18
|
end
|
@@ -1,19 +1,20 @@
|
|
1
1
|
name '<%= cookbook_name %>'
|
2
2
|
maintainer '<%= copyright_holder %>'
|
3
3
|
maintainer_email '<%= email %>'
|
4
|
-
license '<%=
|
4
|
+
license '<%= @spdx_license %>'
|
5
5
|
description 'Installs/Configures <%= cookbook_name %>'
|
6
6
|
long_description 'Installs/Configures <%= cookbook_name %>'
|
7
7
|
version '0.1.0'
|
8
|
+
chef_version '>= 12.1' if respond_to?(:chef_version)
|
8
9
|
|
9
10
|
# The `issues_url` points to the location where issues for this cookbook are
|
10
11
|
# tracked. A `View Issues` link will be displayed on this cookbook's page when
|
11
12
|
# uploaded to a Supermarket.
|
12
13
|
#
|
13
|
-
# issues_url 'https://github.com/<insert_org_here>/<%= cookbook_name %>/issues'
|
14
|
+
# issues_url 'https://github.com/<insert_org_here>/<%= cookbook_name %>/issues'
|
14
15
|
|
15
16
|
# The `source_url` points to the development reposiory for this cookbook. A
|
16
17
|
# `View Source` link will be displayed on this cookbook's page when uploaded to
|
17
18
|
# a Supermarket.
|
18
19
|
#
|
19
|
-
# source_url 'https://github.com/<insert_org_here>/<%= cookbook_name %>'
|
20
|
+
# source_url 'https://github.com/<insert_org_here>/<%= cookbook_name %>'
|
@@ -7,9 +7,11 @@
|
|
7
7
|
require 'spec_helper'
|
8
8
|
|
9
9
|
describe '<%= cookbook_name %>::<%= recipe_name %>' do
|
10
|
-
context 'When all attributes are default, on an
|
10
|
+
context 'When all attributes are default, on an Ubuntu 16.04' do
|
11
11
|
let(:chef_run) do
|
12
|
-
|
12
|
+
# for a complete list of available platforms and versions see:
|
13
|
+
# https://github.com/customink/fauxhai/blob/master/PLATFORMS.md
|
14
|
+
runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
|
13
15
|
runner.converge(described_recipe)
|
14
16
|
end
|
15
17
|
|
data/lib/chef-dk/ui.rb
CHANGED
data/lib/chef-dk/version.rb
CHANGED
@@ -21,7 +21,7 @@ require "kitchen/provisioner/chef_base"
|
|
21
21
|
# TODO: chef-dk and kitchen can only co-exist if kitchen and chef-dk agree on
|
22
22
|
# the version of mixlib-shellout to use. Kitchen currently locked at 1.4,
|
23
23
|
# chef-dk is on 2.x
|
24
|
-
require
|
24
|
+
require "chef-dk/policyfile_services/export_repo"
|
25
25
|
|
26
26
|
module Kitchen
|
27
27
|
|
@@ -69,13 +69,13 @@ module Kitchen
|
|
69
69
|
|
70
70
|
default_config :chef_client_path do |provisioner|
|
71
71
|
provisioner.
|
72
|
-
remote_path_join(%W
|
72
|
+
remote_path_join(%W{#{provisioner[:chef_omnibus_root]} bin chef-client}).
|
73
73
|
tap { |path| path.concat(".bat") if provisioner.windows_os? }
|
74
74
|
end
|
75
75
|
|
76
76
|
default_config :ruby_bindir do |provisioner|
|
77
77
|
provisioner.
|
78
|
-
remote_path_join(%W
|
78
|
+
remote_path_join(%W{#{provisioner[:chef_omnibus_root]} embedded bin})
|
79
79
|
end
|
80
80
|
|
81
81
|
# (see Base#finalize_config!)
|
@@ -96,7 +96,7 @@ module Kitchen
|
|
96
96
|
# (see Base#run_command)
|
97
97
|
def run_command
|
98
98
|
level = config[:log_level] == :info ? :auto : config[:log_level]
|
99
|
-
|
99
|
+
|
100
100
|
cmd = "#{sudo(config[:chef_client_path])} --local-mode".
|
101
101
|
tap { |str| str.insert(0, "& ") if powershell_shell? }
|
102
102
|
|
@@ -104,10 +104,10 @@ module Kitchen
|
|
104
104
|
"--config #{config[:root_path]}/client.rb",
|
105
105
|
"--log_level #{level}",
|
106
106
|
"--force-formatter",
|
107
|
-
"--no-color"
|
107
|
+
"--no-color",
|
108
108
|
]
|
109
109
|
if config[:chef_zero_port]
|
110
|
-
args <<
|
110
|
+
args << "--chef-zero-port #{config[:chef_zero_port]}"
|
111
111
|
end
|
112
112
|
if config[:log_file]
|
113
113
|
args << "--logfile #{config[:log_file]}"
|
@@ -166,7 +166,7 @@ module Kitchen
|
|
166
166
|
info("Preparing validation.pem")
|
167
167
|
debug("Using a dummy validation.pem")
|
168
168
|
|
169
|
-
source = File.join(Kitchen.source_root, %w
|
169
|
+
source = File.join(Kitchen.source_root, %w{support dummy-validation.pem})
|
170
170
|
FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
|
171
171
|
end
|
172
172
|
|