chef-cli 5.6.1 → 5.6.8

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: 308c1bbb1d1f4d2070055036818dc566c577d28cd3c6ab476054029302082676
4
- data.tar.gz: a5cc534e4f0d0ae65347b5b438ffc968b4dc982078a37e6c89ff1a351eee4ee3
3
+ metadata.gz: 8c80bb20b027a5c4311dd72bce5ab3bbc569b5700c79513b4f7f455ce7ea9319
4
+ data.tar.gz: 0b6764b2f73d29b39ce9aa106f8b2621a7a37725c3dd4543061b648910eb5be9
5
5
  SHA512:
6
- metadata.gz: 6d53620886e274948207b24d28dcb1bae9f3b784d64783ae42b9698f5359c6ef1653bb1a65417d3309a0bdef10d3254663049447c9a6cdfdcfe1321739335a7d
7
- data.tar.gz: abc2a02f25e66edb3bd03b9c1a4903310f1029f699107b23565e3629cacb65b8254faaacb8354f2a00b1c9b6155eaa39df1f3709542eb840f5a2477310b221e4
6
+ metadata.gz: a2a07a53fa8f92ed504d59710c0f9ee4ae2792b9717d42e97ce2cfb45ced507e32b009a0ee5e96c9ed7bf7061ffb5cb987ca5cebd1cda3f5fa2f41816898062d
7
+ data.tar.gz: 278351d4ec69ff485b6b7f3d598e251fa0cc8d0419fa6a86d5ecba1bc00c4aa16f65fb400e277c36cd17ec412298db33d55d61e422d715e0fbee1f2c5b52c956
data/chef-cli.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
29
29
  gem.license = "Apache-2.0"
30
30
  gem.homepage = "https://www.chef.io/"
31
31
 
32
- gem.required_ruby_version = ">= 2.6"
32
+ gem.required_ruby_version = ">= 2.7"
33
33
 
34
34
  gem.files = %w{Rakefile LICENSE} +
35
35
  Dir.glob("Gemfile*") + # Includes Gemfile and locks
@@ -18,9 +18,6 @@
18
18
  require "chef/config"
19
19
  require "chef/workstation_config_loader"
20
20
 
21
- require_relative "cookbook_omnifetch"
22
- require_relative "chef_server_api_multi"
23
-
24
21
  # Define a config context for ChefCLI
25
22
  class Chef::Config
26
23
 
@@ -52,8 +49,6 @@ module ChefCLI
52
49
 
53
50
  config_loader.load
54
51
  @chef_config = Chef::Config
55
- CookbookOmnifetch.integration.default_chef_server_http_client = default_chef_server_http_client
56
- @chef_config
57
52
  end
58
53
 
59
54
  def chefcli_config
@@ -80,14 +75,5 @@ module ChefCLI
80
75
  @chef_config = nil
81
76
  @config_loader = nil
82
77
  end
83
-
84
- def default_chef_server_http_client
85
- lambda do
86
- ChefServerAPIMulti.new(@chef_config.chef_server_url,
87
- signing_key_filename: @chef_config.client_key,
88
- client_name: @chef_config.node_name)
89
- end
90
- end
91
-
92
78
  end
93
79
  end
@@ -15,7 +15,10 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
+ require "chef/config"
18
19
  require "cookbook-omnifetch"
20
+ require_relative "exceptions"
21
+ require_relative "chef_server_api_multi"
19
22
  require_relative "shell_out"
20
23
  require_relative "cookbook_metadata"
21
24
  require_relative "helpers"
@@ -29,4 +32,15 @@ CookbookOmnifetch.configure do |c|
29
32
  c.shell_out_class = ChefCLI::ShellOut
30
33
  c.cached_cookbook_class = ChefCLI::CookbookMetadata
31
34
  c.chef_server_download_concurrency = 10
35
+
36
+ c.default_chef_server_http_client = lambda do
37
+ if Chef::Config.node_name.nil?
38
+ raise ChefCLI::BUG.new("CookbookOmnifetch.default_chef_server_http_client requires Chef::Config;" \
39
+ " load the config or configure a different default")
40
+ end
41
+
42
+ ChefCLI::ChefServerAPIMulti.new(Chef::Config.chef_server_url,
43
+ signing_key_filename: Chef::Config.client_key,
44
+ client_name: Chef::Config.node_name)
45
+ end
32
46
  end
@@ -117,9 +117,10 @@ module ChefCLI
117
117
  private
118
118
 
119
119
  def with_staging_dir
120
- p = Process.pid
121
- t = Time.new.utc.strftime("%Y%m%d%H%M%S")
122
- Dir.mktmpdir("chefcli-export-#{p}-#{t}") do |d|
120
+ require "securerandom" unless defined?(SecureRandom)
121
+ random_string = SecureRandom.hex(2)
122
+ path = "chef-export-#{random_string}"
123
+ Dir.mktmpdir(path) do |d|
123
124
  begin
124
125
  @staging_dir = d
125
126
  yield
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "5.6.1".freeze
19
+ VERSION = "5.6.8".freeze
20
20
  end
@@ -40,29 +40,4 @@ describe ChefCLI::Configurable do
40
40
  it "provides generator_config" do
41
41
  expect(includer.generator_config).to eq Chef::Config.chefcli.generator
42
42
  end
43
-
44
- describe "loading Chef Config" do
45
-
46
- let(:url) { "https://chef.example/organizations/myorg" }
47
-
48
- let(:key_path) { "/path/to/my/key.pem" }
49
-
50
- let(:username) { "my-username" }
51
-
52
- before do
53
- Chef::Config.chef_server_url(url)
54
- Chef::Config.client_key(key_path)
55
- Chef::Config.node_name(username)
56
- includer.chef_config
57
- end
58
-
59
- it "creates a default chef server HTTP client for Omnifetch" do
60
- client = CookbookOmnifetch.default_chef_server_http_client
61
- expect(client).to be_a_kind_of(ChefCLI::ChefServerAPIMulti)
62
- expect(client.url).to eq(url)
63
- expect(client.opts[:signing_key_filename]).to eq(key_path)
64
- expect(client.opts[:client_name]).to eq(username)
65
- end
66
-
67
- end
68
43
  end
@@ -0,0 +1,50 @@
1
+
2
+ # Copyright:: Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "chef-cli/cookbook_omnifetch"
20
+
21
+ describe "CookbookOmnifetch dependency" do
22
+ describe "lambda for default_chef_server_http_client" do
23
+ context "after chef config is loaded" do
24
+ let(:url) { "https://chef.example/organizations/myorg" }
25
+ let(:key_path) { "/path/to/my/key.pem" }
26
+ let(:username) { "my-username" }
27
+
28
+ before do
29
+ Chef::Config.chef_server_url(url)
30
+ Chef::Config.client_key(key_path)
31
+ Chef::Config.node_name(username)
32
+ end
33
+
34
+ it "creates a default chef server HTTP client for Omnifetch" do
35
+ client = CookbookOmnifetch.default_chef_server_http_client
36
+ expect(client).to be_a_kind_of(ChefCLI::ChefServerAPIMulti)
37
+ expect(client.url).to eq(url)
38
+ expect(client.opts[:signing_key_filename]).to eq(key_path)
39
+ expect(client.opts[:client_name]).to eq(username)
40
+ end
41
+ end
42
+
43
+ context "before chef config is loaded" do
44
+ it "raises an exception" do
45
+ expect { CookbookOmnifetch.default_chef_server_http_client }
46
+ .to raise_exception(ChefCLI::BUG)
47
+ end
48
+ end
49
+ end
50
+ end
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: 5.6.1
4
+ version: 5.6.8
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: 2022-02-16 00:00:00.000000000 Z
11
+ date: 2022-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -440,6 +440,7 @@ files:
440
440
  - spec/unit/commands_map_spec.rb
441
441
  - spec/unit/configurable_spec.rb
442
442
  - spec/unit/cookbook_metadata_spec.rb
443
+ - spec/unit/cookbook_omnifetch.rb
443
444
  - spec/unit/cookbook_profiler/git_spec.rb
444
445
  - spec/unit/cookbook_profiler/identifiers_spec.rb
445
446
  - spec/unit/fixtures/chef-runner-cookbooks/test_cookbook/recipes/recipe_one.rb
@@ -606,7 +607,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
606
607
  requirements:
607
608
  - - ">="
608
609
  - !ruby/object:Gem::Version
609
- version: '2.6'
610
+ version: '2.7'
610
611
  required_rubygems_version: !ruby/object:Gem::Requirement
611
612
  requirements:
612
613
  - - ">="
@@ -666,6 +667,7 @@ test_files:
666
667
  - spec/unit/commands_map_spec.rb
667
668
  - spec/unit/configurable_spec.rb
668
669
  - spec/unit/cookbook_metadata_spec.rb
670
+ - spec/unit/cookbook_omnifetch.rb
669
671
  - spec/unit/cookbook_profiler/git_spec.rb
670
672
  - spec/unit/cookbook_profiler/identifiers_spec.rb
671
673
  - spec/unit/fixtures/chef-runner-cookbooks/test_cookbook/recipes/recipe_one.rb