chef-cli 3.0.1 → 3.0.11
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 +6 -1
 - data/chef-cli.gemspec +2 -2
 - data/lib/chef-cli/cli.rb +7 -1
 - data/lib/chef-cli/command/generator_commands/chef_exts/generator_desc_resource.rb +1 -0
 - data/lib/chef-cli/skeletons/code_generator/files/default/chefignore +13 -9
 - data/lib/chef-cli/skeletons/code_generator/metadata.rb +1 -1
 - data/lib/chef-cli/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +1 -1
 - data/lib/chef-cli/skeletons/code_generator/templates/default/metadata.rb.erb +1 -1
 - data/lib/chef-cli/version.rb +1 -1
 - data/lib/kitchen/provisioner/chef_zero_capture.rb +90 -0
 - data/spec/unit/command/generator_commands/build_cookbook_spec.rb +1 -1
 - data/spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb +84 -0
 - metadata +14 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b8a428266246dc22388ebf2714824965912bf1b17fa657bc9ffab99fef6f0a88
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: aed196c6c1cae0d61a877e6916d5514313c0b186faae75598402fcacfee0c756
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 343ec04d69d8133e65d887f5e71ab53416ba2a09013df8f530ba70cb2d2f6dcc9b60c8b9ea4c3e445e9a223175681c5d61babc9339ef381483707219d0f5cf71
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b1fe61b9c04025de73c654d0c7bd65033a34935198ba53a68a921eb1bf1f2c1d4c7c30e55ee45eb4168e304402f3412fc30e47f8230af22d9c4f802b424a280e
         
     | 
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -15,11 +15,16 @@ group :test do 
     | 
|
| 
       15 
15 
     | 
    
         
             
              gem "rspec-mocks", "~> 3.8"
         
     | 
| 
       16 
16 
     | 
    
         
             
              gem "cookstyle"
         
     | 
| 
       17 
17 
     | 
    
         
             
              gem "chefstyle"
         
     | 
| 
      
 18 
     | 
    
         
            +
              gem "test-kitchen", "> 2.5"
         
     | 
| 
      
 19 
     | 
    
         
            +
              if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6")
         
     | 
| 
      
 20 
     | 
    
         
            +
                gem "chef-zero", "~> 14"
         
     | 
| 
      
 21 
     | 
    
         
            +
                gem "chef", "~> 15"
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
       18 
23 
     | 
    
         
             
            end
         
     | 
| 
       19 
24 
     | 
    
         | 
| 
       20 
25 
     | 
    
         
             
            group :development do
         
     | 
| 
       21 
26 
     | 
    
         
             
              gem "pry"
         
     | 
| 
       22 
27 
     | 
    
         
             
              gem "pry-byebug"
         
     | 
| 
       23 
     | 
    
         
            -
              gem "pry-stack_explorer"
         
     | 
| 
      
 28 
     | 
    
         
            +
              gem "pry-stack_explorer", "~> 0.4.0"
         
     | 
| 
       24 
29 
     | 
    
         
             
              gem "rb-readline"
         
     | 
| 
       25 
30 
     | 
    
         
             
            end
         
     | 
    
        data/chef-cli.gemspec
    CHANGED
    
    | 
         @@ -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. 
     | 
| 
      
 32 
     | 
    
         
            +
              gem.required_ruby_version = ">= 2.5"
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
              gem.files = %w{Rakefile LICENSE} +
         
     | 
| 
       35 
35 
     | 
    
         
             
                Dir.glob("Gemfile*") + # Includes Gemfile and locks
         
     | 
| 
         @@ -47,7 +47,7 @@ Gem::Specification.new do |gem| 
     | 
|
| 
       47 
47 
     | 
    
         
             
              gem.add_dependency "solve", "< 5.0", "> 2.0"
         
     | 
| 
       48 
48 
     | 
    
         
             
              gem.add_dependency "addressable", ">= 2.3.5", "< 2.8"
         
     | 
| 
       49 
49 
     | 
    
         
             
              gem.add_dependency "cookbook-omnifetch", "~> 0.5"
         
     | 
| 
       50 
     | 
    
         
            -
              gem.add_dependency "diff-lcs", " 
     | 
| 
      
 50 
     | 
    
         
            +
              gem.add_dependency "diff-lcs", ">= 1.0", "< 1.4" # 1.4 changes the output
         
     | 
| 
       51 
51 
     | 
    
         
             
              gem.add_dependency "paint", ">= 1", "< 3"
         
     | 
| 
       52 
52 
     | 
    
         
             
              gem.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.11"
         
     | 
| 
       53 
53 
     | 
    
         
             
            end
         
     | 
    
        data/lib/chef-cli/cli.rb
    CHANGED
    
    | 
         @@ -122,7 +122,13 @@ module ChefCLI 
     | 
|
| 
       122 
122 
     | 
    
         
             
                    "Test Kitchen": "kitchen",
         
     | 
| 
       123 
123 
     | 
    
         
             
                    "Cookstyle": "cookstyle",
         
     | 
| 
       124 
124 
     | 
    
         
             
                  }.each do |name, cli|
         
     | 
| 
       125 
     | 
    
         
            -
                     
     | 
| 
      
 125 
     | 
    
         
            +
                    # @todo when Ruby 2.5/2.6 support goes away this if statement can go away
         
     | 
| 
      
 126 
     | 
    
         
            +
                    if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2")
         
     | 
| 
      
 127 
     | 
    
         
            +
                      result = Bundler.with_unbundled_env { shell_out("#{cli} --version") }
         
     | 
| 
      
 128 
     | 
    
         
            +
                    else
         
     | 
| 
      
 129 
     | 
    
         
            +
                      result = Bundler.with_clean_env { shell_out("#{cli} --version") }
         
     | 
| 
      
 130 
     | 
    
         
            +
                    end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
       126 
132 
     | 
    
         
             
                    if result.exitstatus != 0
         
     | 
| 
       127 
133 
     | 
    
         
             
                      msg("#{name} version: ERROR")
         
     | 
| 
       128 
134 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -9,10 +9,7 @@ ehthumbs.db 
     | 
|
| 
       9 
9 
     | 
    
         
             
            Icon?
         
     | 
| 
       10 
10 
     | 
    
         
             
            nohup.out
         
     | 
| 
       11 
11 
     | 
    
         
             
            Thumbs.db
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            # SASS #
         
     | 
| 
       14 
     | 
    
         
            -
            ########
         
     | 
| 
       15 
     | 
    
         
            -
            .sass-cache
         
     | 
| 
      
 12 
     | 
    
         
            +
            .envrc
         
     | 
| 
       16 
13 
     | 
    
         | 
| 
       17 
14 
     | 
    
         
             
            # EDITORS #
         
     | 
| 
       18 
15 
     | 
    
         
             
            ###########
         
     | 
| 
         @@ -26,11 +23,11 @@ Thumbs.db 
     | 
|
| 
       26 
23 
     | 
    
         
             
            *.tmproj
         
     | 
| 
       27 
24 
     | 
    
         
             
            *~
         
     | 
| 
       28 
25 
     | 
    
         
             
            \#*
         
     | 
| 
       29 
     | 
    
         
            -
            mkmf.log
         
     | 
| 
       30 
26 
     | 
    
         
             
            REVISION
         
     | 
| 
       31 
27 
     | 
    
         
             
            TAGS*
         
     | 
| 
       32 
28 
     | 
    
         
             
            tmtags
         
     | 
| 
       33 
29 
     | 
    
         
             
            .vscode
         
     | 
| 
      
 30 
     | 
    
         
            +
            .editorconfig
         
     | 
| 
       34 
31 
     | 
    
         | 
| 
       35 
32 
     | 
    
         
             
            ## COMPILED ##
         
     | 
| 
       36 
33 
     | 
    
         
             
            ##############
         
     | 
| 
         @@ -43,27 +40,32 @@ tmtags 
     | 
|
| 
       43 
40 
     | 
    
         
             
            *.so
         
     | 
| 
       44 
41 
     | 
    
         
             
            */rdoc/
         
     | 
| 
       45 
42 
     | 
    
         
             
            a.out
         
     | 
| 
      
 43 
     | 
    
         
            +
            mkmf.log
         
     | 
| 
       46 
44 
     | 
    
         | 
| 
       47 
45 
     | 
    
         
             
            # Testing #
         
     | 
| 
       48 
46 
     | 
    
         
             
            ###########
         
     | 
| 
       49 
47 
     | 
    
         
             
            .circleci/*
         
     | 
| 
       50 
48 
     | 
    
         
             
            .codeclimate.yml
         
     | 
| 
      
 49 
     | 
    
         
            +
            .delivery/*
         
     | 
| 
       51 
50 
     | 
    
         
             
            .foodcritic
         
     | 
| 
       52 
51 
     | 
    
         
             
            .kitchen*
         
     | 
| 
      
 52 
     | 
    
         
            +
            .mdlrc
         
     | 
| 
      
 53 
     | 
    
         
            +
            .overcommit.yml
         
     | 
| 
       53 
54 
     | 
    
         
             
            .rspec
         
     | 
| 
       54 
55 
     | 
    
         
             
            .rubocop.yml
         
     | 
| 
       55 
56 
     | 
    
         
             
            .travis.yml
         
     | 
| 
       56 
57 
     | 
    
         
             
            .watchr
         
     | 
| 
      
 58 
     | 
    
         
            +
            .yamllint
         
     | 
| 
       57 
59 
     | 
    
         
             
            azure-pipelines.yml
         
     | 
| 
      
 60 
     | 
    
         
            +
            Dangerfile
         
     | 
| 
       58 
61 
     | 
    
         
             
            examples/*
         
     | 
| 
       59 
62 
     | 
    
         
             
            features/*
         
     | 
| 
       60 
63 
     | 
    
         
             
            Guardfile
         
     | 
| 
       61 
64 
     | 
    
         
             
            kitchen.yml*
         
     | 
| 
      
 65 
     | 
    
         
            +
            mlc_config.json
         
     | 
| 
       62 
66 
     | 
    
         
             
            Procfile
         
     | 
| 
       63 
67 
     | 
    
         
             
            Rakefile
         
     | 
| 
       64 
68 
     | 
    
         
             
            spec/*
         
     | 
| 
       65 
     | 
    
         
            -
            spec/*
         
     | 
| 
       66 
     | 
    
         
            -
            spec/fixtures/*
         
     | 
| 
       67 
69 
     | 
    
         
             
            test/*
         
     | 
| 
       68 
70 
     | 
    
         | 
| 
       69 
71 
     | 
    
         
             
            # SCM #
         
     | 
| 
         @@ -73,6 +75,7 @@ test/* 
     | 
|
| 
       73 
75 
     | 
    
         
             
            .gitconfig
         
     | 
| 
       74 
76 
     | 
    
         
             
            .github/*
         
     | 
| 
       75 
77 
     | 
    
         
             
            .gitignore
         
     | 
| 
      
 78 
     | 
    
         
            +
            .gitkeep
         
     | 
| 
       76 
79 
     | 
    
         
             
            .gitmodules
         
     | 
| 
       77 
80 
     | 
    
         
             
            .svn
         
     | 
| 
       78 
81 
     | 
    
         
             
            */.bzr/*
         
     | 
| 
         @@ -100,10 +103,11 @@ Policyfile.lock.json 
     | 
|
| 
       100 
103 
     | 
    
         | 
| 
       101 
104 
     | 
    
         
             
            # Documentation #
         
     | 
| 
       102 
105 
     | 
    
         
             
            #############
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
      
 106 
     | 
    
         
            +
            CODE_OF_CONDUCT*
         
     | 
| 
       104 
107 
     | 
    
         
             
            CONTRIBUTING*
         
     | 
| 
      
 108 
     | 
    
         
            +
            documentation/*
         
     | 
| 
       105 
109 
     | 
    
         
             
            TESTING*
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
      
 110 
     | 
    
         
            +
            UPGRADING*
         
     | 
| 
       107 
111 
     | 
    
         | 
| 
       108 
112 
     | 
    
         
             
            # Vagrant #
         
     | 
| 
       109 
113 
     | 
    
         
             
            ###########
         
     | 
| 
         @@ -4,7 +4,7 @@ maintainer_email '<%= email %>' 
     | 
|
| 
       4 
4 
     | 
    
         
             
            license '<%= @spdx_license %>'
         
     | 
| 
       5 
5 
     | 
    
         
             
            description 'Installs/Configures <%= cookbook_name %>'
         
     | 
| 
       6 
6 
     | 
    
         
             
            version '0.1.0'
         
     | 
| 
       7 
     | 
    
         
            -
            chef_version '>=  
     | 
| 
      
 7 
     | 
    
         
            +
            chef_version '>= 15.0'
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
            # The `issues_url` points to the location where issues for this cookbook are
         
     | 
| 
       10 
10 
     | 
    
         
             
            # tracked.  A `View Issues` link will be displayed on this cookbook's page when
         
     | 
    
        data/lib/chef-cli/version.rb
    CHANGED
    
    
| 
         @@ -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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.0.11
         
     | 
| 
       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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-06-29 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: mixlib-cli
         
     | 
| 
         @@ -156,16 +156,22 @@ dependencies: 
     | 
|
| 
       156 
156 
     | 
    
         
             
              name: diff-lcs
         
     | 
| 
       157 
157 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       158 
158 
     | 
    
         
             
                requirements:
         
     | 
| 
       159 
     | 
    
         
            -
                - - " 
     | 
| 
      
 159 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       160 
160 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       161 
161 
     | 
    
         
             
                    version: '1.0'
         
     | 
| 
      
 162 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 163 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 164 
     | 
    
         
            +
                    version: '1.4'
         
     | 
| 
       162 
165 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       163 
166 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       164 
167 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       165 
168 
     | 
    
         
             
                requirements:
         
     | 
| 
       166 
     | 
    
         
            -
                - - " 
     | 
| 
      
 169 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       167 
170 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       168 
171 
     | 
    
         
             
                    version: '1.0'
         
     | 
| 
      
 172 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 173 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 174 
     | 
    
         
            +
                    version: '1.4'
         
     | 
| 
       169 
175 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       170 
176 
     | 
    
         
             
              name: paint
         
     | 
| 
       171 
177 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -389,6 +395,7 @@ files: 
     | 
|
| 
       389 
395 
     | 
    
         
             
            - lib/chef-cli/skeletons/code_generator/templates/default/template.erb
         
     | 
| 
       390 
396 
     | 
    
         
             
            - lib/chef-cli/ui.rb
         
     | 
| 
       391 
397 
     | 
    
         
             
            - lib/chef-cli/version.rb
         
     | 
| 
      
 398 
     | 
    
         
            +
            - lib/kitchen/provisioner/chef_zero_capture.rb
         
     | 
| 
       392 
399 
     | 
    
         
             
            - lib/kitchen/provisioner/policyfile_zero.rb
         
     | 
| 
       393 
400 
     | 
    
         
             
            - spec/shared/a_file_generator.rb
         
     | 
| 
       394 
401 
     | 
    
         
             
            - spec/shared/a_generated_file.rb
         
     | 
| 
         @@ -527,6 +534,7 @@ files: 
     | 
|
| 
       527 
534 
     | 
    
         
             
            - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
         
     | 
| 
       528 
535 
     | 
    
         
             
            - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
         
     | 
| 
       529 
536 
     | 
    
         
             
            - spec/unit/generator_spec.rb
         
     | 
| 
      
 537 
     | 
    
         
            +
            - spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb
         
     | 
| 
       530 
538 
     | 
    
         
             
            - spec/unit/pager_spec.rb
         
     | 
| 
       531 
539 
     | 
    
         
             
            - spec/unit/policyfile/artifactory_cookbook_source_spec.rb
         
     | 
| 
       532 
540 
     | 
    
         
             
            - spec/unit/policyfile/attribute_merge_checker_spec.rb
         
     | 
| 
         @@ -592,7 +600,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       592 
600 
     | 
    
         
             
              requirements:
         
     | 
| 
       593 
601 
     | 
    
         
             
              - - ">="
         
     | 
| 
       594 
602 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       595 
     | 
    
         
            -
                  version: '2. 
     | 
| 
      
 603 
     | 
    
         
            +
                  version: '2.5'
         
     | 
| 
       596 
604 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       597 
605 
     | 
    
         
             
              requirements:
         
     | 
| 
       598 
606 
     | 
    
         
             
              - - ">="
         
     | 
| 
         @@ -741,6 +749,7 @@ test_files: 
     | 
|
| 
       741 
749 
     | 
    
         
             
            - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
         
     | 
| 
       742 
750 
     | 
    
         
             
            - spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
         
     | 
| 
       743 
751 
     | 
    
         
             
            - spec/unit/generator_spec.rb
         
     | 
| 
      
 752 
     | 
    
         
            +
            - spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb
         
     | 
| 
       744 
753 
     | 
    
         
             
            - spec/unit/pager_spec.rb
         
     | 
| 
       745 
754 
     | 
    
         
             
            - spec/unit/policyfile/artifactory_cookbook_source_spec.rb
         
     | 
| 
       746 
755 
     | 
    
         
             
            - spec/unit/policyfile/attribute_merge_checker_spec.rb
         
     |