chef-cli 3.0.16 → 3.0.30

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -1
  3. data/bin/chef-cli +2 -2
  4. data/chef-cli.gemspec +2 -2
  5. data/lib/chef-cli/cli.rb +18 -7
  6. data/lib/chef-cli/command/env.rb +2 -2
  7. data/lib/chef-cli/command/gem.rb +0 -1
  8. data/lib/chef-cli/command/generator_commands.rb +1 -2
  9. data/lib/chef-cli/command/generator_commands/cookbook.rb +7 -17
  10. data/lib/chef-cli/command/provision.rb +0 -2
  11. data/lib/chef-cli/command/shell_init.rb +1 -1
  12. data/lib/chef-cli/cookbook_profiler/identifiers.rb +1 -1
  13. data/lib/chef-cli/generator.rb +1 -1
  14. data/lib/chef-cli/helpers.rb +1 -1
  15. data/lib/chef-cli/policyfile/artifactory_cookbook_source.rb +2 -2
  16. data/lib/chef-cli/policyfile/attribute_merge_checker.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/delivery_supermarket_source.rb +1 -3
  20. data/lib/chef-cli/policyfile/differ.rb +8 -2
  21. data/lib/chef-cli/policyfile/dsl.rb +1 -1
  22. data/lib/chef-cli/policyfile/storage_config.rb +1 -1
  23. data/lib/chef-cli/policyfile_services/export_repo.rb +1 -1
  24. data/lib/chef-cli/policyfile_services/install.rb +7 -5
  25. data/lib/chef-cli/policyfile_services/push_archive.rb +1 -1
  26. data/lib/chef-cli/version.rb +1 -1
  27. data/lib/kitchen/provisioner/chef_zero_capture.rb +1 -1
  28. data/spec/test_helpers.rb +2 -2
  29. data/spec/unit/cli_spec.rb +6 -3
  30. data/spec/unit/command/env_spec.rb +1 -1
  31. data/spec/unit/command/exec_spec.rb +1 -1
  32. data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +5 -8
  33. data/spec/unit/policyfile/differ_spec.rb +1 -1
  34. data/spec/unit/policyfile/storage_config_spec.rb +2 -2
  35. data/spec/unit/policyfile_services/install_spec.rb +20 -0
  36. data/spec/unit/service_exception_inspectors/http_spec.rb +1 -1
  37. metadata +13 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ba95803ebaddd3034b21130fda13e0a001c5ef02b304897d7808c0286268d9b
4
- data.tar.gz: 7c64aed7f98666dc5677f11036cbbb7671cc9d8d09f410f25222332c1fd10ac6
3
+ metadata.gz: 8a39366b7f1920937b7329ef1a5b54d810d4b3c017e331926608356c55c68250
4
+ data.tar.gz: 20882fcd4590d7969d7afd83aec868e89be1c032651dc594dcc61f4eee2eb632
5
5
  SHA512:
6
- metadata.gz: a42c1780fe0865c527c8787bd1122abcb06867b0f3e01e142684ac2cda519215c9801d031c6266ac94c7965d890dd5c6e0af8eebb195aecdfd0fa36f0691422c
7
- data.tar.gz: 3133b68e4e51bd548e180bdbf3d8bae0735834118e0c9b81a781b0e869196a4108ea72ea38904cc1662a3d1863af4dcdf92a5508073efcd53408e7704f792c9e
6
+ metadata.gz: 621b7594acfcb6968c5ddd3d690fc49a86b4c6932d4011debdadee19d86d638b7caea04eba2aa89776be213533ec4c14be65b715418edf83a39fda0f651c8bba
7
+ data.tar.gz: 315dd298b75add288ff031a1c9b7d3a0d5d4994454476570b4fd3c46a4c0ae3d693ecc8d9ac0b43aa5c10f3ffa1901921fb841e63198612b84d0cbb6e630d582
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ 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", "6.13.3" # this forces dependabot PRs to open which triggers cookstyle CI on the chef generate command
16
+ gem "cookstyle", "6.14.7" # this forces dependabot PRs to open which triggers cookstyle CI on the chef generate command
17
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")
@@ -28,3 +28,9 @@ group :development do
28
28
  gem "pry-stack_explorer", "~> 0.4.0"
29
29
  gem "rb-readline"
30
30
  end
31
+
32
+ group :profile do
33
+ gem "stackprof"
34
+ gem "stackprof-webnav"
35
+ gem "memory_profiler"
36
+ end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # Copyright:: Copyright (c) 2014-2018 Chef Software Inc.
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,7 @@
19
19
  # Set a trap for ctrl-C right away so we don't surface interrupt exceptions inside of rubygems or whatever.
20
20
  Kernel.trap(:INT) { print("\n"); exit 1 }
21
21
 
22
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
22
+ $:.unshift(File.expand_path(File.join(__dir__, "..", "lib")))
23
23
  require "chef-cli/cli"
24
24
 
25
25
  ChefCLI::CLI.new(ARGV.clone).run(enforce_license: true)
@@ -48,6 +48,6 @@ Gem::Specification.new do |gem|
48
48
  gem.add_dependency "addressable", ">= 2.3.5", "< 2.8"
49
49
  gem.add_dependency "cookbook-omnifetch", "~> 0.5"
50
50
  gem.add_dependency "diff-lcs", ">= 1.0", "< 1.4" # 1.4 changes the output
51
- gem.add_dependency "paint", ">= 1", "< 3"
52
- gem.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.11"
51
+ gem.add_dependency "pastel", "~> 0.7" # used for policyfile differ
52
+ gem.add_dependency "license-acceptance", ">= 1.0.11", "< 3"
53
53
  end
@@ -33,6 +33,10 @@ module ChefCLI
33
33
  include Chef::Mixin::ShellOut
34
34
 
35
35
  banner(<<~BANNER)
36
+ The Chef command line tool for managing your infrastructure from your workstation.
37
+ Docs: https://docs.chef.io/workstation/
38
+ Patents: https://www.chef.io/patents
39
+
36
40
  Usage:
37
41
  #{ChefCLI::Dist::EXEC} -h/--help
38
42
  #{ChefCLI::Dist::EXEC} -v/--version
@@ -59,7 +63,7 @@ module ChefCLI
59
63
  end
60
64
 
61
65
  def run(enforce_license: false)
62
- sanity_check!
66
+ path_check!
63
67
 
64
68
  subcommand_name, *subcommand_params = argv
65
69
 
@@ -119,13 +123,13 @@ module ChefCLI
119
123
 
120
124
  def show_help
121
125
  msg(banner)
122
- msg("\nAvailable Commands:")
126
+ msg("Available Commands:")
123
127
 
124
128
  justify_length = subcommands.map(&:length).max + 2
125
129
  subcommand_specs.each do |name, spec|
126
130
  next if spec.hidden
127
131
 
128
- msg(" #{"#{name}".ljust(justify_length)}#{spec.description}")
132
+ msg(" #{name.to_s.ljust(justify_length)}#{spec.description}")
129
133
  end
130
134
  end
131
135
 
@@ -149,8 +153,15 @@ module ChefCLI
149
153
  commands_map.command_specs
150
154
  end
151
155
 
156
+ #
157
+ # Is a passed parameter actually an option aka does it start with '-'
158
+ #
159
+ # @param [String] param The passed parameter to check
160
+ #
161
+ # @return [Boolean]
162
+ #
152
163
  def option?(param)
153
- param =~ /^-/
164
+ param[0] == "-"
154
165
  end
155
166
 
156
167
  def instantiate_subcommand(name)
@@ -178,12 +189,12 @@ module ChefCLI
178
189
  end
179
190
 
180
191
  def manifest_hash
181
- require "json"
192
+ require "json" unless defined?(JSON)
182
193
  @manifest_hash ||= JSON.parse(read_version_manifest_json)
183
194
  end
184
195
 
185
196
  def gem_manifest_hash
186
- require "json"
197
+ require "json" unless defined?(JSON)
187
198
  @gem_manifest_hash ||= JSON.parse(read_gem_version_manifest_json)
188
199
  end
189
200
 
@@ -224,7 +235,7 @@ module ChefCLI
224
235
  # catch the cases where users setup only the embedded_bin_dir in their path, or
225
236
  # when they have the embedded_bin_dir before the omnibus_bin_dir -- both of which will
226
237
  # defeat appbundler and interact very badly with our intent.
227
- def sanity_check!
238
+ def path_check!
228
239
  # When installed outside of omnibus, trust the user to configure their PATH
229
240
  return true unless omnibus_install?
230
241
 
@@ -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
@@ -37,7 +37,7 @@ module ChefCLI
37
37
 
38
38
  def run(params)
39
39
  info = {}
40
- info["#{ChefCLI::Dist::PRODUCT}"] = workstation_info
40
+ info[ChefCLI::Dist::PRODUCT] = workstation_info
41
41
  info["Ruby"] = ruby_info
42
42
  info["Path"] = paths
43
43
  ui.msg info.to_yaml
@@ -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,17 @@ 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
203
- end
204
-
205
- result
206
- end
207
-
208
- def contains_delivery_cli_toml?(path)
209
- delivery_cli_path = path.join(".delivery/cli.toml")
210
- delivery_cli_path.exist?
200
+ Pathname.pwd.ascend.any? { |path| path.join(".delivery/cli.toml").exist? }
211
201
  end
212
202
 
213
203
  def read_and_validate_params
@@ -215,7 +205,7 @@ module ChefCLI
215
205
  @cookbook_name_or_path = arguments[0]
216
206
  if !@cookbook_name_or_path
217
207
  @params_valid = false
218
- elsif /-/ =~ File.basename(@cookbook_name_or_path)
208
+ elsif File.basename(@cookbook_name_or_path).include?("-")
219
209
  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
210
  end
221
211
 
@@ -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"
@@ -18,7 +18,7 @@
18
18
  # TODO: Chef should require its dependency correctly.
19
19
  require "singleton" unless defined?(Singleton)
20
20
  require "chef/cookbook/cookbook_version_loader"
21
- require "digest/sha1"
21
+ require "digest/sha1" unless defined?(Digest::SHA1)
22
22
 
23
23
  require "chef/digester"
24
24
 
@@ -154,7 +154,7 @@ module ChefCLI
154
154
  end
155
155
  if comment
156
156
  # Ensure there's no trailing whitespace
157
- result.gsub(/^(.+)$/, "#{comment} \\1").gsub(/^$/, "#{comment}").strip
157
+ result.gsub(/^(.+)$/, "#{comment} \\1").gsub(/^$/, comment).strip
158
158
  else
159
159
  result
160
160
  end
@@ -141,7 +141,7 @@ module ChefCLI
141
141
 
142
142
  def default_package_home
143
143
  if Chef::Platform.windows?
144
- File.join(ENV["LOCALAPPDATA"], "#{ChefCLI::Dist::PRODUCT_PKG_HOME}")
144
+ File.join(ENV["LOCALAPPDATA"], ChefCLI::Dist::PRODUCT_PKG_HOME)
145
145
  else
146
146
  File.expand_path("~/.#{ChefCLI::Dist::PRODUCT_PKG_HOME}")
147
147
  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
@@ -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
 
@@ -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
@@ -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
 
@@ -52,7 +52,7 @@ module ChefCLI
52
52
  return use_policyfile_lock(policyfile_filename)
53
53
  end
54
54
  unless policyfile_filename.end_with?(".rb")
55
- raise InvalidPolicyfileFilename, "Policyfile filenames must end with `.rb' extension (you gave: `#{policyfile_filename}')"
55
+ raise InvalidPolicyfileFilename, "Policyfile filenames must end with an `.rb' or `.lock.json' extension (you gave: `#{policyfile_filename}')"
56
56
  end
57
57
 
58
58
  @policyfile_filename = policyfile_filename
@@ -18,7 +18,7 @@
18
18
  require "pathname" unless defined?(Pathname)
19
19
  require "fileutils" unless defined?(FileUtils)
20
20
  require "tmpdir" unless defined?(Dir.mktmpdir)
21
- require "zlib"
21
+ require "zlib" unless defined?(Zlib)
22
22
 
23
23
  require "archive/tar/minitar"
24
24
 
@@ -42,8 +42,8 @@ module ChefCLI
42
42
  @overwrite = overwrite
43
43
  @chef_config = config
44
44
 
45
- policyfile_rel_path = policyfile || "Policyfile.rb"
46
- policyfile_full_path = File.expand_path(policyfile_rel_path, root_dir)
45
+ @policyfile_rel_path = policyfile || "Policyfile.rb"
46
+ policyfile_full_path = File.expand_path(@policyfile_rel_path, root_dir)
47
47
  @storage_config = Policyfile::StorageConfig.new.use_policyfile(policyfile_full_path)
48
48
 
49
49
  @policyfile_content = nil
@@ -51,9 +51,11 @@ module ChefCLI
51
51
  end
52
52
 
53
53
  def run(cookbooks_to_update = [], exclude_deps = false)
54
- unless File.exist?(policyfile_expanded_path)
55
- # TODO: suggest next step. Add a generator/init command? Specify path to Policyfile.rb?
56
- # See card CC-232
54
+ # TODO: suggest next step. Add a generator/init command? Specify path to Policyfile.rb?
55
+ # See card CC-232
56
+ if @policyfile_rel_path.end_with?(".lock.json") && !File.exist?(policyfile_lock_expanded_path)
57
+ raise PolicyfileNotFound, "Policyfile lock not found at path #{policyfile_lock_expanded_path}"
58
+ elsif @policyfile_rel_path.end_with?(".rb") && !File.exist?(policyfile_expanded_path)
57
59
  raise PolicyfileNotFound, "Policyfile not found at path #{policyfile_expanded_path}"
58
60
  end
59
61
 
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "zlib"
18
+ require "zlib" unless defined?(Zlib)
19
19
  require "archive/tar/minitar"
20
20
 
21
21
  require_relative "../service_exceptions"
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "3.0.16".freeze
19
+ VERSION = "3.0.30".freeze
20
20
  end
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "json"
18
+ require "json" unless defined?(JSON)
19
19
  require "kitchen"
20
20
  require "kitchen/provisioner/base"
21
21
  require "kitchen/provisioner/chef_zero"
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2014-2018 Chef Software Inc.
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,7 +35,7 @@ module TestHelpers
35
35
  end
36
36
 
37
37
  def fixtures_path
38
- File.expand_path(File.dirname(__FILE__) + "/unit/fixtures/")
38
+ File.expand_path(__dir__ + "/unit/fixtures/")
39
39
  end
40
40
 
41
41
  def project_root
@@ -41,12 +41,15 @@ describe ChefCLI::CLI do
41
41
 
42
42
  let(:base_help_message) do
43
43
  <<~E
44
+ The Chef command line tool for managing your infrastructure from your workstation.
45
+ Docs: https://docs.chef.io/workstation/
46
+ Patents: https://www.chef.io/patents
47
+
44
48
  Usage:
45
49
  chef -h/--help
46
50
  chef -v/--version
47
51
  chef command [arguments...] [options...]
48
52
 
49
-
50
53
  Available Commands:
51
54
  gem Runs the `gem` command in context of the embedded ruby
52
55
  example Example subcommand for testing
@@ -55,7 +58,7 @@ describe ChefCLI::CLI do
55
58
 
56
59
  def run_cli(expected_exit_code)
57
60
  expect(cli).to receive(:exit).with(expected_exit_code)
58
- expect(cli).to receive(:sanity_check!)
61
+ expect(cli).to receive(:path_check!)
59
62
  cli.run
60
63
  end
61
64
 
@@ -256,7 +259,7 @@ describe ChefCLI::CLI do
256
259
  end
257
260
  end
258
261
 
259
- context "sanity_check!" do
262
+ context "path_check!" do
260
263
 
261
264
  before do
262
265
  allow(Gem).to receive(:ruby).and_return(ruby_path)
@@ -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
@@ -127,7 +127,7 @@ describe ChefCLI::Command::Exec do
127
127
  end
128
128
 
129
129
  context "when running a exec with #{switch}" do
130
- let(:command_options) { ["#{switch}"] }
130
+ let(:command_options) { [switch] }
131
131
 
132
132
  it "should call not call exec, but it should print the banner" do
133
133
  allow(command_instance).to receive(:msg)
@@ -1,14 +1,11 @@
1
1
  require "openssl"
2
- require "net/https"
3
- require "json"
4
- require "pp"
2
+ require "net/http" unless defined?(Net::HTTP)
3
+ require "json" unless defined?(JSON)
5
4
  require "uri"
6
5
 
7
- THIS_DIR = File.expand_path(File.dirname(__FILE__))
8
-
9
- UNIVERSE_JSON_PATH = File.join(THIS_DIR, "universe.json")
10
- SMALL_UNIVERSE_JSON_PATH = File.join(THIS_DIR, "small_universe.json")
11
- PRUNED_UNIVERSE_PATH = File.join(THIS_DIR, "pruned_small_universe.json")
6
+ UNIVERSE_JSON_PATH = File.join(__dir__, "universe.json")
7
+ SMALL_UNIVERSE_JSON_PATH = File.join(__dir__, "small_universe.json")
8
+ PRUNED_UNIVERSE_PATH = File.join(__dir__, "pruned_small_universe.json")
12
9
 
13
10
  COOKBOOKS_IN_SMALL_UNIVERSE = %w{apache2 application apt database mysql nginx postgresql yum}.freeze
14
11
 
@@ -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
@@ -106,10 +106,10 @@ describe ChefCLI::Policyfile::StorageConfig do
106
106
 
107
107
  end
108
108
 
109
- context "when the policyfile file name doesn't have a .rb extension" do
109
+ context "when the policyfile file name doesn't have an .rb or .lock.json extension" do
110
110
 
111
111
  it "raises an error" do
112
- err_string = %q{Policyfile filenames must end with `.rb' extension (you gave: `Policyfile')}
112
+ err_string = %q{Policyfile filenames must end with an `.rb' or `.lock.json' extension (you gave: `Policyfile')}
113
113
  expect { storage_config.use_policyfile("Policyfile") }.to raise_error(ChefCLI::InvalidPolicyfileFilename, err_string)
114
114
  end
115
115
 
@@ -77,6 +77,26 @@ describe ChefCLI::PolicyfileServices::Install do
77
77
 
78
78
  end
79
79
 
80
+ context "When an explicit Policfyfile lock name is given and does not exist" do
81
+
82
+ let(:policyfile_rb_explicit_name) { "i_do_not_exist.lock.json" }
83
+
84
+ it "errors out" do
85
+ expect { install_service.run }.to raise_error(ChefCLI::PolicyfileNotFound, "Policyfile lock not found at path #{policyfile_rb_path}")
86
+ end
87
+
88
+ end
89
+
90
+ context "When an explicit Policfyfile name is given and does not exist" do
91
+
92
+ let(:policyfile_rb_explicit_name) { "i_do_not_exist.rb" }
93
+
94
+ it "errors out" do
95
+ expect { install_service.run }.to raise_error(ChefCLI::PolicyfileNotFound, "Policyfile not found at path #{policyfile_rb_path}")
96
+ end
97
+
98
+ end
99
+
80
100
  context "when a Policyfile exists" do
81
101
 
82
102
  before do
@@ -16,7 +16,7 @@
16
16
  #
17
17
 
18
18
  require "spec_helper"
19
- require "net/http"
19
+ require "net/http" unless defined?(Net::HTTP)
20
20
  require "chef/monkey_patches/net_http"
21
21
  require "chef-cli/service_exception_inspectors/http"
22
22
 
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.16
4
+ version: 3.0.30
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-08-03 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -173,45 +173,39 @@ dependencies:
173
173
  - !ruby/object:Gem::Version
174
174
  version: '1.4'
175
175
  - !ruby/object:Gem::Dependency
176
- name: paint
176
+ name: pastel
177
177
  requirement: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- version: '1'
182
- - - "<"
179
+ - - "~>"
183
180
  - !ruby/object:Gem::Version
184
- version: '3'
181
+ version: '0.7'
185
182
  type: :runtime
186
183
  prerelease: false
187
184
  version_requirements: !ruby/object:Gem::Requirement
188
185
  requirements:
189
- - - ">="
190
- - !ruby/object:Gem::Version
191
- version: '1'
192
- - - "<"
186
+ - - "~>"
193
187
  - !ruby/object:Gem::Version
194
- version: '3'
188
+ version: '0.7'
195
189
  - !ruby/object:Gem::Dependency
196
190
  name: license-acceptance
197
191
  requirement: !ruby/object:Gem::Requirement
198
192
  requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: '1.0'
202
193
  - - ">="
203
194
  - !ruby/object:Gem::Version
204
195
  version: 1.0.11
196
+ - - "<"
197
+ - !ruby/object:Gem::Version
198
+ version: '3'
205
199
  type: :runtime
206
200
  prerelease: false
207
201
  version_requirements: !ruby/object:Gem::Requirement
208
202
  requirements:
209
- - - "~>"
210
- - !ruby/object:Gem::Version
211
- version: '1.0'
212
203
  - - ">="
213
204
  - !ruby/object:Gem::Version
214
205
  version: 1.0.11
206
+ - - "<"
207
+ - !ruby/object:Gem::Version
208
+ version: '3'
215
209
  description: A streamlined development and deployment workflow for Chef platform.
216
210
  email:
217
211
  - info@chef.io