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.
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-ng" do |c|
421
- c.gem_base_dir = "chef-sugar-ng"
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::HTTPServerException => e
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::HTTPServerException => e
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::HTTPServerException => e
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 foodcritic/rubocop on my local system?
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
 
@@ -60,7 +60,7 @@ if context.have_git
60
60
  execute('initialize-git') do
61
61
  command('git init .')
62
62
  cwd repo_dir
63
- not_if { File.exist?("#{repo_dir}/.gitignore") }
63
+ not_if { ::File.exist?("#{repo_dir}/.gitignore") }
64
64
  end
65
65
  end
66
66
  template "#{repo_dir}/.gitignore" do
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefDK
19
- VERSION = "4.5.0".freeze
19
+ VERSION = "4.11.0".freeze
20
20
  end
@@ -271,7 +271,7 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
271
271
  # Cookbook:: build_cookbook
272
272
  # Recipe:: publish
273
273
  #
274
- # Copyright:: 2019, The Authors, All Rights Reserved.
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-ng",
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::HTTPServerException.new("conflict", response)
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::HTTPServerException.new("Not Found", response)
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::HTTPServerException.new(message, response).tap { |e| e.chef_rest_request = request }
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.5.0
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: 2019-10-16 00:00:00.000000000 Z
13
+ date: 2020-09-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mixlib-cli