chef-cli 5.6.1 → 5.6.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 308c1bbb1d1f4d2070055036818dc566c577d28cd3c6ab476054029302082676
4
- data.tar.gz: a5cc534e4f0d0ae65347b5b438ffc968b4dc982078a37e6c89ff1a351eee4ee3
3
+ metadata.gz: f99463373ae13f85a16df321c3bb756e8eba19d8e1e7f15b3ae3f2eb173253f2
4
+ data.tar.gz: 9f7d1ebb555efa92cc22c8957f24b18f1bb823e19e140518838318584158b8c0
5
5
  SHA512:
6
- metadata.gz: 6d53620886e274948207b24d28dcb1bae9f3b784d64783ae42b9698f5359c6ef1653bb1a65417d3309a0bdef10d3254663049447c9a6cdfdcfe1321739335a7d
7
- data.tar.gz: abc2a02f25e66edb3bd03b9c1a4903310f1029f699107b23565e3629cacb65b8254faaacb8354f2a00b1c9b6155eaa39df1f3709542eb840f5a2477310b221e4
6
+ metadata.gz: c602f596eac142ce3fbf2f81dbdc987f22768e3b4c35fbb0c1d5615eb94eaba4085444ae4a7270986229c1ff90b4f81eddb36b87a1ae9db353c96f43f613d25d
7
+ data.tar.gz: e2956dcc853d9a61e74ad243e9fd7f8a391687f5be8e82a72ba89408b1a97025ef1a5f274867ca4ff99f807dee0432bb76ec1a75a3ea478132253d5f965acc50
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
@@ -122,7 +122,7 @@ module ChefCLI
122
122
  return "" unless (completion_template_basename = completion_template_for(shell))
123
123
 
124
124
  completion_template_path = expand_completion_template_path(completion_template_basename)
125
- erb = ERB.new(File.read(completion_template_path), nil, "-")
125
+ erb = ERB.new(File.read(completion_template_path), trim_mode: "-")
126
126
  context_binding = shell_completion_template_context.get_binding
127
127
  erb.result(context_binding)
128
128
  end
@@ -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
@@ -112,7 +112,7 @@ module ChefCLI
112
112
  ui.msg ""
113
113
 
114
114
  ui.msg "Lockfile written to #{policyfile_lock_expanded_path}"
115
- ui.msg "Policy revision id: #{policyfile_lock.revision_id}"
115
+ ui.msg "Policy revision id: #{lock_data["revision_id"]}"
116
116
  rescue => error
117
117
  raise PolicyfileInstallError.new("Failed to generate Policyfile.lock", error)
118
118
  end
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "5.6.1".freeze
19
+ VERSION = "5.6.11".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.11
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: 2023-03-27 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