chef-dk 1.6.11 → 2.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +25 -38
- data/Gemfile.lock +199 -199
- data/README.md +4 -2
- data/Rakefile +1 -2
- data/acceptance/Gemfile +1 -1
- data/acceptance/Gemfile.lock +23 -21
- data/chef-dk.gemspec +4 -6
- data/lib/chef-dk/builtin_commands.rb +1 -1
- data/lib/chef-dk/chef_runner.rb +1 -1
- data/lib/chef-dk/cli.rb +1 -0
- data/lib/chef-dk/command/generate.rb +5 -2
- data/lib/chef-dk/command/generator_commands/helpers.rb +36 -0
- data/lib/chef-dk/command/generator_commands/{lwrp.rb → resource.rb} +4 -4
- data/lib/chef-dk/command/update.rb +11 -18
- data/lib/chef-dk/command/verify.rb +1 -16
- data/lib/chef-dk/commands_map.rb +3 -3
- data/lib/chef-dk/policyfile/artifactory_cookbook_source.rb +102 -0
- data/lib/chef-dk/policyfile/cookbook_location_specification.rb +2 -2
- data/lib/chef-dk/policyfile/cookbook_sources.rb +1 -0
- data/lib/chef-dk/policyfile/dsl.rb +10 -0
- data/lib/chef-dk/policyfile/solution_dependencies.rb +15 -1
- data/lib/chef-dk/policyfile_lock.rb +1 -1
- data/lib/chef-dk/policyfile_services/install.rb +30 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/Berksfile +1 -0
- 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/cookbook_readmes/README.md +2 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/delivery-config.json +3 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/delivery-project.toml +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +2 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/spec_helper.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/spec_helper_policyfile.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/metadata.rb +3 -2
- data/lib/chef-dk/skeletons/code_generator/recipes/app.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/attribute.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/build_cookbook.rb +7 -12
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook_file.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/helpers.rb +21 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/policyfile.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/recipe.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/{lwrp.rb → resource.rb} +1 -11
- data/lib/chef-dk/skeletons/code_generator/recipes/template.rb +3 -3
- data/lib/chef-dk/skeletons/code_generator/templates/default/helpers.rb.erb +39 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/resource.rb.erb +1 -0
- data/lib/chef-dk/version.rb +2 -2
- data/omnibus_overrides.rb +14 -12
- data/spec/unit/command/generator_commands/cookbook_spec.rb +7 -1
- data/spec/unit/command/generator_commands/helpers_spec.rb +31 -0
- data/spec/unit/command/generator_commands/{lwrp_spec.rb → resource_spec.rb} +5 -5
- data/spec/unit/command/install_spec.rb +2 -2
- data/spec/unit/command/update_spec.rb +11 -3
- data/spec/unit/command/verify_spec.rb +2 -1
- data/spec/unit/policyfile/artifactory_cookbook_source_spec.rb +59 -0
- data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +1 -1
- data/spec/unit/policyfile/solution_dependencies_spec.rb +25 -0
- data/spec/unit/policyfile_demands_spec.rb +2 -1
- data/spec/unit/policyfile_lock_build_spec.rb +23 -21
- data/spec/unit/policyfile_lock_install_spec.rb +2 -2
- data/spec/unit/policyfile_lock_validation_spec.rb +3 -3
- data/spec/unit/policyfile_services/export_repo_spec.rb +6 -6
- data/spec/unit/policyfile_services/install_spec.rb +1 -1
- data/spec/unit/policyfile_services/update_spec.rb +143 -0
- data/tasks/announce.rb +3 -2
- data/tasks/dependencies.rb +35 -111
- data/tasks/github_changelog_generator.rb +0 -3
- data/tasks/templates/prerelease.md.erb +1 -1
- data/tasks/templates/release.md.erb +1 -1
- metadata +20 -38
- data/lib/chef-dk/skeletons/code_generator/templates/default/provider.rb.erb +0 -0
- data/spec/unit/gemfile_util_spec.rb +0 -41
- data/spec/unit/helpers_spec.rb +0 -120
- data/spec/unit/tasks/helpers_spec.rb +0 -75
- data/tasks/bin/bundle-platform +0 -19
- data/tasks/bin/create-override-gemfile +0 -110
- data/tasks/bundle.rb +0 -96
- data/tasks/bundle_util.rb +0 -110
- data/tasks/gemfile_util.rb +0 -435
- data/tasks/helpers.rb +0 -47
- data/version_policy.rb +0 -142
data/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Chef Development Kit (ChefDK) brings Chef and the development tools developed by
|
|
|
11
11
|
* [Test Kitchen][]
|
|
12
12
|
* [ChefSpec][]
|
|
13
13
|
* [Foodcritic][]
|
|
14
|
+
* [Cookstyle][]
|
|
14
15
|
* [Delivery CLI][]
|
|
15
16
|
* [Push Jobs Client][]
|
|
16
17
|
|
|
@@ -22,7 +23,7 @@ are in the omnibus directory in this repository.
|
|
|
22
23
|
|
|
23
24
|
You can get the [latest release of ChefDK from the downloads page][ChefDK].
|
|
24
25
|
|
|
25
|
-
On Mac OS X, you can also use [homebrew-cask](
|
|
26
|
+
On Mac OS X, you can also use [homebrew-cask](https://caskroom.github.io/)
|
|
26
27
|
to `brew cask install chefdk`.
|
|
27
28
|
|
|
28
29
|
Once you install the package, the `chef-client` suite, `berks`,
|
|
@@ -321,9 +322,10 @@ packaging, and building works.
|
|
|
321
322
|
|
|
322
323
|
[Berkshelf]: https://docs.chef.io/berkshelf.html "Berkshelf"
|
|
323
324
|
[Chef]: https://www.chef.io "Chef"
|
|
324
|
-
[ChefDK]: https://downloads.chef.io/
|
|
325
|
+
[ChefDK]: https://downloads.chef.io/chefdk "Chef Development Kit"
|
|
325
326
|
[Chef Documentation]: https://docs.chef.io "Chef Documentation"
|
|
326
327
|
[ChefSpec]: http://sethvargo.github.io/chefspec/ "ChefSpec"
|
|
328
|
+
[Cookstyle]: https://docs.chef.io/cookstyle.html "Cookstyle"
|
|
327
329
|
[Foodcritic]: http://foodcritic.io "Foodcritic"
|
|
328
330
|
[Learn Chef]: https://learn.chef.io "Learn Chef"
|
|
329
331
|
[Test Kitchen]: http://kitchen.ci "Test Kitchen"
|
data/Rakefile
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
|
|
18
18
|
require "bundler/gem_tasks"
|
|
19
19
|
require_relative "tasks/version"
|
|
20
|
-
require_relative "tasks/bundle"
|
|
21
20
|
require_relative "tasks/dependencies"
|
|
22
21
|
require_relative "tasks/github_changelog_generator"
|
|
23
22
|
require_relative "tasks/announce"
|
|
@@ -75,7 +74,7 @@ namespace :style do
|
|
|
75
74
|
FoodCritic::Rake::LintTask.new(:foodcritic) do |t|
|
|
76
75
|
t.options = {
|
|
77
76
|
fail_tags: ["any"],
|
|
78
|
-
tags: ["~FC011", "~
|
|
77
|
+
tags: ["~FC011", "~FC071", "~supermarket"],
|
|
79
78
|
cookbook_paths: ["lib/chef-dk/skeletons/code_generator"],
|
|
80
79
|
progress: true,
|
|
81
80
|
}
|
data/acceptance/Gemfile
CHANGED
data/acceptance/Gemfile.lock
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
GIT
|
|
2
|
-
remote:
|
|
2
|
+
remote: https://github.com/chef/chef-acceptance
|
|
3
3
|
revision: 3877c344098021ac66134e8edb5eb805d14d4643
|
|
4
4
|
specs:
|
|
5
5
|
chef-acceptance (0.2.0)
|
|
@@ -12,15 +12,15 @@ GEM
|
|
|
12
12
|
addressable (2.5.1)
|
|
13
13
|
public_suffix (~> 2.0, >= 2.0.2)
|
|
14
14
|
artifactory (2.8.1)
|
|
15
|
-
aws-sdk (2.9.
|
|
16
|
-
aws-sdk-resources (= 2.9.
|
|
17
|
-
aws-sdk-core (2.9.
|
|
15
|
+
aws-sdk (2.9.25)
|
|
16
|
+
aws-sdk-resources (= 2.9.25)
|
|
17
|
+
aws-sdk-core (2.9.25)
|
|
18
18
|
aws-sigv4 (~> 1.0)
|
|
19
19
|
jmespath (~> 1.0)
|
|
20
|
-
aws-sdk-resources (2.9.
|
|
21
|
-
aws-sdk-core (= 2.9.
|
|
20
|
+
aws-sdk-resources (2.9.25)
|
|
21
|
+
aws-sdk-core (= 2.9.25)
|
|
22
22
|
aws-sigv4 (1.0.0)
|
|
23
|
-
berkshelf (
|
|
23
|
+
berkshelf (6.0.1)
|
|
24
24
|
addressable (~> 2.3, >= 2.3.4)
|
|
25
25
|
berkshelf-api-client (>= 2.0.2, < 4.0)
|
|
26
26
|
buff-config (~> 2.0)
|
|
@@ -55,7 +55,7 @@ GEM
|
|
|
55
55
|
celluloid-io (0.16.2)
|
|
56
56
|
celluloid (>= 0.16.0)
|
|
57
57
|
nio4r (>= 1.1.0)
|
|
58
|
-
chef-config (
|
|
58
|
+
chef-config (13.0.118)
|
|
59
59
|
addressable
|
|
60
60
|
fuzzyurl
|
|
61
61
|
mixlib-config (~> 2.0)
|
|
@@ -63,7 +63,7 @@ GEM
|
|
|
63
63
|
cleanroom (1.0.0)
|
|
64
64
|
coderay (1.1.1)
|
|
65
65
|
diff-lcs (1.3)
|
|
66
|
-
docker-api (1.33.
|
|
66
|
+
docker-api (1.33.4)
|
|
67
67
|
excon (>= 0.38.0)
|
|
68
68
|
json
|
|
69
69
|
erubis (2.7.0)
|
|
@@ -77,9 +77,9 @@ GEM
|
|
|
77
77
|
gyoku (1.3.1)
|
|
78
78
|
builder (>= 2.1.2)
|
|
79
79
|
hashie (3.5.5)
|
|
80
|
-
hitimes (1.2.
|
|
80
|
+
hitimes (1.2.5)
|
|
81
81
|
httpclient (2.8.3)
|
|
82
|
-
inspec (1.
|
|
82
|
+
inspec (1.25.1)
|
|
83
83
|
addressable (~> 2.4)
|
|
84
84
|
faraday (>= 0.9.0)
|
|
85
85
|
hashie (~> 3.4)
|
|
@@ -87,31 +87,33 @@ GEM
|
|
|
87
87
|
method_source (~> 0.8)
|
|
88
88
|
mixlib-log
|
|
89
89
|
parallel (~> 1.9)
|
|
90
|
+
parslet (~> 1.5)
|
|
90
91
|
pry (~> 0)
|
|
91
92
|
rainbow (~> 2)
|
|
92
93
|
rspec (~> 3)
|
|
93
94
|
rspec-its (~> 1.2)
|
|
94
95
|
rubyzip (~> 1.1)
|
|
95
|
-
|
|
96
|
+
semverse
|
|
97
|
+
sslshake (~> 1.2)
|
|
96
98
|
thor (~> 0.19)
|
|
97
99
|
toml (~> 0.1)
|
|
98
100
|
train (>= 0.22.0, < 1.0)
|
|
99
101
|
jmespath (1.3.1)
|
|
100
|
-
json (2.0
|
|
102
|
+
json (2.1.0)
|
|
101
103
|
kitchen-ec2 (1.3.2)
|
|
102
104
|
aws-sdk (~> 2)
|
|
103
105
|
excon
|
|
104
106
|
multi_json
|
|
105
107
|
retryable (~> 2.0)
|
|
106
108
|
test-kitchen (~> 1.4, >= 1.4.1)
|
|
107
|
-
kitchen-inspec (0.
|
|
109
|
+
kitchen-inspec (0.19.0)
|
|
108
110
|
hashie (~> 3.4)
|
|
109
111
|
inspec (>= 0.34.0, < 2.0.0)
|
|
110
112
|
test-kitchen (~> 1.6)
|
|
111
113
|
kitchen-vagrant (1.1.0)
|
|
112
114
|
test-kitchen (~> 1.4)
|
|
113
115
|
little-plugger (1.1.4)
|
|
114
|
-
logging (2.2.
|
|
116
|
+
logging (2.2.2)
|
|
115
117
|
little-plugger (~> 1.1)
|
|
116
118
|
multi_json (~> 1.10)
|
|
117
119
|
method_source (0.8.2)
|
|
@@ -138,9 +140,9 @@ GEM
|
|
|
138
140
|
net-ssh (>= 2.6.5)
|
|
139
141
|
nio4r (2.0.0)
|
|
140
142
|
nori (2.6.0)
|
|
141
|
-
octokit (4.
|
|
143
|
+
octokit (4.7.0)
|
|
142
144
|
sawyer (~> 0.8.0, >= 0.5.3)
|
|
143
|
-
parallel (1.11.
|
|
145
|
+
parallel (1.11.2)
|
|
144
146
|
parslet (1.5.0)
|
|
145
147
|
blankslate (~> 2.0)
|
|
146
148
|
pry (0.10.4)
|
|
@@ -184,7 +186,7 @@ GEM
|
|
|
184
186
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
185
187
|
rspec-support (~> 3.4.0)
|
|
186
188
|
rspec-support (3.4.1)
|
|
187
|
-
rubyntlm (0.6.
|
|
189
|
+
rubyntlm (0.6.2)
|
|
188
190
|
rubyzip (1.2.1)
|
|
189
191
|
safe_yaml (1.0.4)
|
|
190
192
|
sawyer (0.8.1)
|
|
@@ -195,7 +197,7 @@ GEM
|
|
|
195
197
|
solve (3.1.0)
|
|
196
198
|
molinillo (>= 0.5)
|
|
197
199
|
semverse (>= 1.1, < 3.0)
|
|
198
|
-
sslshake (1.
|
|
200
|
+
sslshake (1.2.0)
|
|
199
201
|
test-kitchen (1.16.0)
|
|
200
202
|
mixlib-install (>= 1.2, < 3.0)
|
|
201
203
|
mixlib-shellout (>= 1.2, < 3.0)
|
|
@@ -222,7 +224,7 @@ GEM
|
|
|
222
224
|
hashie (>= 2.0.2, < 4.0.0)
|
|
223
225
|
windows_chef_zero (2.0.0)
|
|
224
226
|
test-kitchen (>= 1.2.1)
|
|
225
|
-
winrm (2.2.
|
|
227
|
+
winrm (2.2.3)
|
|
226
228
|
builder (>= 2.1.2)
|
|
227
229
|
erubis (~> 2.7)
|
|
228
230
|
gssapi (~> 1.2)
|
|
@@ -258,4 +260,4 @@ DEPENDENCIES
|
|
|
258
260
|
winrm-fs
|
|
259
261
|
|
|
260
262
|
BUNDLED WITH
|
|
261
|
-
1.
|
|
263
|
+
1.15.0
|
data/chef-dk.gemspec
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: Copyright (c) 2014 Chef Software Inc.
|
|
2
|
+
# Copyright:: Copyright (c) 2014-2017, Chef Software Inc.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -28,10 +28,10 @@ Gem::Specification.new do |gem|
|
|
|
28
28
|
gem.summary = gem.description
|
|
29
29
|
gem.homepage = "https://www.chef.io/"
|
|
30
30
|
|
|
31
|
-
gem.required_ruby_version = ">= 2.
|
|
31
|
+
gem.required_ruby_version = ">= 2.3"
|
|
32
32
|
|
|
33
33
|
gem.files = %w{Rakefile LICENSE README.md warning.txt} +
|
|
34
|
-
%w{
|
|
34
|
+
%w{omnibus_overrides.rb} +
|
|
35
35
|
Dir.glob("Gemfile*") + # Includes Gemfile and locks
|
|
36
36
|
Dir.glob("*.gemspec") +
|
|
37
37
|
Dir.glob("{lib,spec,acceptance,tasks}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
|
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
|
|
|
43
43
|
gem.add_dependency "mixlib-shellout", "~> 2.0"
|
|
44
44
|
gem.add_dependency "ffi-yajl", ">= 1.0", "< 3.0"
|
|
45
45
|
gem.add_dependency "minitar", "~> 0.5.4"
|
|
46
|
-
gem.add_dependency "chef", "~>
|
|
46
|
+
gem.add_dependency "chef", "~> 13.0"
|
|
47
47
|
gem.add_dependency "solve", "< 4.0", "> 2.0"
|
|
48
48
|
gem.add_dependency "addressable", ">= 2.3.5", "< 2.6"
|
|
49
49
|
gem.add_dependency "cookbook-omnifetch", "~> 0.5"
|
|
@@ -51,8 +51,6 @@ Gem::Specification.new do |gem|
|
|
|
51
51
|
gem.add_dependency "paint", "~> 1.0"
|
|
52
52
|
gem.add_dependency "chef-provisioning", "~> 2.0"
|
|
53
53
|
|
|
54
|
-
gem.add_development_dependency "rake"
|
|
55
|
-
|
|
56
54
|
%w{rspec-core rspec-expectations rspec-mocks}.each do |dev_gem|
|
|
57
55
|
gem.add_development_dependency dev_gem, "~> 3.0"
|
|
58
56
|
end
|
|
@@ -55,5 +55,5 @@ ChefDK.commands do |c|
|
|
|
55
55
|
|
|
56
56
|
c.builtin "undelete", :Undelete, desc: "Undo a delete command"
|
|
57
57
|
|
|
58
|
-
c.builtin "verify", :Verify, desc: "Test the embedded ChefDK applications"
|
|
58
|
+
c.builtin "verify", :Verify, desc: "Test the embedded ChefDK applications", hidden: true
|
|
59
59
|
end
|
data/lib/chef-dk/chef_runner.rb
CHANGED
|
@@ -45,7 +45,7 @@ module ChefDK
|
|
|
45
45
|
message = "Could not find cookbook(s) to satisfy run list #{run_list.inspect} in #{cookbook_path}"
|
|
46
46
|
raise CookbookNotFound.new(message, e)
|
|
47
47
|
rescue => e
|
|
48
|
-
raise ChefConvergeError.new("Chef failed to converge: #{e}", e)
|
|
48
|
+
raise ChefConvergeError.new("Chef failed to converge: #{e} from file #{e.backtrace.first}", e)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def run_context
|
data/lib/chef-dk/cli.rb
CHANGED
|
@@ -23,7 +23,8 @@ require "chef-dk/command/generator_commands/cookbook"
|
|
|
23
23
|
require "chef-dk/command/generator_commands/app"
|
|
24
24
|
require "chef-dk/command/generator_commands/attribute"
|
|
25
25
|
require "chef-dk/command/generator_commands/cookbook_file"
|
|
26
|
-
require
|
|
26
|
+
require 'chef-dk/command/generator_commands/helpers'
|
|
27
|
+
require "chef-dk/command/generator_commands/resource"
|
|
27
28
|
require "chef-dk/command/generator_commands/recipe"
|
|
28
29
|
require "chef-dk/command/generator_commands/template"
|
|
29
30
|
require "chef-dk/command/generator_commands/repo"
|
|
@@ -51,7 +52,9 @@ module ChefDK
|
|
|
51
52
|
generator(:attribute, :Attribute, "Generate an attributes file")
|
|
52
53
|
generator(:template, :Template, "Generate a file template")
|
|
53
54
|
generator(:file, :CookbookFile, "Generate a cookbook file")
|
|
54
|
-
generator(:
|
|
55
|
+
generator(:helpers, :Helpers, "Generate a cookbook helper file in libraries")
|
|
56
|
+
generator(:lwrp, :Resource, "Generate a custom resource")
|
|
57
|
+
generator(:resource, :Resource, "Generate a custom resource")
|
|
55
58
|
generator(:repo, :Repo, "Generate a Chef code repository")
|
|
56
59
|
generator(:policyfile, :Policyfile, "Generate a Policyfile for use with the install/push commands")
|
|
57
60
|
generator(:generator, :GeneratorGenerator, "Copy ChefDK's generator cookbook so you can customize it")
|
|
@@ -0,0 +1,36 @@
|
|
|
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-dk/command/generator_commands/cookbook_code_file'
|
|
19
|
+
|
|
20
|
+
module ChefDK
|
|
21
|
+
module Command
|
|
22
|
+
module GeneratorCommands
|
|
23
|
+
# chef generate helpers [path/to/cookbook_root] NAME
|
|
24
|
+
class Helpers < CookbookCodeFile
|
|
25
|
+
|
|
26
|
+
banner "Usage: chef generate helpers [path/to/cookbook] NAME [options]"
|
|
27
|
+
|
|
28
|
+
options.merge!(SharedGeneratorOptions.options)
|
|
29
|
+
|
|
30
|
+
def recipe
|
|
31
|
+
'helpers'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -20,15 +20,15 @@ require "chef-dk/command/generator_commands/cookbook_code_file"
|
|
|
20
20
|
module ChefDK
|
|
21
21
|
module Command
|
|
22
22
|
module GeneratorCommands
|
|
23
|
-
# chef generate
|
|
24
|
-
class
|
|
23
|
+
# chef generate resource [path/to/cookbook_root] NAME
|
|
24
|
+
class Resource < CookbookCodeFile
|
|
25
25
|
|
|
26
|
-
banner "Usage: chef generate
|
|
26
|
+
banner "Usage: chef generate resource [path/to/cookbook] NAME [options]"
|
|
27
27
|
|
|
28
28
|
options.merge!(SharedGeneratorOptions.options)
|
|
29
29
|
|
|
30
30
|
def recipe
|
|
31
|
-
"
|
|
31
|
+
"resource"
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
|
@@ -60,10 +60,10 @@ BANNER
|
|
|
60
60
|
default: false,
|
|
61
61
|
boolean: true
|
|
62
62
|
|
|
63
|
-
option :
|
|
63
|
+
option :update_attributes_only,
|
|
64
64
|
short: "-a",
|
|
65
65
|
long: "--attributes",
|
|
66
|
-
description: "
|
|
66
|
+
description: "Only update attributes (not cookbooks)",
|
|
67
67
|
default: false,
|
|
68
68
|
boolean: true
|
|
69
69
|
|
|
@@ -78,6 +78,7 @@ BANNER
|
|
|
78
78
|
@policyfile_relative_path = nil
|
|
79
79
|
@installer = nil
|
|
80
80
|
@attributes_updater = nil
|
|
81
|
+
@cookbooks_to_update = []
|
|
81
82
|
end
|
|
82
83
|
|
|
83
84
|
def run(params = [])
|
|
@@ -89,11 +90,8 @@ BANNER
|
|
|
89
90
|
# ssl_verify_mode)
|
|
90
91
|
chef_config
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
else
|
|
95
|
-
installer.run
|
|
96
|
-
end
|
|
93
|
+
attributes_updater.run
|
|
94
|
+
installer.run(@cookbooks_to_update) unless update_attributes_only?
|
|
97
95
|
0
|
|
98
96
|
rescue PolicyfileServiceError => e
|
|
99
97
|
handle_error(e)
|
|
@@ -101,7 +99,7 @@ BANNER
|
|
|
101
99
|
end
|
|
102
100
|
|
|
103
101
|
def installer
|
|
104
|
-
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd, overwrite: true)
|
|
102
|
+
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd, config: chef_config, overwrite: true)
|
|
105
103
|
end
|
|
106
104
|
|
|
107
105
|
def attributes_updater
|
|
@@ -117,8 +115,8 @@ BANNER
|
|
|
117
115
|
config[:config_file]
|
|
118
116
|
end
|
|
119
117
|
|
|
120
|
-
def
|
|
121
|
-
!!config[:
|
|
118
|
+
def update_attributes_only?
|
|
119
|
+
!!config[:update_attributes_only]
|
|
122
120
|
end
|
|
123
121
|
|
|
124
122
|
def handle_error(error)
|
|
@@ -133,15 +131,10 @@ BANNER
|
|
|
133
131
|
|
|
134
132
|
def apply_params!(params)
|
|
135
133
|
remaining_args = parse_options(params)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
else
|
|
140
|
-
@policyfile_relative_path = remaining_args.first
|
|
141
|
-
true
|
|
142
|
-
end
|
|
134
|
+
@policyfile_relative_path = remaining_args.shift
|
|
135
|
+
@cookbooks_to_update += remaining_args
|
|
136
|
+
true
|
|
143
137
|
end
|
|
144
|
-
|
|
145
138
|
end
|
|
146
139
|
end
|
|
147
140
|
end
|
|
@@ -324,22 +324,6 @@ require 'spec_helper'
|
|
|
324
324
|
end
|
|
325
325
|
end
|
|
326
326
|
|
|
327
|
-
add_component "rubocop" do |c|
|
|
328
|
-
c.gem_base_dir = "rubocop"
|
|
329
|
-
c.smoke_test do
|
|
330
|
-
tmpdir do |cwd|
|
|
331
|
-
with_file(File.join(cwd, "foo.rb")) do |f|
|
|
332
|
-
f.write <<-EOF
|
|
333
|
-
def foo
|
|
334
|
-
puts 'foo'
|
|
335
|
-
end
|
|
336
|
-
EOF
|
|
337
|
-
end
|
|
338
|
-
sh("#{bin("rubocop")} foo.rb -l", cwd: cwd)
|
|
339
|
-
end
|
|
340
|
-
end
|
|
341
|
-
end
|
|
342
|
-
|
|
343
327
|
add_component "fauxhai" do |c|
|
|
344
328
|
c.gem_base_dir = "fauxhai"
|
|
345
329
|
c.smoke_test { sh("#{embedded_bin("gem")} list fauxhai") }
|
|
@@ -544,6 +528,7 @@ end
|
|
|
544
528
|
end
|
|
545
529
|
|
|
546
530
|
def run(params = [ ])
|
|
531
|
+
err("[WARN] This is an internal command used by the ChefDK development team. If you are a ChefDK user, please do not run it.")
|
|
547
532
|
@components_filter = parse_options(params)
|
|
548
533
|
|
|
549
534
|
validate_components!
|
data/lib/chef-dk/commands_map.rb
CHANGED
|
@@ -54,7 +54,7 @@ module ChefDK
|
|
|
54
54
|
class CommandsMap
|
|
55
55
|
NULL_ARG = Object.new
|
|
56
56
|
|
|
57
|
-
CommandSpec = Struct.new(:name, :constant_name, :require_path, :description)
|
|
57
|
+
CommandSpec = Struct.new(:name, :constant_name, :require_path, :description, :hidden)
|
|
58
58
|
|
|
59
59
|
class CommandSpec
|
|
60
60
|
|
|
@@ -72,12 +72,12 @@ module ChefDK
|
|
|
72
72
|
@command_specs = {}
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
def builtin(name, constant_name, require_path: NULL_ARG, desc: "")
|
|
75
|
+
def builtin(name, constant_name, require_path: NULL_ARG, desc: "", hidden: false)
|
|
76
76
|
if null?(require_path)
|
|
77
77
|
snake_case_path = name.tr("-", "_")
|
|
78
78
|
require_path = "chef-dk/command/#{snake_case_path}"
|
|
79
79
|
end
|
|
80
|
-
command_specs[name] = CommandSpec.new(name, constant_name, require_path, desc)
|
|
80
|
+
command_specs[name] = CommandSpec.new(name, constant_name, require_path, desc, hidden)
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def instantiate(name)
|