chef-cli 3.0.36 → 3.0.40

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: 75b5fd57e86db29bb68a615fdf19d525619d825cf5569fc19f01af72ac64c355
4
- data.tar.gz: 7659576815fb41138d60c1aba5996eddba6ea6229f4900a4177bbf969e567d80
3
+ metadata.gz: 589401fa72480dd7b3e4ad63f7023af6ad9cc312c105978667d7b164df0144ad
4
+ data.tar.gz: de56186f0f6a2e9fe5e2aa1b21abe467dc97548710e1a92bec0adaa5d7c82a64
5
5
  SHA512:
6
- metadata.gz: 00da7122004fa0123b09833996c1a5ac0abba1c891f508c7b06bad885db4872c4a718493f91a101779e3628183793437ffb52cbc5c71740ae318ce5fa6823ab3
7
- data.tar.gz: 800b5fd86118674375ed4d97f0084889a4d03594fabbb54d948db5e84eeb5b7b1123e6a742e16571a4ce965284866cf1db705ad609ec6e8d400549ea98b48d2b
6
+ metadata.gz: de377459543532084875b808fd2b7c0ab897fe2bae2b54bca4f82c90a59c565f1d0a04c8ccaf19710a5b9982d09a6bf2f805371b83a7ae77ae68656e0b1299d4
7
+ data.tar.gz: 64e33de89273df76855c56b599e4b8da396df569c7c787100f3b22640675dfbb47ad5dd9546b20eb072e1cebd2ffce29687297e0ee94962758745cbf26d4ead9
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", "6.14.7" # this forces dependabot PRs to open which triggers cookstyle CI on the chef generate command
17
- gem "chefstyle", "1.2.0"
16
+ gem "cookstyle", "=7.7.2" # this forces dependabot PRs to open which triggers cookstyle CI on the chef generate command
17
+ gem "chefstyle", "=1.6.2"
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"
data/chef-cli.gemspec CHANGED
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- lib = File.expand_path("../lib", __FILE__)
18
+ lib = File.expand_path("lib", __dir__)
19
19
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
20
20
  require "chef-cli/version"
21
21
 
data/lib/chef-cli/cli.rb CHANGED
@@ -171,11 +171,7 @@ module ChefCLI
171
171
  private
172
172
 
173
173
  def manifest_field(field)
174
- if manifest_hash[field]
175
- manifest_hash[field]
176
- else
177
- "unknown"
178
- end
174
+ manifest_hash[field] || "unknown"
179
175
  end
180
176
 
181
177
  def component_version(name)
@@ -86,7 +86,7 @@ module ChefCLI
86
86
  # chefcli.generator_cookbook would make this command copy the custom
87
87
  # generator, but that doesn't make sense because the user can easily
88
88
  # do that anyway.
89
- File.expand_path("../../../skeletons/code_generator", __FILE__)
89
+ File.expand_path("../../skeletons/code_generator", __dir__)
90
90
  end
91
91
 
92
92
  private
@@ -142,7 +142,7 @@ module ChefCLI
142
142
  end
143
143
 
144
144
  def expand_completion_template_path(basename)
145
- File.join(File.expand_path("../../completions", __FILE__), basename)
145
+ File.join(File.expand_path("../completions", __dir__), basename)
146
146
  end
147
147
 
148
148
  def shell_completion_template_context
@@ -33,7 +33,7 @@ class Chef::Config
33
33
  # instead of `chefcli.generator_cookbook`).
34
34
  config_strict_mode(true)
35
35
 
36
- default(:generator_cookbook, File.expand_path("../skeletons/code_generator", __FILE__))
36
+ default(:generator_cookbook, File.expand_path("skeletons/code_generator", __dir__))
37
37
 
38
38
  config_context(:generator) do
39
39
  config_strict_mode(true)
@@ -120,14 +120,10 @@ module ChefCLI
120
120
  @unborn_branch = false
121
121
  branch
122
122
  rescue Mixlib::ShellOut::ShellCommandFailed => e
123
- # We may have an "unborn" branch, i.e. one with no commits.
124
- if unborn_branch_ref
125
- unborn_branch_ref
126
- else
127
- # if we got here, but verify_ref_cmd didn't error, we don't know why
128
- # the original git command failed, so re-raise.
129
- raise e
130
- end
123
+ # "unborn" branch, i.e. one with no commits or
124
+ # verify_ref_cmd didn't error, we don't know why
125
+ # the original git command failed, so re-raise.
126
+ unborn_branch_ref || raise(e)
131
127
  end
132
128
 
133
129
  def unborn_branch_ref
@@ -82,10 +82,14 @@ module ChefCLI
82
82
  "artifactory(#{uri})"
83
83
  end
84
84
 
85
+ def artifactory_api_key
86
+ chef_config&.artifactory_api_key || ENV["ARTIFACTORY_API_KEY"]
87
+ end
88
+
85
89
  private
86
90
 
87
91
  def http_connection_for(base_url)
88
- headers = { "X-Jfrog-Art-API" => chef_config.artifactory_api_key || ENV["ARTIFACTORY_API_KEY"] }
92
+ headers = { "X-Jfrog-Art-API" => artifactory_api_key }
89
93
  @http_connections[base_url] ||= Chef::HTTP::Simple.new(base_url, headers: headers)
90
94
  end
91
95
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  require "diff/lcs"
19
19
  require "diff/lcs/hunk"
20
- require "pastel"
20
+ require "pastel" unless defined?(Pastel)
21
21
  autoload :FFI_Yajl, "ffi_yajl"
22
22
 
23
23
  module ChefCLI
@@ -123,6 +123,7 @@ module ChefCLI
123
123
 
124
124
  class DeletePolicyError < PolicyfileNestedException
125
125
  end
126
+
126
127
  class PolicyCookbookCleanError < PolicyfileNestedException
127
128
  end
128
129
 
@@ -22,4 +22,4 @@ else
22
22
  source 'cookbook_file.erb'
23
23
  helpers(ChefCLI::Generator::TemplateHelper)
24
24
  end
25
- end
25
+ end
@@ -4,7 +4,7 @@ driver:
4
4
 
5
5
  ## The forwarded_port port feature lets you connect to ports on the VM guest via
6
6
  ## localhost on the host.
7
- ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports.html
7
+ ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
8
8
 
9
9
  # network:
10
10
  # - ["forwarded_port", {guest: 80, host: 8080}]
@@ -4,7 +4,7 @@ driver:
4
4
 
5
5
  ## The forwarded_port port feature lets you connect to ports on the VM guest via
6
6
  ## localhost on the host.
7
- ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports.html
7
+ ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
8
8
 
9
9
  # network:
10
10
  # - ["forwarded_port", {guest: 80, host: 8080}]
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "3.0.36".freeze
19
+ VERSION = "3.0.40".freeze
20
20
  end
data/spec/test_helpers.rb CHANGED
@@ -39,7 +39,7 @@ module TestHelpers
39
39
  end
40
40
 
41
41
  def project_root
42
- File.expand_path("../..", __FILE__)
42
+ File.expand_path("..", __dir__)
43
43
  end
44
44
 
45
45
  def reset_tempdir
@@ -562,7 +562,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
562
562
 
563
563
  ## The forwarded_port port feature lets you connect to ports on the VM guest via
564
564
  ## localhost on the host.
565
- ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports.html
565
+ ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
566
566
 
567
567
  # network:
568
568
  # - ["forwarded_port", {guest: 80, host: 8080}]
@@ -645,7 +645,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
645
645
 
646
646
  ## The forwarded_port port feature lets you connect to ports on the VM guest via
647
647
  ## localhost on the host.
648
- ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports.html
648
+ ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
649
649
 
650
650
  # network:
651
651
  # - ["forwarded_port", {guest: 80, host: 8080}]
@@ -26,7 +26,7 @@ describe ChefCLI::Command::GeneratorCommands::GeneratorGenerator do
26
26
  let(:stdout_io) { StringIO.new }
27
27
  let(:stderr_io) { StringIO.new }
28
28
 
29
- let(:repo_root) { File.expand_path("../../../../..", __FILE__) }
29
+ let(:repo_root) { File.expand_path("../../../..", __dir__) }
30
30
 
31
31
  let(:builtin_generator_path) { File.join(repo_root, "lib/chef-cli/skeletons/code_generator") }
32
32
 
@@ -20,8 +20,9 @@ require "chef-cli/policyfile/source_uri"
20
20
  require "chef-cli/policyfile/artifactory_cookbook_source"
21
21
 
22
22
  describe ChefCLI::Policyfile::ArtifactoryCookbookSource do
23
- subject { described_class.new(cookbook_source) }
23
+ subject { described_class.new(cookbook_source, chef_config: config) }
24
24
 
25
+ let(:config) { nil }
25
26
  let(:cookbook_source) { "https://supermarket.chef.io/api/v1" }
26
27
 
27
28
  let(:http_connection) { double("Chef::HTTP::Simple") }
@@ -56,4 +57,29 @@ describe ChefCLI::Policyfile::ArtifactoryCookbookSource do
56
57
  expect(subject.source_options_for("apache2", "1.10.4")).to eq(expected_opts)
57
58
  end
58
59
  end
60
+
61
+ describe "#artifactory_api_key" do
62
+ before do
63
+ ENV["ARTIFACTORY_API_KEY"] = "test"
64
+ end
65
+
66
+ context "when config is not present" do
67
+ let(:config) { nil }
68
+ it "should get artifactory key from the env" do
69
+ expect(subject.artifactory_api_key).to eq("test")
70
+ end
71
+ end
72
+
73
+ context "when config is present" do
74
+ let(:config) { double("Chef::Config") }
75
+ it "should get artifactory key from config when key is present" do
76
+ expect(config).to receive(:artifactory_api_key).and_return "test1"
77
+ expect(subject.artifactory_api_key).to eq("test1")
78
+ end
79
+ it "should get artifactory key from env when config is present but has a nil key" do
80
+ expect(config).to receive(:artifactory_api_key).and_return nil
81
+ expect(subject.artifactory_api_key).to eq("test")
82
+ end
83
+ end
84
+ end
59
85
  end
@@ -223,7 +223,7 @@ describe ChefCLI::Policyfile::UndoStack do
223
223
  end
224
224
 
225
225
  it "removes the oldest record" do
226
- oldest_record_file = undo_stack_files.sort.first
226
+ oldest_record_file = undo_stack_files.min
227
227
 
228
228
  undo_stack.push(incremented_undo_record(11))
229
229
 
@@ -251,7 +251,7 @@ describe ChefCLI::Policyfile::UndoStack do
251
251
  end
252
252
 
253
253
  it "removes the oldest record" do
254
- oldest_record_file = undo_stack_files.sort.first
254
+ oldest_record_file = undo_stack_files.min
255
255
 
256
256
  undo_stack.push(incremented_undo_record(11))
257
257
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  require "spec_helper"
19
19
  require "chef-cli/policyfile_compiler"
20
- require "chef-cli/policyfile_lock.rb"
20
+ require "chef-cli/policyfile_lock"
21
21
 
22
22
  describe ChefCLI::PolicyfileLock, "installing cookbooks from included policies" do
23
23
 
@@ -19,7 +19,7 @@ require "spec_helper"
19
19
  require "shared/setup_git_cookbooks"
20
20
  require "shared/fixture_cookbook_checksums"
21
21
  require "chef-cli/policyfile/storage_config"
22
- require "chef-cli/policyfile_lock.rb"
22
+ require "chef-cli/policyfile_lock"
23
23
 
24
24
  describe ChefCLI::PolicyfileLock, "building a lockfile", :skip_on_windows do
25
25
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  require "spec_helper"
19
19
  require "shared/fixture_cookbook_checksums"
20
- require "chef-cli/policyfile_lock.rb"
20
+ require "chef-cli/policyfile_lock"
21
21
 
22
22
  describe ChefCLI::PolicyfileLock, "installing cookbooks from a lockfile" do
23
23
 
@@ -16,7 +16,7 @@
16
16
  #
17
17
 
18
18
  require "spec_helper"
19
- require "chef-cli/policyfile_lock.rb"
19
+ require "chef-cli/policyfile_lock"
20
20
 
21
21
  describe ChefCLI::PolicyfileLock, "validating locked cookbooks" do
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.36
4
+ version: 3.0.40
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: 2021-01-15 00:00:00.000000000 Z
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli