chef-dk 4.5.0 → 4.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +39 -47
- data/Gemfile.lock +456 -463
- data/Rakefile +0 -16
- data/lib/chef-dk/command/verify.rb +7 -48
- data/lib/chef-dk/policyfile/uploader.rb +2 -2
- data/lib/chef-dk/policyfile_services/rm_policy.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/README.md +1 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/build_cookbook.rb +2 -2
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +1 -1
- data/lib/chef-dk/version.rb +1 -1
- data/spec/unit/command/generator_commands/cookbook_spec.rb +1 -1
- data/spec/unit/command/verify_spec.rb +2 -3
- data/spec/unit/policyfile/uploader_spec.rb +2 -2
- data/spec/unit/policyfile_services/clean_policies_spec.rb +2 -0
- data/spec/unit/service_exception_inspectors/http_spec.rb +1 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -58,20 +58,4 @@ namespace :style do
|
|
58
58
|
rescue LoadError => e
|
59
59
|
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"]
|
60
60
|
end
|
61
|
-
|
62
|
-
begin
|
63
|
-
require "foodcritic"
|
64
|
-
|
65
|
-
desc "Run Chef Cookbook (Foodcritic) style checks"
|
66
|
-
FoodCritic::Rake::LintTask.new(:foodcritic) do |t|
|
67
|
-
t.options = {
|
68
|
-
fail_tags: ["any"],
|
69
|
-
tags: ["~FC071", "~supermarket", "~FC031"],
|
70
|
-
cookbook_paths: ["lib/chef-dk/skeletons/code_generator"],
|
71
|
-
progress: true,
|
72
|
-
}
|
73
|
-
end
|
74
|
-
rescue LoadError => e
|
75
|
-
puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"]
|
76
|
-
end
|
77
61
|
end
|
@@ -118,43 +118,6 @@ module ChefDK
|
|
118
118
|
c.smoke_test { run_in_tmpdir("kitchen init --create-gemfile") }
|
119
119
|
end
|
120
120
|
|
121
|
-
add_component "tk-policyfile-provisioner" do |c|
|
122
|
-
|
123
|
-
c.gem_base_dir = "chef-dk"
|
124
|
-
|
125
|
-
c.smoke_test do
|
126
|
-
tmpdir do |cwd|
|
127
|
-
File.open(File.join(cwd, "kitchen.yml"), "w+") do |f|
|
128
|
-
f.print(<<~KITCHEN_YML)
|
129
|
-
---
|
130
|
-
driver:
|
131
|
-
name: dummy
|
132
|
-
network:
|
133
|
-
- ["forwarded_port", {guest: 80, host: 8080}]
|
134
|
-
|
135
|
-
provisioner:
|
136
|
-
name: policyfile_zero
|
137
|
-
require_chef_omnibus: 12.3.0
|
138
|
-
|
139
|
-
platforms:
|
140
|
-
- name: ubuntu-14.04
|
141
|
-
|
142
|
-
suites:
|
143
|
-
- name: default
|
144
|
-
run_list:
|
145
|
-
- recipe[aar::default]
|
146
|
-
attributes:
|
147
|
-
|
148
|
-
KITCHEN_YML
|
149
|
-
end
|
150
|
-
|
151
|
-
sh("kitchen list", cwd: cwd)
|
152
|
-
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
end
|
157
|
-
|
158
121
|
add_component "chef-client" do |c|
|
159
122
|
c.gem_base_dir = "chef"
|
160
123
|
c.unit_test do
|
@@ -185,20 +148,16 @@ module ChefDK
|
|
185
148
|
end
|
186
149
|
end
|
187
150
|
|
188
|
-
add_component "chef-apply" do |c|
|
189
|
-
c.gem_base_dir = "chef-apply"
|
190
|
-
# c.unit_test do
|
191
|
-
# bundle_install_mutex.synchronize { sh("#{embedded_bin("bundle")} install") }
|
192
|
-
# sh("#{embedded_bin("bundle")} exec rspec")
|
193
|
-
# end
|
194
|
-
c.smoke_test { sh("#{bin("chef-run")} -v") }
|
195
|
-
end
|
196
|
-
|
197
151
|
add_component "foodcritic" do |c|
|
198
152
|
c.gem_base_dir = "foodcritic"
|
199
153
|
c.smoke_test { sh("#{embedded_bin("foodcritic --list")}") } # foodcritic -v exits with 2 so use --list which exits 0
|
200
154
|
end
|
201
155
|
|
156
|
+
add_component "cookstyle" do |c|
|
157
|
+
c.gem_base_dir = "cookstyle"
|
158
|
+
c.smoke_test { sh("#{embedded_bin("cookstyle -v")}") }
|
159
|
+
end
|
160
|
+
|
202
161
|
add_component "chefspec" do |c|
|
203
162
|
c.gem_base_dir = "chefspec"
|
204
163
|
c.unit_test do
|
@@ -417,8 +376,8 @@ module ChefDK
|
|
417
376
|
end
|
418
377
|
|
419
378
|
# We try and use some chef-sugar code to make sure it loads correctly
|
420
|
-
add_component "chef-sugar
|
421
|
-
c.gem_base_dir = "chef-sugar
|
379
|
+
add_component "chef-sugar" do |c|
|
380
|
+
c.gem_base_dir = "chef-sugar"
|
422
381
|
c.smoke_test do
|
423
382
|
tmpdir do |cwd|
|
424
383
|
with_file(File.join(cwd, "foo.rb")) do |f|
|
@@ -79,7 +79,7 @@ module ChefDK
|
|
79
79
|
|
80
80
|
def data_bag_create
|
81
81
|
http_client.post("data", { "name" => COMPAT_MODE_DATA_BAG_NAME })
|
82
|
-
rescue Net::
|
82
|
+
rescue Net::HTTPClientException => e
|
83
83
|
raise e unless e.response.code == "409"
|
84
84
|
end
|
85
85
|
|
@@ -214,7 +214,7 @@ module ChefDK
|
|
214
214
|
|
215
215
|
def upload_lockfile_as_data_bag_item(policy_id, data_item)
|
216
216
|
http_client.put("data/#{COMPAT_MODE_DATA_BAG_NAME}/#{policy_id}", data_item)
|
217
|
-
rescue Net::
|
217
|
+
rescue Net::HTTPClientException => e
|
218
218
|
raise e unless e.response.code == "404"
|
219
219
|
|
220
220
|
http_client.post("data/#{COMPAT_MODE_DATA_BAG_NAME}", data_item)
|
@@ -134,7 +134,7 @@ module ChefDK
|
|
134
134
|
def fetch_policy_revision_data
|
135
135
|
@policy_revision_data = http_client.get("/policies/#{policy_name}")
|
136
136
|
@policy_exists = true
|
137
|
-
rescue Net::
|
137
|
+
rescue Net::HTTPClientException => e
|
138
138
|
raise unless e.response.code == "404"
|
139
139
|
|
140
140
|
@policy_exists = false
|
@@ -129,7 +129,7 @@ delivery review
|
|
129
129
|
|
130
130
|
## FAQ
|
131
131
|
|
132
|
-
### Why don't I just run rspec and
|
132
|
+
### Why don't I just run rspec and cookstyle/chefspec on my local system?
|
133
133
|
|
134
134
|
An objection to the Test Kitchen approach is that it is much faster to run the unit, lint, and syntax commands for the project on the local system. That is totally true, and also totally valid. Do that for the really fast feedback loop. However, the dance we do with Test Kitchen brings a much higher degree of confidence in the changes we're making, that everything will run on the build nodes in Chef Workflow. We strongly encourage this approach before actually pushing the changes to Workflow.
|
135
135
|
|
@@ -11,13 +11,13 @@ directory dot_delivery_dir
|
|
11
11
|
|
12
12
|
cookbook_file config_json do
|
13
13
|
source 'delivery-config.json'
|
14
|
-
not_if { File.exist?(config_json) }
|
14
|
+
not_if { ::File.exist?(config_json) }
|
15
15
|
end
|
16
16
|
|
17
17
|
# Adding the delivery local-mode config
|
18
18
|
cookbook_file project_toml do
|
19
19
|
source 'delivery-project.toml'
|
20
|
-
not_if { File.exist?(project_toml) }
|
20
|
+
not_if { ::File.exist?(project_toml) }
|
21
21
|
end
|
22
22
|
|
23
23
|
generator_desc('Ensuring correct Workflow (Delivery) build cookbook content')
|
@@ -129,7 +129,7 @@ unless context.enable_workflow
|
|
129
129
|
# Adding the delivery local-mode config
|
130
130
|
cookbook_file "#{cookbook_dir}/.delivery/project.toml" do
|
131
131
|
source 'delivery-project.toml'
|
132
|
-
not_if { File.exist?("#{cookbook_dir}/.delivery/project.toml") }
|
132
|
+
not_if { ::File.exist?("#{cookbook_dir}/.delivery/project.toml") }
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
data/lib/chef-dk/version.rb
CHANGED
@@ -271,7 +271,7 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
|
|
271
271
|
# Cookbook:: build_cookbook
|
272
272
|
# Recipe:: publish
|
273
273
|
#
|
274
|
-
# Copyright::
|
274
|
+
# Copyright:: 2020, The Authors, All Rights Reserved.
|
275
275
|
|
276
276
|
include_recipe 'delivery-truck::publish'
|
277
277
|
CONFIG_DOT_JSON
|
@@ -38,12 +38,12 @@ describe ChefDK::Command::Verify do
|
|
38
38
|
let(:default_components) do
|
39
39
|
[
|
40
40
|
"berkshelf",
|
41
|
-
"chef-apply",
|
42
41
|
"chef-client",
|
43
42
|
"chef-dk",
|
44
|
-
"chef-sugar
|
43
|
+
"chef-sugar",
|
45
44
|
"chef-vault",
|
46
45
|
"chefspec",
|
46
|
+
"cookstyle",
|
47
47
|
"delivery-cli",
|
48
48
|
"fauxhai",
|
49
49
|
"foodcritic",
|
@@ -55,7 +55,6 @@ describe ChefDK::Command::Verify do
|
|
55
55
|
"opscode-pushy-client",
|
56
56
|
"package installation",
|
57
57
|
"test-kitchen",
|
58
|
-
"tk-policyfile-provisioner",
|
59
58
|
]
|
60
59
|
end
|
61
60
|
|
@@ -319,14 +319,14 @@ describe ChefDK::Policyfile::Uploader do
|
|
319
319
|
|
320
320
|
it "does not error when the 'policyfiles' data bag exists" do
|
321
321
|
response = double("Net::HTTP response", code: "409")
|
322
|
-
error = Net::
|
322
|
+
error = Net::HTTPClientException .new("conflict", response)
|
323
323
|
expect(http_client).to receive(:post).with("data", { "name" => "policyfiles" }).and_raise(error)
|
324
324
|
expect { uploader.data_bag_create }.to_not raise_error
|
325
325
|
end
|
326
326
|
|
327
327
|
it "uploads the policyfile as a data bag item" do
|
328
328
|
response = double("Net::HTTP response", code: "404")
|
329
|
-
error = Net::
|
329
|
+
error = Net::HTTPClientException .new("Not Found", response)
|
330
330
|
expect(http_client).to receive(:put)
|
331
331
|
.with("data/policyfiles/example-unit-test", policyfile_as_data_bag_item)
|
332
332
|
.and_raise(error)
|
@@ -211,6 +211,8 @@ describe ChefDK::PolicyfileServices::CleanPolicies do
|
|
211
211
|
end
|
212
212
|
|
213
213
|
it "deletes what it can, then raises an error" do
|
214
|
+
# Ruby 2.6 deprecated HTTPServerException but the errors are still initialized using it, so
|
215
|
+
# this will continue to print that out until they remove HTTPServerException
|
214
216
|
expected_message = <<~ERROR
|
215
217
|
Failed to delete some policy revisions:
|
216
218
|
- appserver (4444444444444444444444444444444444444444444444444444444444444444): Net::HTTPServerException 403 \"Unauthorized\"
|
@@ -64,7 +64,7 @@ describe ChefDK::ServiceExceptionInspectors::HTTP do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
let(:exception) do
|
67
|
-
Net::
|
67
|
+
Net::HTTPClientException .new(message, response).tap { |e| e.chef_rest_request = request }
|
68
68
|
end
|
69
69
|
|
70
70
|
subject(:inspector) { described_class.new(exception) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-dk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel DeLeo
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-09-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mixlib-cli
|