chef-cli 3.0.24 → 3.0.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -0
  3. data/bin/chef-cli +2 -2
  4. data/chef-cli.gemspec +1 -1
  5. data/lib/chef-cli/cli.rb +6 -2
  6. data/lib/chef-cli/command/env.rb +7 -4
  7. data/lib/chef-cli/command/exec.rb +4 -1
  8. data/lib/chef-cli/command/generator_commands.rb +1 -1
  9. data/lib/chef-cli/command/generator_commands/cookbook.rb +5 -0
  10. data/lib/chef-cli/command/shell_init.rb +5 -2
  11. data/lib/chef-cli/cookbook_profiler/identifiers.rb +1 -1
  12. data/lib/chef-cli/dist.rb +7 -2
  13. data/lib/chef-cli/generator.rb +1 -1
  14. data/lib/chef-cli/helpers.rb +5 -2
  15. data/lib/chef-cli/policyfile/chef_server_cookbook_source.rb +1 -1
  16. data/lib/chef-cli/policyfile/comparison_base.rb +5 -2
  17. data/lib/chef-cli/policyfile/differ.rb +1 -1
  18. data/lib/chef-cli/policyfile/git_lock_fetcher.rb +4 -1
  19. data/lib/chef-cli/policyfile/lister.rb +1 -1
  20. data/lib/chef-cli/policyfile/solution_dependencies.rb +1 -1
  21. data/lib/chef-cli/policyfile/source_uri.rb +4 -1
  22. data/lib/chef-cli/policyfile/storage_config.rb +1 -1
  23. data/lib/chef-cli/policyfile/undo_stack.rb +1 -1
  24. data/lib/chef-cli/policyfile_compiler.rb +1 -1
  25. data/lib/chef-cli/policyfile_services/clean_policy_cookbooks.rb +1 -1
  26. data/lib/chef-cli/policyfile_services/export_repo.rb +1 -1
  27. data/lib/chef-cli/policyfile_services/install.rb +8 -6
  28. data/lib/chef-cli/policyfile_services/push.rb +1 -1
  29. data/lib/chef-cli/policyfile_services/push_archive.rb +1 -1
  30. data/lib/chef-cli/service_exception_inspectors/http.rb +1 -1
  31. data/lib/chef-cli/shell_out.rb +3 -1
  32. data/lib/chef-cli/skeletons/code_generator/files/default/gitignore +1 -1
  33. data/lib/chef-cli/skeletons/code_generator/files/default/repo/README.md +3 -3
  34. data/lib/chef-cli/skeletons/code_generator/recipes/cookbook.rb +15 -2
  35. data/lib/chef-cli/version.rb +1 -1
  36. data/lib/kitchen/provisioner/chef_zero_capture.rb +0 -1
  37. data/spec/test_helpers.rb +2 -2
  38. data/spec/unit/cli_spec.rb +4 -1
  39. data/spec/unit/command/env_spec.rb +1 -1
  40. data/spec/unit/command/exec_spec.rb +1 -1
  41. data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +4 -7
  42. data/spec/unit/policyfile/storage_config_spec.rb +2 -2
  43. data/spec/unit/policyfile_services/install_spec.rb +20 -0
  44. data/spec/unit/service_exception_inspectors/http_spec.rb +1 -1
  45. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 313ac394fc05556ea7a12748f3d00256a17556e57c97be2c8cc8b875233f2607
4
- data.tar.gz: 20e16fbae37e2c6bf8615bdc2d161d96d5a6f74791294f59c39bc509072f99fa
3
+ metadata.gz: 4e62dfc227a16206b504aa0a8838d2e1960e38573e0d1f2646fc4e14b1e174df
4
+ data.tar.gz: cfca788e2ae2a92d7014d62c4fc65c20d20cbe9b57a9c8bad24e342f70262167
5
5
  SHA512:
6
- metadata.gz: af4ff4840e87a8dba88b0f4ddc527800e6f2826f7a8e6d90da4d6c364e4d013098d707a046322948858ced67b0666ab3fc737d8c1aa9332f162ec99f8f53d9c2
7
- data.tar.gz: b9b76d0a67b78d4803d8ee924986d66a7d65723384850f1baaa59063917b28bf48456ebbad0fb7ba5fc283f1eccfe75c942b2bce7556070caeac71ca1c81bd1e
6
+ metadata.gz: a4adff5f07ea9bf2fee6933c5b2f91eeebd2ceab36ba27c72f3ddf38555ce43940e31f7975c5cf3df1a0869f6d548869af33dd1fc70e30e1223b3c70634a5aad
7
+ data.tar.gz: a3c7f7187f9ee410517c4a81bd4160ef0f55cb3101b7197ef3c0d902e01863356ce5f8e35c52c15213b53e3680c17996d4a1eb13bb1ce4d9a30335e32858e72a
data/Gemfile CHANGED
@@ -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)
@@ -49,5 +49,5 @@ Gem::Specification.new do |gem|
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
51
  gem.add_dependency "pastel", "~> 0.7" # used for policyfile differ
52
- gem.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.11"
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
+ #{ChefCLI::Dist::WORKSTATION_HEADER}
37
+ Docs: #{ChefCLI::Dist::WORKSTATION_DOCS}
38
+ Patents: #{ChefCLI::Dist::PATENTS}
39
+
36
40
  Usage:
37
41
  #{ChefCLI::Dist::EXEC} -h/--help
38
42
  #{ChefCLI::Dist::EXEC} -v/--version
@@ -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
 
@@ -20,8 +20,11 @@ require_relative "../cookbook_omnifetch"
20
20
  require_relative "../ui"
21
21
  require_relative "../version"
22
22
  require_relative "../dist"
23
- require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
24
- require "yaml" unless defined?(YAML)
23
+
24
+ module Mixlib
25
+ autoload :ShellOut, "mixlib/shellout"
26
+ end
27
+ autoload :YAML, "yaml"
25
28
 
26
29
  module ChefCLI
27
30
  module Command
@@ -37,10 +40,10 @@ module ChefCLI
37
40
 
38
41
  def run(params)
39
42
  info = {}
40
- info["#{ChefCLI::Dist::PRODUCT}"] = workstation_info
43
+ info[ChefCLI::Dist::PRODUCT] = workstation_info
41
44
  info["Ruby"] = ruby_info
42
45
  info["Path"] = paths
43
- ui.msg info.to_yaml
46
+ ui.msg YAML.dump(info)
44
47
  end
45
48
 
46
49
  def workstation_info
@@ -17,7 +17,10 @@
17
17
 
18
18
  require_relative "base"
19
19
  require_relative "../dist"
20
- require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
20
+
21
+ module Mixlib
22
+ autoload :ShellOut, "mixlib/shellout"
23
+ end
21
24
 
22
25
  module ChefCLI
23
26
  module Command
@@ -16,7 +16,7 @@
16
16
  #
17
17
 
18
18
  require "mixlib/cli" unless defined?(Mixlib::CLI)
19
- require "pathname" unless defined?(Pathname)
19
+ autoload :Pathname, "pathname"
20
20
  require_relative "base"
21
21
  require_relative "../chef_runner"
22
22
  require_relative "../generator"
@@ -137,6 +137,7 @@ module ChefCLI
137
137
  Generator.add_attr_to_context(:use_policyfile, policy_mode?)
138
138
  Generator.add_attr_to_context(:pipeline, pipeline)
139
139
  Generator.add_attr_to_context(:kitchen, kitchen)
140
+ Generator.add_attr_to_context(:vscode_dir, create_vscode_dir?)
140
141
  end
141
142
 
142
143
  def kitchen
@@ -235,6 +236,10 @@ module ChefCLI
235
236
  end
236
237
  false
237
238
  end
239
+
240
+ def create_vscode_dir?
241
+ ::File.exist?("/Applications/Visual Studio Code.app") || ::File.exist?("#{ENV["APPDATA"]}\\Code")
242
+ end
238
243
  end
239
244
  end
240
245
  end
@@ -15,13 +15,16 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "erb" unless defined?(ERB)
18
+ autoload :ERB, "erb"
19
19
 
20
20
  require_relative "../commands_map"
21
21
  require_relative "../builtin_commands"
22
22
  require_relative "base"
23
23
  require_relative "../dist"
24
- require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
24
+
25
+ module Mixlib
26
+ autoload :ShellOut, "mixlib/shellout"
27
+ end
25
28
 
26
29
  module ChefCLI
27
30
 
@@ -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
 
@@ -27,7 +27,6 @@ module ChefCLI
27
27
 
28
28
  # The name of the server product
29
29
  SERVER_PRODUCT = "Chef Infra Server".freeze
30
-
31
30
  WORKFLOW = "Chef Workflow (Delivery)".freeze
32
31
 
33
32
  # The chef executable, as in `chef gem install` or `chef generate cookbook`
@@ -38,7 +37,13 @@ module ChefCLI
38
37
 
39
38
  HAB_PRODUCT = "Chef Habitat".freeze
40
39
  HAB_SOFTWARE_NAME = "habitat".freeze
41
-
42
40
  HAB_CLI = "hab".freeze
41
+
42
+ # product patents page
43
+ PATENTS = "https://www.chef.io/patents".freeze
44
+
45
+ # Workstation banner/help text
46
+ WORKSTATION_DOCS = "https://docs.chef.io/workstation/".freeze
47
+ WORKSTATION_HEADER = "The Chef command line tool for managing your infrastructure from your workstation.".freeze
43
48
  end
44
49
  end
@@ -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
@@ -15,7 +15,10 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
18
+ module Mixlib
19
+ autoload :ShellOut, "mixlib/shellout"
20
+ end
21
+
19
22
  require_relative "exceptions"
20
23
 
21
24
  module ChefCLI
@@ -141,7 +144,7 @@ module ChefCLI
141
144
 
142
145
  def default_package_home
143
146
  if Chef::Platform.windows?
144
- File.join(ENV["LOCALAPPDATA"], "#{ChefCLI::Dist::PRODUCT_PKG_HOME}")
147
+ File.join(ENV["LOCALAPPDATA"], ChefCLI::Dist::PRODUCT_PKG_HOME)
145
148
  else
146
149
  File.expand_path("~/.#{ChefCLI::Dist::PRODUCT_PKG_HOME}")
147
150
  end
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "ffi_yajl" unless defined?(FFI_Yajl)
18
+ autoload :FFI_Yajl, "ffi_yajl"
19
19
  require_relative "../exceptions"
20
20
  require_relative "source_uri"
21
21
  require_relative "../chef_server_api_multi"
@@ -15,8 +15,11 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "ffi_yajl" unless defined?(FFI_Yajl)
19
- require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
18
+ module Mixlib
19
+ autoload :ShellOut, "mixlib/shellout"
20
+ end
21
+
22
+ autoload :FFI_Yajl, "ffi_yajl"
20
23
  require_relative "../service_exceptions"
21
24
 
22
25
  module ChefCLI
@@ -18,7 +18,7 @@
18
18
  require "diff/lcs"
19
19
  require "diff/lcs/hunk"
20
20
  require "pastel"
21
- require "ffi_yajl" unless defined?(FFI_Yajl)
21
+ autoload :FFI_Yajl, "ffi_yajl"
22
22
 
23
23
  module ChefCLI
24
24
  module Policyfile
@@ -15,10 +15,13 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
+ module Mixlib
19
+ autoload :ShellOut, "mixlib/shellout"
20
+ end
21
+
18
22
  require_relative "../policyfile_lock"
19
23
  require_relative "../exceptions"
20
24
  require_relative "../helpers"
21
- require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
22
25
  require "tmpdir" unless defined?(Dir.mktmpdir)
23
26
 
24
27
  module ChefCLI
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "set" unless defined?(Set)
18
+ autoload :Set, "set"
19
19
 
20
20
  require "chef/server_api"
21
21
  require_relative "../service_exceptions"
@@ -16,7 +16,7 @@
16
16
  #
17
17
 
18
18
  require "semverse"
19
- require "set" unless defined?(Set)
19
+ autoload :Set, "set"
20
20
  require_relative "../exceptions"
21
21
 
22
22
  module ChefCLI
@@ -15,7 +15,10 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "addressable/uri" unless defined?(Addressable::URI)
18
+ module Addressable
19
+ autoload :URI, "addressable/uri"
20
+ end
21
+
19
22
  require_relative "../exceptions"
20
23
 
21
24
  module ChefCLI
@@ -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
@@ -17,7 +17,7 @@
17
17
 
18
18
  require "fileutils" unless defined?(FileUtils)
19
19
 
20
- require "ffi_yajl" unless defined?(FFI_Yajl)
20
+ autoload :FFI_Yajl, "ffi_yajl"
21
21
 
22
22
  require_relative "../helpers"
23
23
  require_relative "undo_record"
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "set" unless defined?(Set)
18
+ autoload :Set, "set"
19
19
  require "forwardable" unless defined?(Forwardable)
20
20
 
21
21
  require "solve"
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "set" unless defined?(Set)
18
+ autoload :Set, "set"
19
19
 
20
20
  require "chef/server_api"
21
21
  require_relative "../service_exceptions"
@@ -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
 
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "ffi_yajl" unless defined?(FFI_Yajl)
18
+ autoload :FFI_Yajl, "ffi_yajl"
19
19
 
20
20
  require_relative "../helpers"
21
21
  require_relative "../service_exceptions"
@@ -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 "ffi_yajl" unless defined?(FFI_Yajl)
18
+ autoload :FFI_Yajl, "ffi_yajl"
19
19
 
20
20
  require_relative "../service_exceptions"
21
21
  require "chef/server_api"
@@ -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"
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "ffi_yajl" unless defined?(FFI_Yajl)
18
+ autoload :FFI_Yajl, "ffi_yajl"
19
19
 
20
20
  module ChefCLI
21
21
  module ServiceExceptionInspectors
@@ -15,7 +15,9 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
18
+ module Mixlib
19
+ autoload :ShellOut, "mixlib/shellout"
20
+ end
19
21
 
20
22
  module ChefCLI
21
23
 
@@ -16,7 +16,7 @@ bin/*
16
16
  .kitchen/
17
17
  kitchen.local.yml
18
18
 
19
- # Chef
19
+ # Chef Infra
20
20
  Berksfile.lock
21
21
  .zero-knife.rb
22
22
  Policyfile.lock.json
@@ -2,7 +2,7 @@
2
2
 
3
3
  Every Chef Infra installation needs a Chef Repository. This is the place where cookbooks, policyfiles, config files and other artifacts for managing systems with Chef Infra will live. We strongly recommend storing this repository in a version control system such as Git and treating it like source code.
4
4
 
5
- # Repository Directories
5
+ ## Repository Directories
6
6
 
7
7
  This repository contains several directories, and each directory contains a README file that describes what it is for in greater detail, and how to use it for managing your systems with Chef.
8
8
 
@@ -11,10 +11,10 @@ This repository contains several directories, and each directory contains a READ
11
11
  - `roles/` - Store roles in .rb or .json in the repository.
12
12
  - `environments/` - Store environments in .rb or .json in the repository.
13
13
 
14
- # Configuration
14
+ ## Configuration
15
15
 
16
16
  The config file, `.chef/config.rb` is a repository-specific configuration file for the knife command line tool. If you're using the Hosted Chef platform, you can download one for your organization from the management console. You can also generate a new config.rb by running `knife configure`. For more information about configuring Knife, see the Knife documentation at https://docs.chef.io/workstation/knife/
17
17
 
18
- # Next Steps
18
+ ## Next Steps
19
19
 
20
20
  Read the README file in each of the subdirectories for more information about what goes in those directories.
@@ -91,7 +91,7 @@ template "#{cookbook_dir}/test/integration/default/default_test.rb" do
91
91
  action :create_if_missing
92
92
  end
93
93
 
94
- # Chefspec
94
+ # ChefSpec
95
95
  directory "#{cookbook_dir}/spec/unit/recipes" do
96
96
  recursive true
97
97
  end
@@ -113,7 +113,6 @@ template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
113
113
  end
114
114
 
115
115
  # Recipes
116
-
117
116
  directory "#{cookbook_dir}/recipes"
118
117
 
119
118
  template "#{cookbook_dir}/recipes/default.rb" do
@@ -164,4 +163,18 @@ if context.have_git
164
163
  end
165
164
  end
166
165
 
166
+ if context.vscode_dir
167
+ directory "#{cookbook_dir}/.vscode"
168
+
169
+ file "#{cookbook_dir}/.vscode/extensions.json" do
170
+ content <<~CONTENT
171
+ {
172
+ "recommendations": [
173
+ "chef-software.chef"
174
+ ]
175
+ }
176
+ CONTENT
177
+ end
178
+ end
179
+
167
180
  include_recipe '::build_cookbook' if context.enable_workflow
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "3.0.24".freeze
19
+ VERSION = "3.0.33".freeze
20
20
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require "json" unless defined?(JSON)
19
18
  require "kitchen"
20
19
  require "kitchen/provisioner/base"
21
20
  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
+ #{ChefCLI::Dist::WORKSTATION_HEADER}
45
+ Docs: #{ChefCLI::Dist::WORKSTATION_DOCS}
46
+ Patents: #{ChefCLI::Dist::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
@@ -16,7 +16,7 @@
16
16
  #
17
17
 
18
18
  require "spec_helper"
19
- require "yaml" unless defined?(YAML)
19
+ autoload :YAML, "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"
2
+ require "net/http" unless defined?(Net::HTTP)
3
3
  require "json" unless defined?(JSON)
4
- require "pp"
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
 
@@ -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.24
4
+ version: 3.0.33
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-17 00:00:00.000000000 Z
11
+ date: 2020-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -190,22 +190,22 @@ dependencies:
190
190
  name: license-acceptance
191
191
  requirement: !ruby/object:Gem::Requirement
192
192
  requirements:
193
- - - "~>"
194
- - !ruby/object:Gem::Version
195
- version: '1.0'
196
193
  - - ">="
197
194
  - !ruby/object:Gem::Version
198
195
  version: 1.0.11
196
+ - - "<"
197
+ - !ruby/object:Gem::Version
198
+ version: '3'
199
199
  type: :runtime
200
200
  prerelease: false
201
201
  version_requirements: !ruby/object:Gem::Requirement
202
202
  requirements:
203
- - - "~>"
204
- - !ruby/object:Gem::Version
205
- version: '1.0'
206
203
  - - ">="
207
204
  - !ruby/object:Gem::Version
208
205
  version: 1.0.11
206
+ - - "<"
207
+ - !ruby/object:Gem::Version
208
+ version: '3'
209
209
  description: A streamlined development and deployment workflow for Chef platform.
210
210
  email:
211
211
  - info@chef.io