chef-cli 3.0.1 → 3.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: adb138942d756bfa17638b7ba9308e77730ba9b77bb505821d68ee9b7cdc3d2c
4
- data.tar.gz: 4b9d246fe278ec0d4f230d6694e30c64dae2a6b426e4b5020639dc01d0401e98
3
+ metadata.gz: d8ef75d64aed76476f1ca99d5e36ebba9d39f408dd2a7dfc842929e0b74e6b44
4
+ data.tar.gz: 246b506ff8bae1577ffdeac5888f26d94fa45223fe02c0236d82d2ab0cfed326
5
5
  SHA512:
6
- metadata.gz: 32d8f2e150ff38eefdb26b17fa2b5eda415c697df4324aa3e63ef9545646a346388e4c985cee379773d4311b0421228fbfcb5a8adf3750bbc40a64882a6aacd7
7
- data.tar.gz: 3a455461956da321300c610c56d78d594b789474017807d0c986dabdd45541e1260b123f838d52e179247f2e6ab4ec911dc7e09ba611c3855dd2b9b4a4cbc4fb
6
+ metadata.gz: a2105386dd0b2fd89e09e9ba027c3da1b2557cb3cb5ff1a655215d936e5224034ded81d07e08f65c5971228b7391277e9ecf7ebaafd46933de16fe105882c68a
7
+ data.tar.gz: 9ba7a7cd5f85f3e577710621f701f266750e25ac24383ef688f821599642fa7b61e25bb3ff6f0fc7ef88a75a981269449e5c6b675852aca91b936210c51f05bf
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
29
29
  gem.license = "Apache-2.0"
30
30
  gem.homepage = "https://www.chef.io/"
31
31
 
32
- gem.required_ruby_version = ">= 2.6"
32
+ gem.required_ruby_version = ">= 2.7"
33
33
 
34
34
  gem.files = %w{Rakefile LICENSE} +
35
35
  Dir.glob("Gemfile*") + # Includes Gemfile and locks
@@ -50,4 +50,5 @@ Gem::Specification.new do |gem|
50
50
  gem.add_dependency "diff-lcs", "~> 1.0"
51
51
  gem.add_dependency "paint", ">= 1", "< 3"
52
52
  gem.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.11"
53
+ gem.add_development_dependency "test-kitchen", "> 2.5"
53
54
  end
@@ -122,7 +122,7 @@ module ChefCLI
122
122
  "Test Kitchen": "kitchen",
123
123
  "Cookstyle": "cookstyle",
124
124
  }.each do |name, cli|
125
- result = Bundler.with_clean_env { shell_out("#{cli} --version") }
125
+ result = Bundler.with_unbundled_env { shell_out("#{cli} --version") }
126
126
  if result.exitstatus != 0
127
127
  msg("#{name} version: ERROR")
128
128
  else
@@ -62,8 +62,6 @@ kitchen.yml*
62
62
  Procfile
63
63
  Rakefile
64
64
  spec/*
65
- spec/*
66
- spec/fixtures/*
67
65
  test/*
68
66
 
69
67
  # SCM #
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "3.0.1".freeze
19
+ VERSION = "3.0.4".freeze
20
20
  end
@@ -0,0 +1,90 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Marc Paradise <marc@chef.io>
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 "json"
20
+ require "kitchen"
21
+ require "kitchen/provisioner/base"
22
+ require "kitchen/provisioner/chef_zero"
23
+
24
+ module Kitchen
25
+ module Provisioner
26
+ # For use in a provisioner that does not do any run list evaluation or
27
+ # policy/berks file expansion.
28
+ class ChefZeroCaptureSandbox < Chef::CommonSandbox
29
+ def populate
30
+ super
31
+ prepare(:policies)
32
+ prepare(:policy_groups)
33
+ prepare(:cookbook_artifacts)
34
+ end
35
+
36
+ # Override #prepare_cookbooks because we don't want any cookbook resolving to occur
37
+ # via kitchen through berks, policy
38
+ def prepare_cookbooks
39
+ cp_cookbooks
40
+ filter_only_cookbook_files
41
+ end
42
+ end
43
+
44
+ # chef-zero provisioner intended for use with `chef capture`.
45
+ #
46
+ # This provisioner does not do any cookbook dependency
47
+ # resolution and will not pull in external cookbooks. All cookbooks
48
+ # or cookbook artificats + policy data as captured from the live node and are
49
+ # expected to be available for chef-zero to provide to the client.
50
+ class ChefZeroCapture < ChefZero
51
+ # Declaring these ensure that they're available to the sandbox - it's initialized
52
+ # the provider's configoptions.
53
+ default_config :policies_path, "policies"
54
+ default_config :policy_groups_path, "policy_groups"
55
+ default_config :cookbook_artifacts_path, "cookbook_artifacts"
56
+
57
+ # This will load policyfile/berkshelf. We don't want either - the client resolves all
58
+ # dependencies from chef-zero, exactly as preppped in the captured repository.
59
+ def load_needed_dependencies!; end
60
+
61
+ def create_sandbox
62
+ # We have to invoke the the true Base create_sandbox because it does setup that
63
+ # we want. However, we do not want to invoke the create_sandbox inherited from
64
+ # ChefZero/ChefBase - those will create and populate a ChefCommonSandbox instead
65
+ # of a ChefZeroCaptureSandbox.
66
+ m = Base.instance_method(:create_sandbox).bind(self)
67
+ m.call
68
+
69
+ # These behaviors from super we _do_ want, so we need to copy them here.
70
+ prepare_validation_pem
71
+ prepare_config_rb
72
+ ChefZeroCaptureSandbox.new(config, sandbox_path, instance).populate
73
+ end
74
+
75
+ # Overriding the private ProviderChefZero#default_config_rb
76
+ # so that we can add additional configuratoin required for chef-zeor
77
+ # to be able to locate our policies/, policy groups, and cookbook artifacts
78
+ # at run-time.
79
+ def default_config_rb
80
+ cfg = super
81
+ # Need to tell chef-zero about our additional config.
82
+ root = config[:root_path].gsub("$env:TEMP", "\#{ENV['TEMP']\}")
83
+ cfg[:policies_path] = remote_path_join(root, config[:policies_path])
84
+ cfg[:policy_groups_path] = remote_path_join(root, config[:policy_groups_path])
85
+ cfg[:cookbook_artifacts_path] = remote_path_join(root, config[:cookbook_artifacts_path])
86
+ cfg
87
+ end
88
+ end
89
+ end
90
+ end
@@ -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
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: 3.0.1
4
+ version: 3.0.4
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: 2020-05-12 00:00:00.000000000 Z
11
+ date: 2020-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -206,6 +206,20 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: 1.0.11
209
+ - !ruby/object:Gem::Dependency
210
+ name: test-kitchen
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">"
214
+ - !ruby/object:Gem::Version
215
+ version: '2.5'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">"
221
+ - !ruby/object:Gem::Version
222
+ version: '2.5'
209
223
  description: A streamlined development and deployment workflow for Chef platform.
210
224
  email:
211
225
  - info@chef.io
@@ -389,6 +403,7 @@ files:
389
403
  - lib/chef-cli/skeletons/code_generator/templates/default/template.erb
390
404
  - lib/chef-cli/ui.rb
391
405
  - lib/chef-cli/version.rb
406
+ - lib/kitchen/provisioner/chef_zero_capture.rb
392
407
  - lib/kitchen/provisioner/policyfile_zero.rb
393
408
  - spec/shared/a_file_generator.rb
394
409
  - spec/shared/a_generated_file.rb
@@ -527,6 +542,7 @@ files:
527
542
  - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
528
543
  - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
529
544
  - spec/unit/generator_spec.rb
545
+ - spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb
530
546
  - spec/unit/pager_spec.rb
531
547
  - spec/unit/policyfile/artifactory_cookbook_source_spec.rb
532
548
  - spec/unit/policyfile/attribute_merge_checker_spec.rb
@@ -592,7 +608,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
592
608
  requirements:
593
609
  - - ">="
594
610
  - !ruby/object:Gem::Version
595
- version: '2.6'
611
+ version: '2.7'
596
612
  required_rubygems_version: !ruby/object:Gem::Requirement
597
613
  requirements:
598
614
  - - ">="
@@ -741,6 +757,7 @@ test_files:
741
757
  - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
742
758
  - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
743
759
  - spec/unit/generator_spec.rb
760
+ - spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb
744
761
  - spec/unit/pager_spec.rb
745
762
  - spec/unit/policyfile/artifactory_cookbook_source_spec.rb
746
763
  - spec/unit/policyfile/attribute_merge_checker_spec.rb