chef-dk 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/chef-dk/authenticated_http.rb +40 -0
  4. data/lib/chef-dk/chef_runner.rb +5 -0
  5. data/lib/chef-dk/command/exec.rb +4 -1
  6. data/lib/chef-dk/command/generate.rb +11 -0
  7. data/lib/chef-dk/command/generator_commands.rb +20 -365
  8. data/lib/chef-dk/command/generator_commands/app.rb +99 -0
  9. data/lib/chef-dk/command/generator_commands/attribute.rb +37 -0
  10. data/lib/chef-dk/command/generator_commands/base.rb +76 -0
  11. data/lib/chef-dk/command/generator_commands/cookbook.rb +100 -0
  12. data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +99 -0
  13. data/lib/chef-dk/command/generator_commands/cookbook_file.rb +45 -0
  14. data/lib/chef-dk/command/generator_commands/lwrp.rb +36 -0
  15. data/lib/chef-dk/command/generator_commands/recipe.rb +36 -0
  16. data/lib/chef-dk/command/generator_commands/repo.rb +96 -0
  17. data/lib/chef-dk/command/generator_commands/template.rb +45 -0
  18. data/lib/chef-dk/command/verify.rb +28 -0
  19. data/lib/chef-dk/component_test.rb +16 -3
  20. data/lib/chef-dk/cookbook_omnifetch.rb +2 -0
  21. data/lib/chef-dk/cookbook_profiler/identifiers.rb +3 -15
  22. data/lib/chef-dk/exceptions.rb +15 -0
  23. data/lib/chef-dk/generator.rb +102 -25
  24. data/lib/chef-dk/policyfile/community_cookbook_source.rb +0 -7
  25. data/lib/chef-dk/policyfile/{cookbook_spec.rb → cookbook_location_specification.rb} +35 -6
  26. data/lib/chef-dk/policyfile/cookbook_locks.rb +305 -0
  27. data/lib/chef-dk/policyfile/dsl.rb +26 -12
  28. data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +70 -0
  29. data/lib/chef-dk/policyfile/solution_dependencies.rb +204 -0
  30. data/lib/chef-dk/policyfile/storage_config.rb +77 -0
  31. data/lib/chef-dk/policyfile/uploader.rb +110 -0
  32. data/lib/chef-dk/policyfile_compiler.rb +59 -29
  33. data/lib/chef-dk/policyfile_lock.rb +104 -160
  34. data/lib/chef-dk/skeletons/code_generator/files/default/Berksfile +1 -1
  35. data/lib/chef-dk/skeletons/code_generator/files/default/chefignore +0 -1
  36. data/lib/chef-dk/skeletons/code_generator/files/default/repo/README.md +66 -0
  37. data/lib/chef-dk/skeletons/code_generator/files/default/repo/Rakefile +65 -0
  38. data/lib/chef-dk/skeletons/code_generator/files/default/repo/certificates/README.md +19 -0
  39. data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README-policy.md +9 -0
  40. data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README.md +54 -0
  41. data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/README.md +63 -0
  42. data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/README.md +5 -0
  43. data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/README.md +16 -0
  44. data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +7 -1
  45. data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +62 -0
  46. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
  47. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.apache2.erb +201 -0
  48. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
  49. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
  50. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
  51. data/lib/chef-dk/skeletons/code_generator/templates/default/default_recipe.rb.erb +1 -4
  52. data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +3 -3
  53. data/lib/chef-dk/skeletons/code_generator/templates/default/repo/config/rake.rb.erb +38 -0
  54. data/lib/chef-dk/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -0
  55. data/lib/chef-dk/version.rb +1 -1
  56. data/spec/shared/a_file_generator.rb +121 -0
  57. data/spec/shared/a_generated_file.rb +12 -0
  58. data/spec/shared/fixture_cookbook_checksums.rb +47 -0
  59. data/spec/spec_helper.rb +4 -2
  60. data/spec/unit/chef_runner_spec.rb +12 -5
  61. data/spec/unit/cli_spec.rb +4 -4
  62. data/spec/unit/command/base_spec.rb +1 -1
  63. data/spec/unit/command/exec_spec.rb +37 -27
  64. data/spec/unit/command/generate_spec.rb +3 -3
  65. data/spec/unit/command/generator_commands/app_spec.rb +131 -0
  66. data/spec/unit/command/generator_commands/attribute_spec.rb +32 -0
  67. data/spec/unit/command/generator_commands/cookbook_file_spec.rb +32 -0
  68. data/spec/unit/command/generator_commands/cookbook_spec.rb +205 -0
  69. data/spec/unit/command/generator_commands/lwrp_spec.rb +32 -0
  70. data/spec/unit/command/generator_commands/recipe_spec.rb +32 -0
  71. data/spec/unit/command/generator_commands/repo_spec.rb +287 -0
  72. data/spec/unit/command/generator_commands/template_spec.rb +32 -0
  73. data/spec/unit/command/shell_init_spec.rb +4 -4
  74. data/spec/unit/command/verify_spec.rb +9 -9
  75. data/spec/unit/commands_map_spec.rb +1 -1
  76. data/spec/unit/component_test_spec.rb +3 -3
  77. data/spec/unit/cookbook_profiler/git_spec.rb +7 -7
  78. data/spec/unit/cookbook_profiler/identifiers_spec.rb +12 -8
  79. data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/Berksfile +1 -1
  80. data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/Berksfile +1 -1
  81. data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/Berksfile +1 -1
  82. data/spec/unit/fixtures/example_cookbook/Berksfile +1 -1
  83. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/README.md +4 -0
  84. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/chefignore +96 -0
  85. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/metadata.rb +8 -0
  86. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/recipes/default.rb +8 -0
  87. data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/Berksfile +1 -1
  88. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml +16 -0
  89. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md +4 -0
  90. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb +8 -0
  91. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb +8 -0
  92. data/spec/unit/generator_spec.rb +120 -0
  93. data/spec/unit/policyfile/{cookbook_spec_spec.rb → cookbook_location_specification_spec.rb} +83 -38
  94. data/spec/unit/policyfile/cookbook_locks_spec.rb +354 -0
  95. data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +85 -0
  96. data/spec/unit/policyfile/solution_dependencies_spec.rb +145 -0
  97. data/spec/unit/policyfile/storage_config_spec.rb +98 -0
  98. data/spec/unit/policyfile/uploader_spec.rb +292 -0
  99. data/spec/unit/policyfile_demands_spec.rb +177 -24
  100. data/spec/unit/policyfile_evaluation_spec.rb +40 -12
  101. data/spec/unit/{policyfile_builder_spec.rb → policyfile_lock_build_spec.rb} +179 -64
  102. data/spec/unit/policyfile_lock_install_spec.rb +138 -0
  103. data/spec/unit/policyfile_lock_validation_spec.rb +610 -0
  104. metadata +103 -59
  105. data/spec/unit/command/generator_commands_spec.rb +0 -504
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b9f2f339c70e930b7bee3c3422c8b013e98e43b
4
- data.tar.gz: d7cbff8ca1698edf60e5908d52ade0096c66416e
3
+ metadata.gz: 71929ebb4b2845757688d9de6a8519e2984de9e3
4
+ data.tar.gz: cbf10aabf6125995c29fe7199ca37e22a5b1d5a8
5
5
  SHA512:
6
- metadata.gz: c547ff5ccf4d910fa63487fb5d7137fee25944ee3e2482ce96bda6f645b5b93c1b20c03a846faa3a2aecfa3d70242b0431a0e06a762215518ce9880012498f0f
7
- data.tar.gz: 701fc497bdb6322659ed4ca70ca45e0b6359c00a14296b12c0e4cb0bab0371db9f8c1f517eed6f7578a3389120ee0ecfa67f99a1f127b9919771837fe9fdafef
6
+ metadata.gz: 93381f6a0deb08de22ef67c5605adf8221f470523de25b6ae5f6207daddaf4cb8d4414cfc5f2bbd597085fc2e39dc29d11539d1fe8e2f250c131e2fff48eb83a
7
+ data.tar.gz: a90008e558fb76709c8ca8159532e7132416c24af750538aff94855201479fd7a876a467c3732cbaf5eb66e3cb7f2e99df00d6ecf795c762b3fdb2353c773c8d
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Chef Development Kit
2
2
 
3
- Chef Development Kit (Chef DK) brings Chef and the development tools developed by the Chef Community together and acts as the consistent interface to this awesomeness. This awesomeness is composed of:
3
+ Chef Development Kit (ChefDK) brings Chef and the development tools developed by the Chef Community together and acts as the consistent interface to this awesomeness. This awesomeness is composed of:
4
4
 
5
5
  * [Chef][]
6
6
  * [Berkshelf][]
@@ -0,0 +1,40 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef/http'
19
+ require 'chef/http/authenticator'
20
+ require 'chef/http/json_input'
21
+ require 'chef/http/json_output'
22
+ require 'chef/http/decompressor'
23
+ require 'chef/http/validate_content_length'
24
+
25
+ module ChefDK
26
+ class AuthenticatedHTTP < Chef::HTTP
27
+
28
+ use JSONInput
29
+ use JSONOutput
30
+ use Decompressor
31
+ use Authenticator
32
+
33
+ # ValidateContentLength should come after Decompressor
34
+ # because the order of middlewares is reversed when handling
35
+ # responses.
36
+ use ValidateContentLength
37
+
38
+ end
39
+ end
40
+
@@ -60,6 +60,11 @@ module ChefDK
60
60
  Chef::Config.cookbook_path = cookbook_path
61
61
  Chef::Config.color = true
62
62
  Chef::Config.diff_disabled = true
63
+
64
+ # atomic file operations on Windows require Administrator privileges to be able to read the SACL from a file
65
+ # Using file_staging_uses_destdir(true) will get us inherited permissions indirectly on tempfile creation
66
+ Chef::Config.file_atomic_update = false if Chef::Platform.windows?
67
+ Chef::Config.file_staging_uses_destdir = true # Default in Chef 12+
63
68
  end
64
69
 
65
70
  def ohai
@@ -24,7 +24,10 @@ module ChefDK
24
24
  banner "Usage: chef exec SYSTEM_COMMAND"
25
25
 
26
26
  def run(params)
27
- exec omnibus_env, *params
27
+ # Set ENV directly on the "parent" process (us) before running #exec to
28
+ # ensure the custom PATH is honored when finding the command to exec
29
+ omnibus_env.each {|var, value| ENV[var] = value }
30
+ exec(*params)
28
31
  raise "Exec failed without an exception, your ruby is buggy" # should never get here
29
32
  end
30
33
  end
@@ -17,6 +17,16 @@
17
17
 
18
18
  require 'chef-dk/command/base'
19
19
  require 'chef-dk/command/generator_commands'
20
+ require 'chef-dk/command/generator_commands/base'
21
+ require 'chef-dk/command/generator_commands/cookbook_code_file'
22
+ require 'chef-dk/command/generator_commands/cookbook'
23
+ require 'chef-dk/command/generator_commands/app'
24
+ require 'chef-dk/command/generator_commands/attribute'
25
+ require 'chef-dk/command/generator_commands/cookbook_file'
26
+ require 'chef-dk/command/generator_commands/lwrp'
27
+ require 'chef-dk/command/generator_commands/recipe'
28
+ require 'chef-dk/command/generator_commands/template'
29
+ require 'chef-dk/command/generator_commands/repo'
20
30
 
21
31
  module ChefDK
22
32
  module Command
@@ -39,6 +49,7 @@ module ChefDK
39
49
  generator(:template, :Template, "Generate a file template")
40
50
  generator(:file, :CookbookFile, "Generate a cookbook file")
41
51
  generator(:lwrp, :LWRP, "Generate a lightweight resource/provider")
52
+ generator(:repo, :Repo, "Generate a Chef policy repository")
42
53
 
43
54
  def self.banner_headline
44
55
  <<-E
@@ -31,6 +31,26 @@ module ChefDK
31
31
  module SharedGeneratorOptions
32
32
  include Mixlib::CLI
33
33
 
34
+ # You really want these to have default values, as
35
+ # they will likely be used all over the place.
36
+ option :license,
37
+ :short => "-I LICENSE",
38
+ :long => "--license LICENSE",
39
+ :description => "all_rights, apache2, mit, gplv2, gplv3 - defaults to all_rights",
40
+ :default => "all_rights"
41
+
42
+ option :copyright_holder,
43
+ :short => "-C COPYRIGHT",
44
+ :long => "--copyright COPYRIGHT",
45
+ :description => "Name of the copyright holder - defaults to 'The Authors'",
46
+ :default => "The Authors"
47
+
48
+ option :email,
49
+ :short => "-m EMAIL",
50
+ :long => "--email EMAIL",
51
+ :description => "Email address of the author - defaults to 'you@example.com'",
52
+ :default => 'you@example.com'
53
+
34
54
  option :generator_cookbook,
35
55
  :short => "-g GENERATOR_COOKBOOK_PATH",
36
56
  :long => "--generator-cookbook GENERATOR_COOKBOOK_PATH",
@@ -44,374 +64,9 @@ module ChefDK
44
64
  #
45
65
  # This module is the namespace for all subcommands of `chef generate`
46
66
  module GeneratorCommands
47
-
48
67
  def self.build(class_name, params)
49
68
  const_get(class_name).new(params)
50
69
  end
51
-
52
- # ## Base
53
- #
54
- # Base class for `chef generate` subcommands. Contains basic behaviors
55
- # for setting up the generator context, detecting git, and launching a
56
- # chef converge.
57
- #
58
- # The behavior of the generators is largely delegated to a chef cookbook.
59
- # The default implementation is the `code_generator` cookbook in
60
- # chef-dk/skeletons/code_generator.
61
- class Base < Command::Base
62
-
63
- attr_reader :params
64
-
65
- options.merge!(SharedGeneratorOptions.options)
66
-
67
- def initialize(params)
68
- super()
69
- @params = params
70
- end
71
-
72
- # An instance of ChefRunner. Calling ChefRunner#converge will trigger
73
- # convergence and generate the desired code.
74
- def chef_runner
75
- @chef_runner ||= ChefRunner.new(generator_cookbook_path, ["code_generator::#{recipe}"])
76
- end
77
-
78
- # Path to the directory where the code_generator cookbook is located.
79
- # For now, this is hard coded to the 'skeletons' directory in this
80
- # repo.
81
- def generator_cookbook_path
82
- config[:generator_cookbook]
83
- end
84
-
85
- # Sets git related generator_context values.
86
- def setup_context
87
- Generator.context.have_git = have_git?
88
- Generator.context.skip_git_init = false
89
- end
90
-
91
- # Delegates to `Generator.context`, the singleton instance of
92
- # Generator::Context
93
- def generator_context
94
- Generator.context
95
- end
96
-
97
- # Checks the `PATH` for the presence of a `git` (or `git.exe`, on
98
- # windows) executable.
99
- def have_git?
100
- path = ENV["PATH"] || ""
101
- paths = path.split(File::PATH_SEPARATOR)
102
- paths.any? {|bin_path| File.exist?(File.join(bin_path, "git#{RbConfig::CONFIG['EXEEXT']}"))}
103
- end
104
-
105
- end
106
-
107
- # ## App
108
- # chef generate app path/to/basename --generator-cookbook=path/to/generator
109
- #
110
- # Generates a full "application" directory structure.
111
- class App < Base
112
-
113
- banner "Usage: chef generate app NAME [options]"
114
-
115
- attr_reader :errors
116
- attr_reader :app_name_or_path
117
-
118
- options.merge!(SharedGeneratorOptions.options)
119
-
120
- def initialize(params)
121
- @params_valid = true
122
- @app_name = nil
123
- super
124
- end
125
-
126
- def run
127
- read_and_validate_params
128
- if params_valid?
129
- setup_context
130
- chef_runner.converge
131
- else
132
- msg(banner)
133
- 1
134
- end
135
- end
136
-
137
- def setup_context
138
- super
139
- generator_context.app_root = app_root
140
- generator_context.app_name = app_name
141
- generator_context.cookbook_root ||= cookbook_root
142
- generator_context.cookbook_name ||= cookbook_name
143
- end
144
-
145
- def recipe
146
- "app"
147
- end
148
-
149
- def app_name
150
- File.basename(app_full_path)
151
- end
152
-
153
- def app_root
154
- File.dirname(app_full_path)
155
- end
156
-
157
- def cookbook_root
158
- File.join(app_full_path, 'cookbooks')
159
- end
160
-
161
- def cookbook_name
162
- app_name
163
- end
164
-
165
- def app_full_path
166
- File.expand_path(app_name_or_path, Dir.pwd)
167
- end
168
-
169
- def read_and_validate_params
170
- arguments = parse_options(params)
171
- @app_name_or_path = arguments[0]
172
- @params_valid = false unless @app_name_or_path
173
- end
174
-
175
- def params_valid?
176
- @params_valid
177
- end
178
-
179
- end
180
-
181
- # ## CookbookFile
182
- # chef generate cookbook path/to/basename --generator-cookbook=path/to/generator
183
- #
184
- # Generates a basic cookbook directory structure. Most file types are
185
- # omitted, the user is expected to add additional files as needed using
186
- # the relevant generators.
187
- class Cookbook < Base
188
-
189
- banner "Usage: chef generate cookbook NAME [options]"
190
-
191
- attr_reader :errors
192
-
193
- attr_reader :cookbook_name_or_path
194
-
195
- options.merge!(SharedGeneratorOptions.options)
196
-
197
- def initialize(params)
198
- @params_valid = true
199
- @cookbook_name = nil
200
- super
201
- end
202
-
203
- def run
204
- read_and_validate_params
205
- if params_valid?
206
- setup_context
207
- chef_runner.converge
208
- else
209
- msg(banner)
210
- 1
211
- end
212
- end
213
-
214
- def setup_context
215
- super
216
- generator_context.skip_git_init = cookbook_path_in_git_repo?
217
- generator_context.cookbook_root = cookbook_root
218
- generator_context.cookbook_name = cookbook_name
219
- end
220
-
221
- def recipe
222
- "cookbook"
223
- end
224
-
225
- def cookbook_name
226
- File.basename(cookbook_full_path)
227
- end
228
-
229
- def cookbook_root
230
- File.dirname(cookbook_full_path)
231
- end
232
-
233
- def cookbook_full_path
234
- File.expand_path(cookbook_name_or_path, Dir.pwd)
235
- end
236
-
237
- def read_and_validate_params
238
- arguments = parse_options(params)
239
- @cookbook_name_or_path = arguments[0]
240
- @params_valid = false unless @cookbook_name_or_path
241
- end
242
-
243
- def params_valid?
244
- @params_valid
245
- end
246
-
247
- def cookbook_path_in_git_repo?
248
- Pathname.new(cookbook_full_path).ascend do |dir|
249
- return true if File.directory?(File.join(dir.to_s, ".git"))
250
- end
251
- false
252
- end
253
-
254
- end
255
-
256
- # ## CookbookCodeFile
257
- # A base class for generators that add individual files to existing
258
- # cookbooks.
259
- class CookbookCodeFile < Base
260
-
261
- attr_reader :errors
262
- attr_reader :cookbook_path
263
- attr_reader :new_file_basename
264
-
265
- options.merge!(SharedGeneratorOptions.options)
266
-
267
- def initialize(params)
268
- @params_valid = true
269
- @cookbook_full_path = nil
270
- @new_file_basename = nil
271
- @errors = []
272
- super
273
- end
274
-
275
- def run
276
- read_and_validate_params
277
- if params_valid?
278
- setup_context
279
- chef_runner.converge
280
- else
281
- errors.each {|error| err("Error: #{error}") }
282
- parse_options
283
- msg(opt_parser)
284
- 1
285
- end
286
- end
287
-
288
- def setup_context
289
- super
290
- generator_context.cookbook_root = cookbook_root
291
- generator_context.cookbook_name = cookbook_name
292
- generator_context.new_file_basename = new_file_basename
293
- end
294
-
295
- def cookbook_root
296
- File.dirname(cookbook_path)
297
- end
298
-
299
- def cookbook_name
300
- File.basename(cookbook_path)
301
- end
302
-
303
- def read_and_validate_params
304
- arguments = parse_options(params)
305
- case arguments.size
306
- when 1
307
- @new_file_basename = arguments[0]
308
- @cookbook_path = Dir.pwd
309
- validate_cookbook_path
310
- when 2
311
- @cookbook_path = arguments[0]
312
- @new_file_basename = arguments[1]
313
- else
314
- @params_valid = false
315
- end
316
- end
317
-
318
- def validate_cookbook_path
319
- unless File.directory?(File.join(cookbook_path, "recipes"))
320
- @errors << "Directory #{cookbook_path} is not a cookbook"
321
- @params_valid = false
322
- end
323
- end
324
-
325
- def params_valid?
326
- @params_valid
327
- end
328
- end
329
-
330
- # chef generate recipe [path/to/cookbook/root] name
331
- class Recipe < CookbookCodeFile
332
-
333
- banner "Usage: chef generate recipe [path/to/cookbook] NAME [options]"
334
-
335
- options.merge!(SharedGeneratorOptions.options)
336
-
337
- def recipe
338
- 'recipe'
339
- end
340
-
341
- end
342
-
343
- # chef generate attribute [path/to/cookbook_root] NAME
344
- class Attribute < CookbookCodeFile
345
-
346
- banner "Usage: chef generate attribute [path/to/cookbook] NAME [options]"
347
-
348
- options.merge!(SharedGeneratorOptions.options)
349
-
350
- def recipe
351
- 'attribute'
352
- end
353
-
354
- end
355
-
356
- # chef generate lwrp [path/to/cookbook_root] NAME
357
- class LWRP < CookbookCodeFile
358
-
359
- banner "Usage: chef generate lwrp [path/to/cookbook] NAME [options]"
360
-
361
- options.merge!(SharedGeneratorOptions.options)
362
-
363
- def recipe
364
- 'lwrp'
365
- end
366
-
367
- end
368
-
369
- # chef generate template [path/to/cookbook_root] name --source=source_file
370
- class Template < CookbookCodeFile
371
-
372
- option :source,
373
- :short => "-s SOURCE_FILE",
374
- :long => "--source SOURCE_FILE",
375
- :description => "Copy content from SOURCE_FILE"
376
-
377
- banner "Usage: chef generate template [path/to/cookbook] NAME [options]"
378
-
379
- options.merge!(SharedGeneratorOptions.options)
380
-
381
- def recipe
382
- 'template'
383
- end
384
-
385
- def setup_context
386
- super
387
- generator_context.content_source = config[:source]
388
- end
389
-
390
- end
391
-
392
- # chef generate file [path/to/cookbook_root] name --source=source_file
393
- class CookbookFile < CookbookCodeFile
394
- option :source,
395
- :short => "-s SOURCE_FILE",
396
- :long => "--source SOURCE_FILE",
397
- :description => "Copy content from SOURCE_FILE"
398
-
399
- banner "Usage: chef generate file [path/to/cookbook] NAME [options]"
400
-
401
- options.merge!(SharedGeneratorOptions.options)
402
-
403
- def recipe
404
- 'cookbook_file'
405
- end
406
-
407
- def setup_context
408
- super
409
- generator_context.content_source = config[:source]
410
- end
411
- end
412
-
413
70
  end
414
-
415
-
416
71
  end
417
72
  end