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.
Files changed (232) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -12
  3. data/Gemfile.lock +120 -116
  4. data/README.md +4 -3
  5. data/Rakefile +54 -0
  6. data/acceptance/Gemfile.lock +36 -47
  7. data/bin/chef +1 -1
  8. data/chef-dk.gemspec +9 -9
  9. data/lib/chef-dk/authenticated_http.rb +6 -7
  10. data/lib/chef-dk/builtin_commands.rb +3 -4
  11. data/lib/chef-dk/chef_runner.rb +7 -8
  12. data/lib/chef-dk/cli.rb +11 -11
  13. data/lib/chef-dk/command/base.rb +4 -4
  14. data/lib/chef-dk/command/clean_policy_cookbooks.rb +4 -5
  15. data/lib/chef-dk/command/clean_policy_revisions.rb +4 -6
  16. data/lib/chef-dk/command/delete_policy.rb +4 -6
  17. data/lib/chef-dk/command/delete_policy_group.rb +6 -8
  18. data/lib/chef-dk/command/diff.rb +9 -10
  19. data/lib/chef-dk/command/env.rb +26 -27
  20. data/lib/chef-dk/command/exec.rb +5 -6
  21. data/lib/chef-dk/command/export.rb +8 -10
  22. data/lib/chef-dk/command/gem.rb +5 -5
  23. data/lib/chef-dk/command/generate.rb +19 -19
  24. data/lib/chef-dk/command/generator_commands.rb +8 -8
  25. data/lib/chef-dk/command/generator_commands/app.rb +2 -3
  26. data/lib/chef-dk/command/generator_commands/attribute.rb +2 -3
  27. data/lib/chef-dk/command/generator_commands/base.rb +13 -13
  28. data/lib/chef-dk/command/generator_commands/build_cookbook.rb +2 -2
  29. data/lib/chef-dk/command/generator_commands/chef_exts/generator_desc_resource.rb +2 -2
  30. data/lib/chef-dk/command/generator_commands/chef_exts/quieter_doc_formatter.rb +1 -2
  31. data/lib/chef-dk/command/generator_commands/chef_exts/recipe_dsl_ext.rb +1 -2
  32. data/lib/chef-dk/command/generator_commands/cookbook.rb +2 -2
  33. data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +3 -3
  34. data/lib/chef-dk/command/generator_commands/cookbook_file.rb +2 -2
  35. data/lib/chef-dk/command/generator_commands/generator_generator.rb +4 -7
  36. data/lib/chef-dk/command/generator_commands/lwrp.rb +2 -2
  37. data/lib/chef-dk/command/generator_commands/policyfile.rb +2 -3
  38. data/lib/chef-dk/command/generator_commands/recipe.rb +2 -2
  39. data/lib/chef-dk/command/generator_commands/repo.rb +1 -3
  40. data/lib/chef-dk/command/generator_commands/template.rb +2 -2
  41. data/lib/chef-dk/command/install.rb +4 -5
  42. data/lib/chef-dk/command/provision.rb +12 -14
  43. data/lib/chef-dk/command/push.rb +5 -6
  44. data/lib/chef-dk/command/push_archive.rb +4 -5
  45. data/lib/chef-dk/command/shell_init.rb +15 -16
  46. data/lib/chef-dk/command/show_policy.rb +5 -7
  47. data/lib/chef-dk/command/undelete.rb +6 -7
  48. data/lib/chef-dk/command/update.rb +5 -6
  49. data/lib/chef-dk/command/verify.rb +30 -31
  50. data/lib/chef-dk/commands_map.rb +1 -3
  51. data/lib/chef-dk/component_test.rb +13 -13
  52. data/lib/chef-dk/configurable.rb +2 -2
  53. data/lib/chef-dk/cookbook_metadata.rb +2 -2
  54. data/lib/chef-dk/cookbook_omnifetch.rb +7 -8
  55. data/lib/chef-dk/cookbook_profiler/git.rb +8 -8
  56. data/lib/chef-dk/cookbook_profiler/identifiers.rb +7 -7
  57. data/lib/chef-dk/cookbook_profiler/null_scm.rb +0 -1
  58. data/lib/chef-dk/exceptions.rb +1 -1
  59. data/lib/chef-dk/generator.rb +9 -7
  60. data/lib/chef-dk/helpers.rb +15 -15
  61. data/lib/chef-dk/pager.rb +2 -3
  62. data/lib/chef-dk/policyfile/chef_repo_cookbook_source.rb +4 -4
  63. data/lib/chef-dk/policyfile/chef_server_cookbook_source.rb +6 -6
  64. data/lib/chef-dk/policyfile/community_cookbook_source.rb +4 -5
  65. data/lib/chef-dk/policyfile/comparison_base.rb +3 -4
  66. data/lib/chef-dk/policyfile/cookbook_location_specification.rb +6 -6
  67. data/lib/chef-dk/policyfile/cookbook_locks.rb +11 -11
  68. data/lib/chef-dk/policyfile/cookbook_sources.rb +5 -5
  69. data/lib/chef-dk/policyfile/delivery_supermarket_source.rb +8 -9
  70. data/lib/chef-dk/policyfile/differ.rb +7 -10
  71. data/lib/chef-dk/policyfile/dsl.rb +10 -11
  72. data/lib/chef-dk/policyfile/lister.rb +3 -6
  73. data/lib/chef-dk/policyfile/null_cookbook_source.rb +3 -3
  74. data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +3 -3
  75. data/lib/chef-dk/policyfile/reports/install.rb +3 -4
  76. data/lib/chef-dk/policyfile/reports/table_printer.rb +0 -1
  77. data/lib/chef-dk/policyfile/reports/upload.rb +4 -4
  78. data/lib/chef-dk/policyfile/solution_dependencies.rb +22 -22
  79. data/lib/chef-dk/policyfile/source_uri.rb +2 -2
  80. data/lib/chef-dk/policyfile/storage_config.rb +4 -5
  81. data/lib/chef-dk/policyfile/undo_record.rb +6 -9
  82. data/lib/chef-dk/policyfile/undo_stack.rb +5 -7
  83. data/lib/chef-dk/policyfile/uploader.rb +8 -8
  84. data/lib/chef-dk/policyfile_compiler.rb +16 -20
  85. data/lib/chef-dk/policyfile_lock.rb +10 -11
  86. data/lib/chef-dk/policyfile_services/clean_policies.rb +3 -3
  87. data/lib/chef-dk/policyfile_services/clean_policy_cookbooks.rb +3 -5
  88. data/lib/chef-dk/policyfile_services/export_repo.rb +13 -14
  89. data/lib/chef-dk/policyfile_services/install.rb +6 -6
  90. data/lib/chef-dk/policyfile_services/push.rb +6 -8
  91. data/lib/chef-dk/policyfile_services/push_archive.rb +6 -10
  92. data/lib/chef-dk/policyfile_services/rm_policy.rb +4 -5
  93. data/lib/chef-dk/policyfile_services/rm_policy_group.rb +4 -5
  94. data/lib/chef-dk/policyfile_services/show_policy.rb +5 -6
  95. data/lib/chef-dk/policyfile_services/undelete.rb +3 -3
  96. data/lib/chef-dk/policyfile_services/update_attributes.rb +4 -6
  97. data/lib/chef-dk/service_exception_inspectors.rb +2 -3
  98. data/lib/chef-dk/service_exception_inspectors/base.rb +0 -1
  99. data/lib/chef-dk/service_exception_inspectors/http.rb +1 -3
  100. data/lib/chef-dk/service_exceptions.rb +1 -2
  101. data/lib/chef-dk/shell_out.rb +1 -1
  102. data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/.kitchen.yml +2 -2
  103. data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/README.md +2 -2
  104. data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +1 -0
  105. data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +1 -1
  106. data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +1 -1
  107. data/lib/chef-dk/skeletons/code_generator/metadata.rb +0 -1
  108. data/lib/chef-dk/skeletons/code_generator/recipes/app.rb +6 -6
  109. data/lib/chef-dk/skeletons/code_generator/recipes/attribute.rb +3 -3
  110. data/lib/chef-dk/skeletons/code_generator/recipes/build_cookbook.rb +43 -39
  111. data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +31 -22
  112. data/lib/chef-dk/skeletons/code_generator/recipes/cookbook_file.rb +5 -5
  113. data/lib/chef-dk/skeletons/code_generator/recipes/lwrp.rb +4 -4
  114. data/lib/chef-dk/skeletons/code_generator/recipes/policyfile.rb +1 -1
  115. data/lib/chef-dk/skeletons/code_generator/recipes/recipe.rb +8 -8
  116. data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +15 -15
  117. data/lib/chef-dk/skeletons/code_generator/recipes/template.rb +6 -6
  118. data/lib/chef-dk/skeletons/code_generator/templates/default/build_cookbook/Berksfile.erb +0 -2
  119. data/lib/chef-dk/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +1 -0
  120. data/lib/chef-dk/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +4 -4
  121. data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen.yml.erb +1 -1
  122. data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +1 -1
  123. data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +4 -3
  124. data/lib/chef-dk/skeletons/code_generator/templates/default/recipe_spec.rb.erb +4 -2
  125. data/lib/chef-dk/ui.rb +0 -1
  126. data/lib/chef-dk/version.rb +1 -1
  127. data/lib/kitchen/provisioner/policyfile_zero.rb +7 -7
  128. data/omnibus_overrides.rb +3 -3
  129. data/spec/shared/a_file_generator.rb +3 -3
  130. data/spec/shared/custom_generator_cookbook.rb +6 -6
  131. data/spec/shared/fixture_cookbook_checksums.rb +2 -3
  132. data/spec/shared/setup_git_committer_config.rb +1 -1
  133. data/spec/shared/setup_git_cookbooks.rb +2 -2
  134. data/spec/spec_helper.rb +5 -5
  135. data/spec/test_helpers.rb +2 -2
  136. data/spec/unit/chef_runner_spec.rb +5 -7
  137. data/spec/unit/cli_spec.rb +36 -37
  138. data/spec/unit/command/base_spec.rb +4 -5
  139. data/spec/unit/command/clean_policy_cookbooks_spec.rb +8 -9
  140. data/spec/unit/command/clean_policy_revisions_spec.rb +8 -9
  141. data/spec/unit/command/delete_policy_group_spec.rb +11 -12
  142. data/spec/unit/command/delete_policy_spec.rb +11 -12
  143. data/spec/unit/command/diff_spec.rb +5 -6
  144. data/spec/unit/command/env_spec.rb +5 -5
  145. data/spec/unit/command/exec_spec.rb +18 -19
  146. data/spec/unit/command/export_spec.rb +5 -6
  147. data/spec/unit/command/generate_spec.rb +10 -10
  148. data/spec/unit/command/generator_commands/app_spec.rb +6 -6
  149. data/spec/unit/command/generator_commands/attribute_spec.rb +3 -4
  150. data/spec/unit/command/generator_commands/base_spec.rb +46 -46
  151. data/spec/unit/command/generator_commands/build_cookbook_spec.rb +50 -16
  152. data/spec/unit/command/generator_commands/chef_exts/generator_desc_resource_spec.rb +9 -9
  153. data/spec/unit/command/generator_commands/chef_exts/recipe_dsl_ext_spec.rb +16 -16
  154. data/spec/unit/command/generator_commands/cookbook_file_spec.rb +3 -4
  155. data/spec/unit/command/generator_commands/cookbook_spec.rb +23 -26
  156. data/spec/unit/command/generator_commands/generator_generator_spec.rb +4 -6
  157. data/spec/unit/command/generator_commands/lwrp_spec.rb +3 -4
  158. data/spec/unit/command/generator_commands/policyfile_spec.rb +3 -5
  159. data/spec/unit/command/generator_commands/recipe_spec.rb +4 -4
  160. data/spec/unit/command/generator_commands/repo_spec.rb +11 -11
  161. data/spec/unit/command/generator_commands/template_spec.rb +3 -4
  162. data/spec/unit/command/install_spec.rb +6 -6
  163. data/spec/unit/command/provision_spec.rb +27 -30
  164. data/spec/unit/command/push_archive_spec.rb +3 -3
  165. data/spec/unit/command/push_spec.rb +5 -6
  166. data/spec/unit/command/shell_init_spec.rb +17 -19
  167. data/spec/unit/command/show_policy_spec.rb +11 -12
  168. data/spec/unit/command/undelete_spec.rb +12 -14
  169. data/spec/unit/command/update_spec.rb +8 -8
  170. data/spec/unit/command/verify_spec.rb +10 -10
  171. data/spec/unit/commands_map_spec.rb +4 -4
  172. data/spec/unit/component_test_spec.rb +3 -3
  173. data/spec/unit/configurable_spec.rb +7 -7
  174. data/spec/unit/cookbook_metadata_spec.rb +5 -7
  175. data/spec/unit/cookbook_profiler/git_spec.rb +6 -7
  176. data/spec/unit/cookbook_profiler/identifiers_spec.rb +5 -7
  177. data/spec/unit/fixtures/command/cli_test_command.rb +2 -2
  178. data/spec/unit/fixtures/configurable/test_configurable.rb +1 -1
  179. data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +13 -16
  180. data/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/berkshelf/verify_me +1 -1
  181. data/spec/unit/gemfile_util_spec.rb +4 -4
  182. data/spec/unit/generator_spec.rb +10 -10
  183. data/spec/unit/helpers_spec.rb +31 -31
  184. data/spec/unit/pager_spec.rb +5 -7
  185. data/spec/unit/policyfile/chef_repo_cookbook_source_spec.rb +11 -11
  186. data/spec/unit/policyfile/chef_server_cookbook_source_spec.rb +13 -13
  187. data/spec/unit/policyfile/community_cookbook_source_spec.rb +3 -4
  188. data/spec/unit/policyfile/comparison_base_spec.rb +3 -6
  189. data/spec/unit/policyfile/cookbook_location_specification_spec.rb +3 -3
  190. data/spec/unit/policyfile/cookbook_locks_spec.rb +7 -9
  191. data/spec/unit/policyfile/delivery_supermarket_source_spec.rb +16 -17
  192. data/spec/unit/policyfile/differ_spec.rb +4 -5
  193. data/spec/unit/policyfile/lister_spec.rb +31 -35
  194. data/spec/unit/policyfile/null_cookbook_source_spec.rb +2 -3
  195. data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +3 -3
  196. data/spec/unit/policyfile/reports/install_spec.rb +4 -5
  197. data/spec/unit/policyfile/reports/upload_spec.rb +4 -6
  198. data/spec/unit/policyfile/solution_dependencies_spec.rb +13 -13
  199. data/spec/unit/policyfile/source_uri_spec.rb +5 -5
  200. data/spec/unit/policyfile/storage_config_spec.rb +3 -7
  201. data/spec/unit/policyfile/undo_record_spec.rb +21 -23
  202. data/spec/unit/policyfile/undo_stack_spec.rb +5 -6
  203. data/spec/unit/policyfile/uploader_spec.rb +73 -75
  204. data/spec/unit/policyfile_demands_spec.rb +93 -99
  205. data/spec/unit/policyfile_evaluation_spec.rb +14 -14
  206. data/spec/unit/policyfile_lock_build_spec.rb +64 -65
  207. data/spec/unit/policyfile_lock_install_spec.rb +5 -6
  208. data/spec/unit/policyfile_lock_serialization_spec.rb +14 -15
  209. data/spec/unit/policyfile_lock_validation_spec.rb +17 -20
  210. data/spec/unit/policyfile_services/clean_policies_spec.rb +16 -16
  211. data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +26 -29
  212. data/spec/unit/policyfile_services/export_repo_spec.rb +3 -6
  213. data/spec/unit/policyfile_services/install_spec.rb +5 -7
  214. data/spec/unit/policyfile_services/push_archive_spec.rb +4 -8
  215. data/spec/unit/policyfile_services/push_spec.rb +3 -3
  216. data/spec/unit/policyfile_services/rm_policy_group_spec.rb +16 -20
  217. data/spec/unit/policyfile_services/rm_policy_spec.rb +14 -17
  218. data/spec/unit/policyfile_services/show_policy_spec.rb +78 -80
  219. data/spec/unit/policyfile_services/undelete_spec.rb +5 -7
  220. data/spec/unit/policyfile_services/update_attributes_spec.rb +34 -35
  221. data/spec/unit/service_exception_inspectors/base_spec.rb +2 -4
  222. data/spec/unit/service_exception_inspectors/http_spec.rb +9 -11
  223. data/spec/unit/shell_out_spec.rb +2 -2
  224. data/spec/unit/tasks/helpers_spec.rb +2 -2
  225. data/tasks/bin/bundle-platform +1 -1
  226. data/tasks/bundle_util.rb +1 -1
  227. data/tasks/dependencies.rb +21 -7
  228. data/tasks/gemfile_util.rb +1 -1
  229. data/tasks/helpers.rb +2 -2
  230. data/tasks/version.rb +26 -1
  231. data/version_policy.rb +6 -6
  232. 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("Ensuring correct cookbook file content")
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 "Policyfile.rb.erb"
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 "spec_helper.rb"
89
+ source 'spec_helper.rb'
77
90
  else
78
- source "spec_helper_policyfile.rb"
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 "recipe_spec.rb.erb"
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 "recipe.rb.erb"
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("Committing cookbook files to git")
117
+ generator_desc('Committing cookbook files to git')
105
118
 
106
- execute("initialize-git") do
107
- command("git init .")
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 "gitignore"
127
+ source 'gitignore'
115
128
  end
116
129
 
117
130
  unless context.skip_git_init
118
131
 
119
- execute("git-add-new-files") do
120
- command("git add .")
132
+ execute('git-add-new-files') do
133
+ command('git add .')
121
134
  cwd cookbook_dir
122
135
  end
123
136
 
124
- execute("git-commit-new-files") do
125
- command("git commit -m \"Add generated cookbook content\"")
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, "files", "default")
5
- cookbook_file_path = File.join(cookbook_dir, "files", "default", context.new_file_basename)
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 source_file = context.content_source
11
+ if context.content_source
12
12
 
13
13
  file cookbook_file_path do
14
- content(IO.read(source_file))
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 "cookbook_file.erb"
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, "resources")
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, "providers")
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 "resource.rb.erb"
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 "provider.rb.erb"
21
+ source 'provider.rb.erb'
22
22
  helpers(ChefDK::Generator::TemplateHelper)
23
23
  end
@@ -3,6 +3,6 @@ context = ChefDK::Generator.context
3
3
  policyfile_path = File.join(context.policyfile_dir, "#{context.new_file_basename}.rb")
4
4
 
5
5
  template policyfile_path do
6
- source "Policyfile.rb.erb"
6
+ source 'Policyfile.rb.erb'
7
7
  helpers(ChefDK::Generator::TemplateHelper)
8
8
  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, "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")
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, "test", "smoke", "default")
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, "test", "recipes"))
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 "recipe_spec.rb.erb"
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 "recipe.rb.erb"
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 "repo/dot-chef-repo.txt"
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 "repo/README.md"
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 "chefignore"
25
+ source 'chefignore'
26
26
  action :create_if_missing
27
27
  end
28
28
 
29
- directories_to_create = %w{ cookbooks data_bags }
29
+ directories_to_create = %w( cookbooks data_bags )
30
30
 
31
- if context.use_roles
32
- directories_to_create += %w{ roles environments }
33
- else
34
- directories_to_create += %w{ policies }
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 "cookbook_readmes/README-policy.md"
46
+ source 'cookbook_readmes/README-policy.md'
47
47
  else
48
- source "cookbook_readmes/README.md"
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
- if !context.skip_git_init
56
- execute("initialize-git") do
57
- command("git init .")
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 "repo/gitignore.erb"
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, "templates", "default")
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) == ".erb"
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, "templates", template_filename)
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 source_file = context.content_source
19
+ if context.content_source
20
20
 
21
21
  file template_path do
22
- content(IO.read(source_file))
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 "template.erb"
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
@@ -3,6 +3,7 @@ maintainer '<%= copyright_holder %>'
3
3
  maintainer_email '<%= email %>'
4
4
  license '<%= license %>'
5
5
  version '0.1.0'
6
+ chef_version '>= 12.1' if respond_to?(:chef_version)
6
7
  <% if build_cookbook_parent_is_cookbook -%>
7
8
 
8
9
  depends 'delivery-truck'
@@ -6,13 +6,13 @@
6
6
  # found at http://inspec.io/docs/reference/resources/
7
7
 
8
8
  unless os.windows?
9
- describe user('root') do
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
- describe port(80) do
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
@@ -14,7 +14,7 @@ verifier:
14
14
 
15
15
  platforms:
16
16
  - name: ubuntu-16.04
17
- - name: centos-7.2
17
+ - name: centos-7.3
18
18
 
19
19
  suites:
20
20
  - name: default
@@ -23,7 +23,7 @@ verifier:
23
23
 
24
24
  platforms:
25
25
  - name: ubuntu-16.04
26
- - name: centos-7.2
26
+ - name: centos-7.3
27
27
 
28
28
  suites:
29
29
  - name: default
@@ -1,19 +1,20 @@
1
1
  name '<%= cookbook_name %>'
2
2
  maintainer '<%= copyright_holder %>'
3
3
  maintainer_email '<%= email %>'
4
- license '<%= 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' if respond_to?(:issues_url)
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 %>' if respond_to?(:source_url)
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 unspecified platform' do
10
+ context 'When all attributes are default, on an Ubuntu 16.04' do
11
11
  let(:chef_run) do
12
- runner = ChefSpec::ServerRunner.new
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
 
@@ -55,4 +55,3 @@ module ChefDK
55
55
  end
56
56
  end
57
57
  end
58
-
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefDK
19
- VERSION = "1.2.22"
19
+ VERSION = "1.3.40"
20
20
  end
@@ -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 'chef-dk/policyfile_services/export_repo'
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[#{provisioner[:chef_omnibus_root]} bin chef-client]).
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[#{provisioner[:chef_omnibus_root]} embedded bin])
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 << "--chef-zero-port #{config[:chef_zero_port]}"
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[support dummy-validation.pem])
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