chef-cli 3.0.10 → 3.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/chef-cli.gemspec +2 -2
  4. data/lib/chef-cli/cli.rb +25 -37
  5. data/lib/chef-cli/command/env.rb +1 -1
  6. data/lib/chef-cli/command/gem.rb +0 -1
  7. data/lib/chef-cli/command/generator_commands.rb +1 -2
  8. data/lib/chef-cli/command/generator_commands/cookbook.rb +15 -12
  9. data/lib/chef-cli/command/provision.rb +0 -2
  10. data/lib/chef-cli/command/shell_init.rb +1 -1
  11. data/lib/chef-cli/command/update.rb +1 -1
  12. data/lib/chef-cli/cookbook_profiler/git.rb +1 -1
  13. data/lib/chef-cli/dist.rb +5 -0
  14. data/lib/chef-cli/policyfile/artifactory_cookbook_source.rb +2 -2
  15. data/lib/chef-cli/policyfile/attribute_merge_checker.rb +1 -1
  16. data/lib/chef-cli/policyfile/chef_server_lock_fetcher.rb +1 -1
  17. data/lib/chef-cli/policyfile/community_cookbook_source.rb +1 -1
  18. data/lib/chef-cli/policyfile/cookbook_location_specification.rb +1 -1
  19. data/lib/chef-cli/policyfile/cookbook_locks.rb +2 -2
  20. data/lib/chef-cli/policyfile/delivery_supermarket_source.rb +2 -4
  21. data/lib/chef-cli/policyfile/differ.rb +8 -2
  22. data/lib/chef-cli/policyfile/dsl.rb +1 -1
  23. data/lib/chef-cli/policyfile/local_lock_fetcher.rb +1 -1
  24. data/lib/chef-cli/policyfile/policyfile_location_specification.rb +1 -1
  25. data/lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb +2 -2
  26. data/lib/chef-cli/policyfile_compiler.rb +1 -1
  27. data/lib/chef-cli/policyfile_lock.rb +1 -2
  28. data/lib/chef-cli/skeletons/code_generator/files/default/chefignore +11 -2
  29. data/lib/chef-cli/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +1 -1
  30. data/lib/chef-cli/version.rb +1 -1
  31. data/lib/kitchen/provisioner/chef_zero_capture.rb +4 -5
  32. data/lib/kitchen/provisioner/policyfile_zero.rb +1 -2
  33. data/spec/unit/cli_spec.rb +17 -56
  34. data/spec/unit/command/clean_policy_cookbooks_spec.rb +2 -2
  35. data/spec/unit/command/env_spec.rb +2 -2
  36. data/spec/unit/command/exec_spec.rb +1 -1
  37. data/spec/unit/commands_map_spec.rb +4 -4
  38. data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +1 -1
  39. data/spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb +0 -1
  40. data/spec/unit/policyfile/differ_spec.rb +1 -1
  41. data/spec/unit/policyfile_includes_spec.rb +0 -1
  42. data/spec/unit/policyfile_install_with_includes_spec.rb +0 -1
  43. data/spec/unit/policyfile_lock_build_spec.rb +0 -1
  44. metadata +15 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52fb659d9d9b8f33e6a46e06ff25c62531d7098c0917da319078ab6c280b9f86
4
- data.tar.gz: d0148fd63485171a17313682edec5a4bf0f62e6c19d0cb906dd150cbc8599bc1
3
+ metadata.gz: c339cf60e573bfcc494ea18c6b641186a8c755c935be0283a8406387540c0134
4
+ data.tar.gz: b774a1dd9c5d085d2d0b307febb9f9882ab5da6ca1517f8b0e6c1dea207b6404
5
5
  SHA512:
6
- metadata.gz: 93eca71e26052ee224039df9e0814dff270b0544976e95ed65b3877b14e7538f52e9c295fb8b26cd969c904f27d7fdad404fb6b5e471bc6e67db614795aa0a52
7
- data.tar.gz: a6b3181c1531d4a91bf0c9a3670c4ee922c3849d849f7a2d61a00a04ab9911a3405dca60a26aff7f2aa08969b43a5092850fa4ca730d9bdfdf8f7ea0095294f3
6
+ metadata.gz: 4737f6de6472e79359cd79694edcf5b0a87973b1ddb3757aed33a59aac968687aa99b5fa94056142cb82c1fa76ba220d2d2e38116004d1328b25ef628dfdaf4f
7
+ data.tar.gz: e616b2608aeb4891dc879c689b2b187885b79d62aa3ed6c9a7a8afb7b02610a4dd100b8eef243945baead2f4d460ce0b205d7d93314b44313e7661302e6ce79b
data/Gemfile CHANGED
@@ -13,8 +13,8 @@ group :test do
13
13
  gem "rspec", "~> 3.8"
14
14
  gem "rspec-expectations", "~> 3.8"
15
15
  gem "rspec-mocks", "~> 3.8"
16
- gem "cookstyle"
17
- gem "chefstyle"
16
+ gem "cookstyle", "6.14.7" # this forces dependabot PRs to open which triggers cookstyle CI on the chef generate command
17
+ gem "chefstyle", "1.2.0"
18
18
  gem "test-kitchen", "> 2.5"
19
19
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6")
20
20
  gem "chef-zero", "~> 14"
@@ -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", "~> 1.0"
51
- gem.add_dependency "paint", ">= 1", "< 3"
50
+ gem.add_dependency "diff-lcs", ">= 1.0", "< 1.4" # 1.4 changes the output
51
+ gem.add_dependency "pastel", "~> 0.7" # used for policyfile differ
52
52
  gem.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.11"
53
53
  end
@@ -59,7 +59,7 @@ module ChefCLI
59
59
  end
60
60
 
61
61
  def run(enforce_license: false)
62
- sanity_check!
62
+ path_check!
63
63
 
64
64
  subcommand_name, *subcommand_params = argv
65
65
 
@@ -99,42 +99,21 @@ module ChefCLI
99
99
  if omnibus_install?
100
100
  show_version_via_version_manifest
101
101
  else
102
- show_version_via_shell_out
102
+ msg("#{ChefCLI::Dist::CLI_PRODUCT} version: #{ChefCLI::VERSION}")
103
103
  end
104
104
  end
105
105
 
106
106
  def show_version_via_version_manifest
107
- msg("#{ChefCLI::Dist::PRODUCT} version: #{manifest_field("build_version")}")
108
- { "#{ChefCLI::Dist::INFRA_CLIENT_PRODUCT}": "#{ChefCLI::Dist::INFRA_CLIENT_GEM}",
109
- "#{ChefCLI::Dist::INSPEC_PRODUCT}": "#{ChefCLI::Dist::INSPEC_CLI}",
110
- "#{ChefCLI::Dist::CLI_PRODUCT}": "#{ChefCLI::Dist::CLI_GEM}",
107
+ msg("#{ChefCLI::Dist::PRODUCT} version: #{component_version("build_version")}")
108
+
109
+ { "#{ChefCLI::Dist::INFRA_CLIENT_PRODUCT}": ChefCLI::Dist::INFRA_CLIENT_GEM,
110
+ "#{ChefCLI::Dist::INSPEC_PRODUCT}": ChefCLI::Dist::INSPEC_CLI,
111
+ "#{ChefCLI::Dist::CLI_PRODUCT}": ChefCLI::Dist::CLI_GEM,
112
+ "#{ChefCLI::Dist::HAB_PRODUCT}": ChefCLI::Dist::HAB_SOFTWARE_NAME,
111
113
  "Test Kitchen": "test-kitchen",
112
114
  "Cookstyle": "cookstyle",
113
- }.each do |name, gem|
114
- msg("#{name} version: #{gem_version(gem)}")
115
- end
116
- end
117
-
118
- def show_version_via_shell_out
119
- msg("#{ChefCLI::Dist::PRODUCT} version: #{ChefCLI::VERSION}")
120
- { "#{ChefCLI::Dist::INFRA_CLIENT_PRODUCT}": "#{ChefCLI::Dist::INFRA_CLIENT_CLI}",
121
- "#{ChefCLI::Dist::INSPEC_PRODUCT}": "#{ChefCLI::Dist::INSPEC_CLI}",
122
- "Test Kitchen": "kitchen",
123
- "Cookstyle": "cookstyle",
124
- }.each do |name, cli|
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
-
132
- if result.exitstatus != 0
133
- msg("#{name} version: ERROR")
134
- else
135
- version = result.stdout.lines.first.scan(/(?:master\s)?[\d+\.\(\)]+\S+/).join("\s")
136
- msg("#{name} version: #{version}")
137
- end
115
+ }.each do |prod_name, component|
116
+ msg("#{prod_name} version: #{component_version(component)}")
138
117
  end
139
118
  end
140
119
 
@@ -170,8 +149,15 @@ module ChefCLI
170
149
  commands_map.command_specs
171
150
  end
172
151
 
152
+ #
153
+ # Is a passed parameter actually an option aka does it start with '-'
154
+ #
155
+ # @param [String] param The passed parameter to check
156
+ #
157
+ # @return [Boolean]
158
+ #
173
159
  def option?(param)
174
- param =~ /^-/
160
+ param[0] == "-"
175
161
  end
176
162
 
177
163
  def instantiate_subcommand(name)
@@ -188,21 +174,23 @@ module ChefCLI
188
174
  end
189
175
  end
190
176
 
191
- def gem_version(name)
177
+ def component_version(name)
192
178
  if gem_manifest_hash[name].is_a?(Array)
193
179
  gem_manifest_hash[name].first
180
+ elsif manifest_hash.key? name
181
+ manifest_field(name)
194
182
  else
195
- "unknown"
183
+ manifest_hash.dig("software", name, "locked_version") || "unknown"
196
184
  end
197
185
  end
198
186
 
199
187
  def manifest_hash
200
- require "json"
188
+ require "json" unless defined?(JSON)
201
189
  @manifest_hash ||= JSON.parse(read_version_manifest_json)
202
190
  end
203
191
 
204
192
  def gem_manifest_hash
205
- require "json"
193
+ require "json" unless defined?(JSON)
206
194
  @gem_manifest_hash ||= JSON.parse(read_gem_version_manifest_json)
207
195
  end
208
196
 
@@ -243,7 +231,7 @@ module ChefCLI
243
231
  # catch the cases where users setup only the embedded_bin_dir in their path, or
244
232
  # when they have the embedded_bin_dir before the omnibus_bin_dir -- both of which will
245
233
  # defeat appbundler and interact very badly with our intent.
246
- def sanity_check!
234
+ def path_check!
247
235
  # When installed outside of omnibus, trust the user to configure their PATH
248
236
  return true unless omnibus_install?
249
237
 
@@ -21,7 +21,7 @@ require_relative "../ui"
21
21
  require_relative "../version"
22
22
  require_relative "../dist"
23
23
  require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
24
- require "yaml"
24
+ require "yaml" unless defined?(YAML)
25
25
 
26
26
  module ChefCLI
27
27
  module Command
@@ -20,7 +20,6 @@ require_relative "../dist"
20
20
  require "rubygems" unless defined?(Gem)
21
21
  require "rubygems/gem_runner"
22
22
  require "rubygems/exceptions"
23
- require "pp" unless defined?(PP)
24
23
 
25
24
  module ChefCLI
26
25
  module Command
@@ -16,7 +16,6 @@
16
16
  #
17
17
 
18
18
  require "mixlib/cli" unless defined?(Mixlib::CLI)
19
- require "rbconfig"
20
19
  require "pathname" unless defined?(Pathname)
21
20
  require_relative "base"
22
21
  require_relative "../chef_runner"
@@ -38,7 +37,7 @@ module ChefCLI
38
37
  long: "--license LICENSE",
39
38
  description: "all_rights, apachev2, mit, gplv2, gplv3 - defaults to all_rights",
40
39
  proc: Proc.new { |l|
41
- l =~ /apache2/ ? "apachev2" : l
40
+ /apache2/.match?(l) ? "apachev2" : l
42
41
  },
43
42
  default: nil
44
43
 
@@ -187,27 +187,30 @@ module ChefCLI
187
187
  @verbose
188
188
  end
189
189
 
190
+ #
191
+ # Is there a .delivery/cli.toml in the current dir or any of the parent dirs
192
+ #
193
+ # @return [Boolean]
194
+ #
190
195
  def have_delivery_config?
191
196
  # delivery-cli's logic is to look recursively upward for
192
197
  # .delivery/cli.toml starting from pwd:
193
198
  # https://github.com/chef/delivery-cli/blob/22cbef3987ebd0aee98405b7e161a100edc87e49/src/delivery/config/mod.rs#L225-L247
194
199
 
195
- path_to_check = File.expand_path(Dir.pwd)
196
- result = false
197
-
198
- Pathname.new(path_to_check).ascend do |path|
199
- if contains_delivery_cli_toml?(path)
200
- result = true
201
- break
202
- end
200
+ Pathname.new(Dir.pwd).ascend do |path|
201
+ return true if contains_delivery_cli_toml?(path)
203
202
  end
204
203
 
205
- result
204
+ false # nothing was found
206
205
  end
207
206
 
207
+ #
208
+ # @param [Pathname] path a directory
209
+ #
210
+ # @return [Boolean] delivery cli.toml exists
211
+ #
208
212
  def contains_delivery_cli_toml?(path)
209
- delivery_cli_path = path.join(".delivery/cli.toml")
210
- delivery_cli_path.exist?
213
+ path.join(".delivery/cli.toml").exist?
211
214
  end
212
215
 
213
216
  def read_and_validate_params
@@ -215,7 +218,7 @@ module ChefCLI
215
218
  @cookbook_name_or_path = arguments[0]
216
219
  if !@cookbook_name_or_path
217
220
  @params_valid = false
218
- elsif /-/ =~ File.basename(@cookbook_name_or_path)
221
+ elsif File.basename(@cookbook_name_or_path).include?("-")
219
222
  msg("Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/ctl_chef/#chef-generate-cookbook for more information.")
220
223
  end
221
224
 
@@ -15,8 +15,6 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "ostruct"
19
-
20
18
  require_relative "base"
21
19
  require_relative "../chef_runner"
22
20
  require_relative "../dist"
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "erb"
18
+ require "erb" unless defined?(ERB)
19
19
 
20
20
  require_relative "../commands_map"
21
21
  require_relative "../builtin_commands"
@@ -70,7 +70,7 @@ module ChefCLI
70
70
 
71
71
  option :exclude_deps,
72
72
  long: "--exclude-deps",
73
- description: "Only update cookbooks explicitely mentioned on the command line",
73
+ description: "Only update cookbooks explicitly mentioned on the command line",
74
74
  boolean: true,
75
75
  default: false
76
76
 
@@ -31,7 +31,7 @@ module ChefCLI
31
31
  @unborn_branch_ref = nil
32
32
  end
33
33
 
34
- # @return [Hash] Hashed used for pinning cookbook versions within a Policfile.lock
34
+ # @return [Hash] Hashed used for pinning cookbook versions within a Policyfile.lock
35
35
  def profile_data
36
36
  {
37
37
  "scm" => "git",
@@ -35,5 +35,10 @@ module ChefCLI
35
35
 
36
36
  # Chef-Zero's product name
37
37
  ZERO_PRODUCT = "Chef Infra Zero".freeze
38
+
39
+ HAB_PRODUCT = "Chef Habitat".freeze
40
+ HAB_SOFTWARE_NAME = "habitat".freeze
41
+
42
+ HAB_CLI = "hab".freeze
38
43
  end
39
44
  end
@@ -15,11 +15,11 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "json"
18
+ require "json" unless defined?(JSON)
19
19
  require_relative "../cookbook_omnifetch"
20
20
  require_relative "source_uri"
21
21
  require_relative "../exceptions"
22
- require "chef/http/simple"
22
+ require "chef/http/simple" unless defined?(Chef::HTTP::Simple)
23
23
 
24
24
  module ChefCLI
25
25
  module Policyfile
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "chef/mash"
18
+ require "chef/mash" unless defined?(Mash)
19
19
 
20
20
  module ChefCLI
21
21
  module Policyfile
@@ -67,7 +67,7 @@ module ChefCLI
67
67
  errors.empty?
68
68
  end
69
69
 
70
- # Check the options provided when craeting this class for errors
70
+ # Check the options provided when creating this class for errors
71
71
  #
72
72
  # @return [Array<String>] A list of errors found
73
73
  def errors
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "json"
18
+ require "json" unless defined?(JSON)
19
19
  require_relative "../cookbook_omnifetch"
20
20
  require_relative "../exceptions"
21
21
  require "chef/http/simple"
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "semverse"
18
+ require "semverse" unless defined?(Semverse)
19
19
  require_relative "../cookbook_omnifetch"
20
20
  require_relative "storage_config"
21
21
 
@@ -400,8 +400,8 @@ module ChefCLI
400
400
 
401
401
  dot_git = Pathname.new(".git")
402
402
  Pathname.new(cookbook_path).ascend do |parent_dir|
403
- possbile_git_dir = parent_dir + dot_git
404
- if possbile_git_dir.exist?
403
+ possible_git_dir = parent_dir + dot_git
404
+ if possible_git_dir.exist?
405
405
  @cookbook_in_git_repo = true
406
406
  break
407
407
  end
@@ -16,9 +16,7 @@
16
16
  #
17
17
 
18
18
  require "forwardable" unless defined?(Forwardable)
19
-
20
- require "semverse"
21
-
19
+ require "semverse" unless defined?(Semverse)
22
20
  require_relative "community_cookbook_source"
23
21
 
24
22
  module ChefCLI
@@ -39,7 +37,7 @@ module ChefCLI
39
37
  # * Version numbers for cookbooks that pass through the Ci pipeline always
40
38
  # increase over time (so that largest version number == newest)
41
39
  #
42
- # In the future, alternative approaches may be persued to achieve the goal
40
+ # In the future, alternative approaches may be pursued to achieve the goal
43
41
  # of continuously integrating at the cookbook level without imposing those
44
42
  # constraints.
45
43
  #
@@ -17,7 +17,7 @@
17
17
 
18
18
  require "diff/lcs"
19
19
  require "diff/lcs/hunk"
20
- require "paint"
20
+ require "pastel"
21
21
  require "ffi_yajl" unless defined?(FFI_Yajl)
22
22
 
23
23
  module ChefCLI
@@ -215,9 +215,15 @@ module ChefCLI
215
215
  ui.print("\n")
216
216
  end
217
217
 
218
+ def pastel
219
+ @pastel ||= Pastel.new
220
+ end
221
+
218
222
  def print_color_diff(hunk)
219
223
  hunk.to_s.each_line do |line|
220
- ui.print(Paint[line, color_for_line(line)])
224
+ line_color = color_for_line(line)
225
+ line = pastel.decorate(line, line_color) unless line_color.nil?
226
+ ui.print(line)
221
227
  end
222
228
  end
223
229
 
@@ -233,7 +233,7 @@ module ChefCLI
233
233
  message = "#{run_list_desc} has invalid cookbook name '#{cookbook}'.\nCookbook names can only contain alphanumerics, hyphens, and underscores."
234
234
 
235
235
  # Special case when there's only one colon instead of two:
236
- if cookbook =~ /[^:]:[^:]/
236
+ if /[^:]:[^:]/.match?(cookbook)
237
237
  message << "\nDid you mean '#{item.sub(":", "::")}'?"
238
238
  end
239
239
 
@@ -48,7 +48,7 @@ module ChefCLI
48
48
  errors.empty?
49
49
  end
50
50
 
51
- # Check the options provided when craeting this class for errors
51
+ # Check the options provided when creating this class for errors
52
52
  #
53
53
  # @return [Array<String>] A list of errors found
54
54
  def errors
@@ -85,7 +85,7 @@ module ChefCLI
85
85
  errors.empty?
86
86
  end
87
87
 
88
- # Check the options provided when craeting this class for errors
88
+ # Check the options provided when creating this class for errors
89
89
  #
90
90
  # @return [Array<String>] A list of errors found
91
91
  def errors
@@ -89,9 +89,9 @@ module ChefCLI
89
89
  @cookbook_version ||=
90
90
  begin
91
91
  cookbook_version = loader.cookbook_version
92
- # TODO: dont do this for non-compat mode
92
+ # TODO: don't do this for non-compat mode
93
93
  cookbook_version.version = version_override
94
- # TODO: dont do this either
94
+ # TODO: don't do this either
95
95
 
96
96
  # Fixup manifest.
97
97
  # What happens is, the 'manifest' representation of cookbook
@@ -274,7 +274,7 @@ module ChefCLI
274
274
  # compared to an unmodified copy upstream. For example, the community site
275
275
  # may have a cookbook "apache2" at version "1.10.4", which the user has
276
276
  # forked on github and modified the dependencies without changing the
277
- # version number. To accomodate this, the local_artifacts_graph should be
277
+ # version number. To accommodate this, the local_artifacts_graph should be
278
278
  # merged over the upstream's artifacts graph.
279
279
  def local_artifacts_graph
280
280
  cookbook_location_specs.inject({}) do |local_artifacts, (cookbook_name, cookbook_location_spec)|
@@ -1,4 +1,3 @@
1
- # -*- coding: UTF-8 -*-
2
1
  #
3
2
  # Copyright:: Copyright (c) 2014-2018 Chef Software Inc.
4
3
  # License:: Apache License, Version 2.0
@@ -362,7 +361,7 @@ module ChefCLI
362
361
  # doubles give 15-17 digits of precision, so we err on the safe side
363
362
  # and only use 15 digits in the string conversion. We use the `g`
364
363
  # format, which is a documented-enough "do what I mean" where floats
365
- # >= 0.1 and < precsion are represented as floating point literals, and
364
+ # >= 0.1 and < precision are represented as floating point literals, and
366
365
  # other numbers use the exponent notation with a lowercase 'e'. Note
367
366
  # that both Ruby and Erlang document what their `g` does but have some
368
367
  # differences both subtle and non-subtle:
@@ -9,6 +9,7 @@ ehthumbs.db
9
9
  Icon?
10
10
  nohup.out
11
11
  Thumbs.db
12
+ .envrc
12
13
 
13
14
  # EDITORS #
14
15
  ###########
@@ -45,17 +46,23 @@ mkmf.log
45
46
  ###########
46
47
  .circleci/*
47
48
  .codeclimate.yml
49
+ .delivery/*
48
50
  .foodcritic
49
51
  .kitchen*
52
+ .mdlrc
53
+ .overcommit.yml
50
54
  .rspec
51
55
  .rubocop.yml
52
56
  .travis.yml
53
57
  .watchr
58
+ .yamllint
54
59
  azure-pipelines.yml
60
+ Dangerfile
55
61
  examples/*
56
62
  features/*
57
63
  Guardfile
58
64
  kitchen.yml*
65
+ mlc_config.json
59
66
  Procfile
60
67
  Rakefile
61
68
  spec/*
@@ -68,6 +75,7 @@ test/*
68
75
  .gitconfig
69
76
  .github/*
70
77
  .gitignore
78
+ .gitkeep
71
79
  .gitmodules
72
80
  .svn
73
81
  */.bzr/*
@@ -95,10 +103,11 @@ Policyfile.lock.json
95
103
 
96
104
  # Documentation #
97
105
  #############
98
- CHANGELOG*
106
+ CODE_OF_CONDUCT*
99
107
  CONTRIBUTING*
108
+ documentation/*
100
109
  TESTING*
101
- CODE_OF_CONDUCT*
110
+ UPGRADING*
102
111
 
103
112
  # Vagrant #
104
113
  ###########
@@ -1,7 +1,7 @@
1
1
  # InSpec test for recipe <%= cookbook_name %>::<%= recipe_name %>
2
2
 
3
3
  # The InSpec reference, with examples and extensive documentation, can be
4
- # found at https://www.inspec.io/docs/reference/resources/
4
+ # found at https://docs.chef.io/inspec/resources/
5
5
 
6
6
  unless os.windows?
7
7
  # This is an example test, replace with your own test.
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "3.0.10".freeze
19
+ VERSION = "3.0.23".freeze
20
20
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Marc Paradise <marc@chef.io>
4
3
  #
@@ -16,7 +15,7 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require "json"
18
+ require "json" unless defined?(JSON)
20
19
  require "kitchen"
21
20
  require "kitchen/provisioner/base"
22
21
  require "kitchen/provisioner/chef_zero"
@@ -45,7 +44,7 @@ module Kitchen
45
44
  #
46
45
  # This provisioner does not do any cookbook dependency
47
46
  # resolution and will not pull in external cookbooks. All cookbooks
48
- # or cookbook artificats + policy data as captured from the live node and are
47
+ # or cookbook artifacts + policy data as captured from the live node and are
49
48
  # expected to be available for chef-zero to provide to the client.
50
49
  class ChefZeroCapture < ChefZero
51
50
  # Declaring these ensure that they're available to the sandbox - it's initialized
@@ -55,7 +54,7 @@ module Kitchen
55
54
  default_config :cookbook_artifacts_path, "cookbook_artifacts"
56
55
 
57
56
  # 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.
57
+ # dependencies from chef-zero, exactly as prepped in the captured repository.
59
58
  def load_needed_dependencies!; end
60
59
 
61
60
  def create_sandbox
@@ -73,7 +72,7 @@ module Kitchen
73
72
  end
74
73
 
75
74
  # Overriding the private ProviderChefZero#default_config_rb
76
- # so that we can add additional configuratoin required for chef-zeor
75
+ # so that we can add additional configuration required for chef-zero
77
76
  # to be able to locate our policies/, policy groups, and cookbook artifacts
78
77
  # at run-time.
79
78
  def default_config_rb
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -54,7 +53,7 @@ module Kitchen
54
53
  # @author Daniel DeLeo <dan@chef.io>
55
54
  class PolicyfileZero < ChefBase
56
55
 
57
- # This provsioner will forcibly set the following config options:
56
+ # This provisioner will forcibly set the following config options:
58
57
  # * `use_policyfile`: `true`
59
58
  # * `versioned_cookbooks`: `true`
60
59
  # * `deployment_group`: `POLICY_NAME-local`
@@ -53,11 +53,9 @@ describe ChefCLI::CLI do
53
53
  E
54
54
  end
55
55
 
56
- let(:version_message) { "#{ChefCLI::Dist::PRODUCT} version: #{ChefCLI::VERSION}\n" }
57
-
58
56
  def run_cli(expected_exit_code)
59
57
  expect(cli).to receive(:exit).with(expected_exit_code)
60
- expect(cli).to receive(:sanity_check!)
58
+ expect(cli).to receive(:path_check!)
61
59
  cli.run
62
60
  end
63
61
 
@@ -66,16 +64,6 @@ describe ChefCLI::CLI do
66
64
  cli.run
67
65
  end
68
66
 
69
- def run_cli_and_validate_tool_versions
70
- full_version_message = version_message
71
- tools.each do |name, details|
72
- expect(cli).to receive(:shell_out).with("#{details["command"]} --version").and_return(mock_shell_out(0, "#{details["version_output"]}", ""))
73
- full_version_message += "#{name} version: #{details["expected_version"]}\n"
74
- end
75
- run_cli(0)
76
- expect(stdout).to eq(full_version_message)
77
- end
78
-
79
67
  def mock_shell_out(exitstatus, stdout, stderr)
80
68
  shell_out = double("mixlib_shell_out")
81
69
  allow(shell_out).to receive(:exitstatus).and_return(exitstatus)
@@ -121,12 +109,17 @@ describe ChefCLI::CLI do
121
109
  context "given -v" do
122
110
  let(:argv) { %w{-v} }
123
111
 
124
- context "#via_version_manifest" do
112
+ context "when installed via omnibus" do
125
113
  let(:mocked_version_manifest_json) do
126
114
  <<~E
127
115
  {
128
116
  "manifest_format": 2,
129
- "build_version": "d.e.v"
117
+ "build_version": "d.e.v",
118
+ "software": {
119
+ "habitat": {
120
+ "locked_version": "1.2.3"
121
+ }
122
+ }
130
123
  }
131
124
  E
132
125
  end
@@ -160,6 +153,7 @@ describe ChefCLI::CLI do
160
153
  Chef Infra Client version: 0.0.2
161
154
  Chef InSpec version: 0.0.3
162
155
  Chef CLI version: 0.0.1
156
+ Chef Habitat version: 1.2.3
163
157
  Test Kitchen version: 0.0.4
164
158
  Cookstyle version: 0.0.6
165
159
  E
@@ -171,6 +165,7 @@ describe ChefCLI::CLI do
171
165
  Chef Infra Client version: unknown
172
166
  Chef InSpec version: unknown
173
167
  Chef CLI version: unknown
168
+ Chef Habitat version: unknown
174
169
  Test Kitchen version: unknown
175
170
  Cookstyle version: unknown
176
171
  E
@@ -195,49 +190,15 @@ describe ChefCLI::CLI do
195
190
  end
196
191
  end
197
192
 
198
- context "#via_shell_out" do
199
- let(:tools) do
200
- {
201
- "Chef Infra Client" => {
202
- "command" => "chef-client",
203
- "version_output" => "Chef Infra Client: 15.0.300",
204
- "expected_version" => "15.0.300",
205
- },
206
- "Chef InSpec" => {
207
- "command" => "inspec",
208
- "version_output" => "4.6.2\n\nYour version of InSpec is out of date! The latest version is 4.6.4.",
209
- "expected_version" => "4.6.2",
210
- },
211
- "Test Kitchen" => {
212
- "command" => "kitchen",
213
- "version_output" => "Test Kitchen version 2.2.5",
214
- "expected_version" => "2.2.5",
215
- },
216
- "Cookstyle" => {
217
- "command" => "cookstyle",
218
- "version_output" => "Cookstyle 4.0.0\n * RuboCop 0.62.0",
219
- "expected_version" => "4.0.0",
220
- },
221
- }
222
- end
223
-
224
- it "does not print versions of tools with missing or errored tools" do
225
- full_version_message = version_message
226
- tools.each do |name, details|
227
- if name == "inspec"
228
- expect(cli).to receive(:shell_out).with("#{details["command"]} --version").and_return(mock_shell_out(1, "#{details["version_output"]}", ""))
229
- full_version_message += "#{name} version: ERROR\n"
230
- else
231
- expect(cli).to receive(:shell_out).with("#{details["command"]} --version").and_return(mock_shell_out(0, "#{details["version_output"]}", ""))
232
- full_version_message += "#{name} version: #{details["expected_version"]}\n"
233
- end
234
- end
235
- run_cli(0)
236
- expect(stdout).to eq(full_version_message)
193
+ context "when installed as a gem" do
194
+ let(:gem_version_message) { "#{ChefCLI::Dist::CLI_PRODUCT} version: #{ChefCLI::VERSION}\n" }
195
+ before do
196
+ allow(cli).to receive(:omnibus_install?).and_return false
237
197
  end
238
198
 
239
199
  it "prints the version and versions of chef-cli tools" do
240
- run_cli_and_validate_tool_versions
200
+ run_cli(0)
201
+ expect(stdout).to eq(gem_version_message)
241
202
  end
242
203
  end
243
204
  end
@@ -295,7 +256,7 @@ describe ChefCLI::CLI do
295
256
  end
296
257
  end
297
258
 
298
- context "sanity_check!" do
259
+ context "path_check!" do
299
260
 
300
261
  before do
301
262
  allow(Gem).to receive(:ruby).and_return(ruby_path)
@@ -50,9 +50,9 @@ describe ChefCLI::Command::CleanPolicyCookbooks do
50
50
 
51
51
  context "when given a path to the config" do
52
52
 
53
- let(:params) { %w{ -c ~/otherstuff/config.rb } }
53
+ let(:params) { %w{ -c ~/other_stuff/config.rb } }
54
54
 
55
- let(:config_arg) { "~/otherstuff/config.rb" }
55
+ let(:config_arg) { "~/other_stuff/config.rb" }
56
56
 
57
57
  before do
58
58
  expect(chef_config_loader).to receive(:load)
@@ -16,7 +16,7 @@
16
16
  #
17
17
 
18
18
  require "spec_helper"
19
- require "yaml"
19
+ require "yaml" unless defined?(YAML)
20
20
  require "chef-cli/command/env"
21
21
 
22
22
  describe ChefCLI::Command::Env do
@@ -69,7 +69,7 @@ describe ChefCLI::Command::Env do
69
69
  it "output should be valid yaml" do
70
70
  expect { yaml }.not_to raise_error
71
71
  end
72
- it "Workstation version should indicate that that we're not runnign from a WS install" do
72
+ it "Workstation version should indicate that that we're not running from a WS install" do
73
73
  expect(yaml).to have_key ChefCLI::Dist::PRODUCT
74
74
  expect(yaml[ChefCLI::Dist::PRODUCT]["Version"]).to eql "Not running from within Workstation"
75
75
  end
@@ -59,7 +59,7 @@ describe ChefCLI::Command::Exec do
59
59
  before do
60
60
  allow(Gem).to receive(:ruby).and_return(ruby_path)
61
61
 
62
- # Using a fake path separator to keep to prevent people from accidently
62
+ # Using a fake path separator to keep to prevent people from accidentally
63
63
  # getting things correct on their system. This enforces that, in general,
64
64
  # you should use the path separator ruby is telling you to use.
65
65
  stub_const("File::PATH_SEPARATOR", "<>")
@@ -25,7 +25,7 @@ describe ChefCLI::CommandsMap do
25
25
 
26
26
  before do
27
27
  mapping.builtin("example", :Example)
28
- mapping.builtin("hypenated-example", :HyphenatedExample)
28
+ mapping.builtin("hyphenated-example", :HyphenatedExample)
29
29
  mapping.builtin("explicit-path-example", :ExplicitPathExample, require_path: "unit/fixtures/command/explicit_path_example")
30
30
  mapping.builtin("documented-example", :DocumentedExample, desc: "I have documentation")
31
31
  end
@@ -34,16 +34,16 @@ describe ChefCLI::CommandsMap do
34
34
  expect(mapping.have_command?("example")).to be true
35
35
  end
36
36
 
37
- it "infers a non-hypenated command's require path" do
37
+ it "infers a non-hyphenated command's require path" do
38
38
  expect(mapping.spec_for("example").require_path).to eq("chef-cli/command/example")
39
39
  end
40
40
 
41
41
  it "infers a hyphenated command's require path" do
42
- expect(mapping.spec_for("hypenated-example").require_path).to eq("chef-cli/command/hypenated_example")
42
+ expect(mapping.spec_for("hyphenated-example").require_path).to eq("chef-cli/command/hyphenated_example")
43
43
  end
44
44
 
45
45
  it "lists the available commands" do
46
- expect(mapping.command_names).to match_array(%w{example hypenated-example explicit-path-example documented-example})
46
+ expect(mapping.command_names).to match_array(%w{example hyphenated-example explicit-path-example documented-example})
47
47
  end
48
48
 
49
49
  it "keeps the docstring of a command" do
@@ -1,6 +1,6 @@
1
1
  require "openssl"
2
2
  require "net/https"
3
- require "json"
3
+ require "json" unless defined?(JSON)
4
4
  require "pp"
5
5
  require "uri"
6
6
 
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Marc Paradsie <marc.paradise@gmail.com>
4
3
  #
@@ -243,7 +243,7 @@ describe ChefCLI::Policyfile::Differ do
243
243
 
244
244
  def output
245
245
  # ANSI codes make the tests harder to read
246
- Paint.unpaint(ui.output)
246
+ Pastel.new.strip(ui.output)
247
247
  end
248
248
 
249
249
  subject(:differ) do
@@ -1,4 +1,3 @@
1
- # -*- coding: UTF-8 -*-
2
1
  #
3
2
  # Copyright:: Copyright (c) 2014-2018, Chef Software Inc.
4
3
  # License:: Apache License, Version 2.0
@@ -1,4 +1,3 @@
1
- # -*- coding: UTF-8 -*-
2
1
  #
3
2
  # Copyright:: Copyright (c) 2017 Chef Software Inc.
4
3
  # License:: Apache License, Version 2.0
@@ -1,4 +1,3 @@
1
- # -*- coding: UTF-8 -*-
2
1
  #
3
2
  # Copyright:: Copyright (c) 2014-2018 Chef Software Inc.
4
3
  # License:: Apache License, Version 2.0
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.10
4
+ version: 3.0.23
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-06-18 00:00:00.000000000 Z
11
+ date: 2020-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -156,36 +156,36 @@ 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
- name: paint
176
+ name: pastel
171
177
  requirement: !ruby/object:Gem::Requirement
172
178
  requirements:
173
- - - ">="
174
- - !ruby/object:Gem::Version
175
- version: '1'
176
- - - "<"
179
+ - - "~>"
177
180
  - !ruby/object:Gem::Version
178
- version: '3'
181
+ version: '0.7'
179
182
  type: :runtime
180
183
  prerelease: false
181
184
  version_requirements: !ruby/object:Gem::Requirement
182
185
  requirements:
183
- - - ">="
184
- - !ruby/object:Gem::Version
185
- version: '1'
186
- - - "<"
186
+ - - "~>"
187
187
  - !ruby/object:Gem::Version
188
- version: '3'
188
+ version: '0.7'
189
189
  - !ruby/object:Gem::Dependency
190
190
  name: license-acceptance
191
191
  requirement: !ruby/object:Gem::Requirement