chef-cli 3.0.27 → 3.0.30

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 577fd81ddfd9035362ceca91e8657bf85601baa80a3b810bb3a537fb1c138f55
4
- data.tar.gz: f54bf84b3b02697a25a0b6df304255322a31baa22c8fff25dcdd3b917daac99f
3
+ metadata.gz: 8a39366b7f1920937b7329ef1a5b54d810d4b3c017e331926608356c55c68250
4
+ data.tar.gz: 20882fcd4590d7969d7afd83aec868e89be1c032651dc594dcc61f4eee2eb632
5
5
  SHA512:
6
- metadata.gz: fa616d709e416e96c148010b895e5d7e95c440544d66e9e39f2768242443f3aecaafe0fbcc3c3fa6715fbe5426bf7b55ec939db0b31338943b1a84f6bdbb04bf
7
- data.tar.gz: 691fd1a5d1cde311bbe3c6bb8678704857733261a1b19e83f2f418ac10d2af22e3fa09c5de26a4a5599bb50733d9deca2a4f70d937b63270ad747b405db31094
6
+ metadata.gz: 621b7594acfcb6968c5ddd3d690fc49a86b4c6932d4011debdadee19d86d638b7caea04eba2aa89776be213533ec4c14be65b715418edf83a39fda0f651c8bba
7
+ data.tar.gz: 315dd298b75add288ff031a1c9b7d3a0d5d4994454476570b4fd3c46a4c0ae3d693ecc8d9ac0b43aa5c10f3ffa1901921fb841e63198612b84d0cbb6e630d582
@@ -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)
@@ -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
@@ -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
 
@@ -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
@@ -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
@@ -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.27".freeze
19
+ VERSION = "3.0.30".freeze
20
20
  end
@@ -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
@@ -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
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
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.27
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-24 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