chef-cli 1.0.16 → 3.0.7

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -11
  3. data/bin/{chef → chef-cli} +0 -0
  4. data/chef-cli.gemspec +7 -6
  5. data/lib/chef-cli/cli.rb +12 -6
  6. data/lib/chef-cli/command/clean_policy_cookbooks.rb +1 -1
  7. data/lib/chef-cli/command/clean_policy_revisions.rb +1 -1
  8. data/lib/chef-cli/command/delete_policy.rb +1 -1
  9. data/lib/chef-cli/command/delete_policy_group.rb +1 -1
  10. data/lib/chef-cli/command/describe_cookbook.rb +1 -1
  11. data/lib/chef-cli/command/export.rb +1 -1
  12. data/lib/chef-cli/command/generator_commands/cookbook.rb +1 -1
  13. data/lib/chef-cli/command/generator_commands/policyfile.rb +2 -2
  14. data/lib/chef-cli/command/install.rb +2 -2
  15. data/lib/chef-cli/command/push.rb +1 -1
  16. data/lib/chef-cli/command/push_archive.rb +1 -1
  17. data/lib/chef-cli/command/show_policy.rb +1 -1
  18. data/lib/chef-cli/command/undelete.rb +1 -1
  19. data/lib/chef-cli/command/update.rb +1 -1
  20. data/lib/chef-cli/dist.rb +8 -0
  21. data/lib/chef-cli/generator.rb +1 -1
  22. data/lib/chef-cli/helpers.rb +2 -2
  23. data/lib/chef-cli/policyfile/cookbook_location_specification.rb +2 -1
  24. data/lib/chef-cli/policyfile/lock_fetcher_mixin.rb +2 -2
  25. data/lib/chef-cli/policyfile/uploader.rb +2 -2
  26. data/lib/chef-cli/policyfile_services/export_repo.rb +5 -0
  27. data/lib/chef-cli/policyfile_services/install.rb +2 -0
  28. data/lib/chef-cli/policyfile_services/rm_policy.rb +1 -1
  29. data/lib/chef-cli/policyfile_services/update_attributes.rb +2 -0
  30. data/lib/chef-cli/skeletons/code_generator/files/default/build_cookbook/README.md +3 -3
  31. data/lib/chef-cli/skeletons/code_generator/files/default/build_cookbook/kitchen.yml +2 -2
  32. data/lib/chef-cli/skeletons/code_generator/files/default/chefignore +2 -3
  33. data/lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +1 -1
  34. data/lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README.md +2 -2
  35. data/lib/chef-cli/skeletons/code_generator/files/default/repo/README.md +1 -1
  36. data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +2 -2
  37. data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +1 -1
  38. data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +1 -1
  39. data/lib/chef-cli/skeletons/code_generator/files/default/repo/data_bags/README.md +4 -4
  40. data/lib/chef-cli/skeletons/code_generator/files/default/repo/environments/README.md +2 -2
  41. data/lib/chef-cli/skeletons/code_generator/files/default/repo/roles/README.md +2 -2
  42. data/lib/chef-cli/skeletons/code_generator/metadata.rb +1 -1
  43. data/lib/chef-cli/skeletons/code_generator/recipes/build_cookbook.rb +2 -2
  44. data/lib/chef-cli/skeletons/code_generator/recipes/cookbook.rb +1 -1
  45. data/lib/chef-cli/skeletons/code_generator/recipes/repo.rb +1 -1
  46. data/lib/chef-cli/skeletons/code_generator/templates/default/CHANGELOG.md.erb +1 -2
  47. data/lib/chef-cli/skeletons/code_generator/templates/default/Policyfile.rb.erb +1 -1
  48. data/lib/chef-cli/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +1 -1
  49. data/lib/chef-cli/skeletons/code_generator/templates/default/helpers.rb.erb +2 -2
  50. data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen.yml.erb +4 -4
  51. data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb +4 -4
  52. data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +4 -4
  53. data/lib/chef-cli/skeletons/code_generator/templates/default/metadata.rb.erb +1 -1
  54. data/lib/chef-cli/skeletons/code_generator/templates/default/recipe_spec.rb.erb +4 -4
  55. data/lib/chef-cli/skeletons/code_generator/templates/default/resource.rb.erb +1 -1
  56. data/lib/chef-cli/version.rb +1 -1
  57. data/lib/kitchen/provisioner/chef_zero_capture.rb +90 -0
  58. data/spec/unit/command/generator_commands/build_cookbook_spec.rb +1 -1
  59. data/spec/unit/command/generator_commands/cookbook_spec.rb +12 -12
  60. data/spec/unit/command/generator_commands/policyfile_spec.rb +1 -1
  61. data/spec/unit/command/generator_commands/repo_spec.rb +5 -5
  62. data/spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb +84 -0
  63. data/spec/unit/policyfile/cookbook_location_specification_spec.rb +5 -0
  64. data/spec/unit/policyfile/uploader_spec.rb +2 -2
  65. data/spec/unit/policyfile_lock_build_spec.rb +1 -1
  66. data/spec/unit/policyfile_services/clean_policies_spec.rb +2 -0
  67. data/spec/unit/policyfile_services/update_attributes_spec.rb +1 -1
  68. data/spec/unit/service_exception_inspectors/http_spec.rb +1 -1
  69. metadata +36 -13
@@ -118,7 +118,7 @@ describe ChefCLI::Command::GeneratorCommands::Policyfile do
118
118
  # Policyfile.rb - Describe how you want Chef Infra Client to build your system.
119
119
  #
120
120
  # For more information on the Policyfile feature, visit
121
- # https://docs.chef.io/policyfile.html
121
+ # https://docs.chef.io/policyfile/
122
122
 
123
123
  # A name that describes what the system you're building with Chef does.
124
124
  name 'my-app-frontend'
@@ -231,7 +231,7 @@ describe ChefCLI::Command::GeneratorCommands::Repo do
231
231
  let(:argv) { ["new_repo", "--policy-only" ] }
232
232
 
233
233
  it "tells you whats up" do
234
- expect(file_contents).to match(/This directory typically contains Chef cookbooks/)
234
+ expect(file_contents).to match(/This directory typically contains Chef Infra cookbooks/)
235
235
  end
236
236
  end
237
237
  end
@@ -331,9 +331,9 @@ describe ChefCLI::Command::GeneratorCommands::Repo do
331
331
 
332
332
  knife role from file roles/example.json
333
333
 
334
- For more information on roles, see the Chef docs site:
334
+ For more information on roles, see the Chef Infra docs site:
335
335
 
336
- https://docs.chef.io/roles.html
336
+ https://docs.chef.io/roles/
337
337
  README
338
338
  end
339
339
 
@@ -355,9 +355,9 @@ describe ChefCLI::Command::GeneratorCommands::Repo do
355
355
 
356
356
  knife environment from file environments/example.json
357
357
 
358
- For more information on environments, see the Chef docs site:
358
+ For more information on environments, see the Chef Infra docs site:
359
359
 
360
- https://docs.chef.io/environments.html
360
+ https://docs.chef.io/environments/
361
361
  README
362
362
  end
363
363
 
@@ -0,0 +1,84 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Marc Paradsie <marc.paradise@gmail.com>
4
+ #
5
+ # Copyright (C) 2020 Chef Software Inc
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require_relative "../../../spec_helper"
20
+
21
+ require "kitchen"
22
+ require "kitchen/provisioner/chef_zero_capture"
23
+
24
+ describe Kitchen::Provisioner::ChefZeroCapture do
25
+ let(:logged_output) { StringIO.new }
26
+ let(:logger) { Logger.new(logged_output) }
27
+ let(:kitchen_root) { Dir.mktmpdir }
28
+
29
+ let(:config) do
30
+ { test_base_path: "/t", base_path: "/b", kitchen_root: kitchen_root, root_path: kitchen_root }
31
+ end
32
+ let(:platform) { double("platform", os_type: nil) }
33
+ let(:suite) { double("suite", name: "fried") }
34
+
35
+ let(:instance_config) do
36
+ double("config", name: "coolbeans", logger: logger, suite: suite, platform: platform)
37
+ end
38
+
39
+ subject do
40
+ p = Kitchen::Provisioner::ChefZeroCapture.new(config)
41
+ p.finalize_config!(instance_config)
42
+ end
43
+
44
+ after do
45
+ FileUtils.remove_entry(kitchen_root)
46
+ end
47
+
48
+ describe "#create_sandbox" do
49
+ let(:sandbox_mock) do
50
+ double("sandbox", populate: nil)
51
+ end
52
+ before do
53
+ allow(Kitchen::Provisioner::ChefZeroCaptureSandbox).to receive(:new).and_return sandbox_mock
54
+ end
55
+
56
+ it "initializes files and populates a ChefZeroCaptureSandbox" do
57
+ expect(subject).to receive(:prepare_validation_pem)
58
+ expect(subject).to receive(:prepare_config_rb)
59
+ expect(sandbox_mock).to receive(:populate)
60
+ subject.create_sandbox
61
+ end
62
+
63
+ after do
64
+ begin
65
+ subject.cleanup_sandbox
66
+ rescue # rubocop:disable Lint/HandleExceptions
67
+ end
68
+ end
69
+ end
70
+
71
+ describe "#default_config_rb" do
72
+ it "contains keys that suggest 'super' was invoked for full config_rb setup" do
73
+ cfg = subject.default_config_rb
74
+ expect(cfg[:node_path]).to eq File.join(kitchen_root, "nodes")
75
+ end
76
+
77
+ it "adds the expected correct config for captured nodes" do
78
+ cfg = subject.default_config_rb
79
+ expect(cfg[:policies_path]).to eq File.join(kitchen_root, "policies")
80
+ expect(cfg[:cookbook_artifacts_path]).to eq File.join(kitchen_root, "cookbook_artifacts")
81
+ expect(cfg[:policy_groups_path]).to eq File.join(kitchen_root, "policy_groups")
82
+ end
83
+ end
84
+ end
@@ -143,13 +143,18 @@ describe ChefCLI::Policyfile::CookbookLocationSpecification do
143
143
  allow(cookbook_location_spec).to receive(:cookbook_path).and_return(cookbook_path)
144
144
 
145
145
  default_recipe_path = install_path.join("recipes/default.rb")
146
+ default_yml_recipe_path = install_path.join("recipes/default.yml")
146
147
  nope_recipe_path = install_path.join("recipes/nope.rb")
148
+ nope_yml_recipe_path = install_path.join("recipes/nope.yml")
147
149
 
148
150
  expect(cookbook_path).to receive(:join).with("recipes/default.rb").and_return(default_recipe_path)
151
+ expect(cookbook_path).to receive(:join).with("recipes/default.yml").and_return(default_yml_recipe_path)
149
152
  expect(cookbook_path).to receive(:join).with("recipes/nope.rb").and_return(nope_recipe_path)
153
+ expect(cookbook_path).to receive(:join).with("recipes/nope.yml").and_return(nope_yml_recipe_path)
150
154
 
151
155
  expect(default_recipe_path).to receive(:exist?).and_return(true)
152
156
  expect(nope_recipe_path).to receive(:exist?).and_return(false)
157
+ expect(nope_yml_recipe_path).to receive(:exist?).and_return(false)
153
158
 
154
159
  expect(cookbook_location_spec.cookbook_has_recipe?("default")).to be(true)
155
160
  expect(cookbook_location_spec.cookbook_has_recipe?("nope")).to be(false)
@@ -319,14 +319,14 @@ describe ChefCLI::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)
@@ -22,7 +22,7 @@ require "shared/fixture_cookbook_checksums"
22
22
  require "chef-cli/policyfile/storage_config"
23
23
  require "chef-cli/policyfile_lock.rb"
24
24
 
25
- describe ChefCLI::PolicyfileLock, "building a lockfile" do
25
+ describe ChefCLI::PolicyfileLock, "building a lockfile", :skip_on_windows do
26
26
 
27
27
  include_context "fixture cookbooks checksums"
28
28
 
@@ -211,6 +211,8 @@ describe ChefCLI::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\"
@@ -176,7 +176,7 @@ describe ChefCLI::PolicyfileServices::UpdateAttributes do
176
176
  expect(ChefCLI::Policyfile::LockApplier).to receive(:new).with(
177
177
  update_attrs_service.policyfile_lock, update_attrs_service.policyfile_compiler
178
178
  ).and_return(lock_applier)
179
- expect(lock_applier).not_to receive(:with_unlocked_policies)
179
+ expect(lock_applier).to receive(:with_unlocked_policies).with(:all).and_return(lock_applier)
180
180
  expect(lock_applier).to receive(:apply!)
181
181
 
182
182
  update_attrs_service.run
@@ -64,7 +64,7 @@ describe ChefCLI::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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-17 00:00:00.000000000 Z
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -90,14 +90,14 @@ dependencies:
90
90
  requirements:
91
91
  - - ">="
92
92
  - !ruby/object:Gem::Version
93
- version: '14.0'
93
+ version: '15.0'
94
94
  type: :runtime
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
98
  - - ">="
99
99
  - !ruby/object:Gem::Version
100
- version: '14.0'
100
+ version: '15.0'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: solve
103
103
  requirement: !ruby/object:Gem::Requirement
@@ -127,7 +127,7 @@ dependencies:
127
127
  version: 2.3.5
128
128
  - - "<"
129
129
  - !ruby/object:Gem::Version
130
- version: '2.6'
130
+ version: '2.8'
131
131
  type: :runtime
132
132
  prerelease: false
133
133
  version_requirements: !ruby/object:Gem::Requirement
@@ -137,7 +137,7 @@ dependencies:
137
137
  version: 2.3.5
138
138
  - - "<"
139
139
  - !ruby/object:Gem::Version
140
- version: '2.6'
140
+ version: '2.8'
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: cookbook-omnifetch
143
143
  requirement: !ruby/object:Gem::Requirement
@@ -170,16 +170,22 @@ dependencies:
170
170
  name: paint
171
171
  requirement: !ruby/object:Gem::Requirement
172
172
  requirements:
173
- - - "~>"
173
+ - - ">="
174
174
  - !ruby/object:Gem::Version
175
- version: '1.0'
175
+ version: '1'
176
+ - - "<"
177
+ - !ruby/object:Gem::Version
178
+ version: '3'
176
179
  type: :runtime
177
180
  prerelease: false
178
181
  version_requirements: !ruby/object:Gem::Requirement
179
182
  requirements:
180
- - - "~>"
183
+ - - ">="
181
184
  - !ruby/object:Gem::Version
182
- version: '1.0'
185
+ version: '1'
186
+ - - "<"
187
+ - !ruby/object:Gem::Version
188
+ version: '3'
183
189
  - !ruby/object:Gem::Dependency
184
190
  name: license-acceptance
185
191
  requirement: !ruby/object:Gem::Requirement
@@ -200,18 +206,32 @@ dependencies:
200
206
  - - ">="
201
207
  - !ruby/object:Gem::Version
202
208
  version: 1.0.11
209
+ - !ruby/object:Gem::Dependency
210
+ name: ffi
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "<"
214
+ - !ruby/object:Gem::Version
215
+ version: '1.13'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "<"
221
+ - !ruby/object:Gem::Version
222
+ version: '1.13'
203
223
  description: A streamlined development and deployment workflow for Chef platform.
204
224
  email:
205
225
  - info@chef.io
206
226
  executables:
207
- - chef
227
+ - chef-cli
208
228
  extensions: []
209
229
  extra_rdoc_files: []
210
230
  files:
211
231
  - Gemfile
212
232
  - LICENSE
213
233
  - Rakefile
214
- - bin/chef
234
+ - bin/chef-cli
215
235
  - chef-cli.gemspec
216
236
  - lib/chef-cli.rb
217
237
  - lib/chef-cli/authenticated_http.rb
@@ -383,6 +403,7 @@ files:
383
403
  - lib/chef-cli/skeletons/code_generator/templates/default/template.erb
384
404
  - lib/chef-cli/ui.rb
385
405
  - lib/chef-cli/version.rb
406
+ - lib/kitchen/provisioner/chef_zero_capture.rb
386
407
  - lib/kitchen/provisioner/policyfile_zero.rb
387
408
  - spec/shared/a_file_generator.rb
388
409
  - spec/shared/a_generated_file.rb
@@ -521,6 +542,7 @@ files:
521
542
  - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
522
543
  - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
523
544
  - spec/unit/generator_spec.rb
545
+ - spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb
524
546
  - spec/unit/pager_spec.rb
525
547
  - spec/unit/policyfile/artifactory_cookbook_source_spec.rb
526
548
  - spec/unit/policyfile/attribute_merge_checker_spec.rb
@@ -586,7 +608,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
586
608
  requirements:
587
609
  - - ">="
588
610
  - !ruby/object:Gem::Version
589
- version: '2.4'
611
+ version: '2.5'
590
612
  required_rubygems_version: !ruby/object:Gem::Requirement
591
613
  requirements:
592
614
  - - ">="
@@ -735,6 +757,7 @@ test_files:
735
757
  - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
736
758
  - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
737
759
  - spec/unit/generator_spec.rb
760
+ - spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb
738
761
  - spec/unit/pager_spec.rb
739
762
  - spec/unit/policyfile/artifactory_cookbook_source_spec.rb
740
763
  - spec/unit/policyfile/attribute_merge_checker_spec.rb