knife 17.3.13 → 17.3.48

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: c4910d4e2971cca8a2e720337272d4c5b8b547c15a3d921c35b0691b826a3cbd
4
- data.tar.gz: 4c9f8242f1370ffbf2fe6c68b6a08166a6b07bc88e9e93402383d1c64a81fe6c
3
+ metadata.gz: 31ea76674fe3c36ffd7530564334f6984f1b95cff36f966eb4aa31a51b8fc4cc
4
+ data.tar.gz: 88a1f4d1335f549e881c9142171f0ee831bb8a6848de85808d136da9d083cc53
5
5
  SHA512:
6
- metadata.gz: 4b1fa6278d191d23b017c2a8eb25d171e8002ab596efa84b8bf9fb699aa03c9aa191960878147b6af4c738f208f987387ce5ed2f1e754c5422742df958c1209f
7
- data.tar.gz: 4d7fb053ed8aedafb48004c291c5d5b78f327d941c1735d8de49352bc2a5a55ab4a1a1d86aa28b5722a07ea34cda0d3f0a09a6e091d680e784bcc85745ee6af8
6
+ metadata.gz: 18745c29c6a2c249d6ed67eef2d961f3175e4f2f124ba368caed230f2df4c037e58ba14666ca1bae726addc10fd14ae5658be654cc2cb506afc9e4cafe5afb9b
7
+ data.tar.gz: 63e4f77b325ba95b279d698885a8b92814938ab2c196b5da79ed36a570dc4f0a8ac26c8c56291686f02530cd8e51fb82f2d58f3cd4da13649c7afe271421728a
@@ -171,12 +171,12 @@ class Chef
171
171
  client_rb << "fips true\n"
172
172
  end
173
173
 
174
- unless chef_config[:file_cache_path].nil?
175
- client_rb << "file_cache_path \"#{chef_config[:file_cache_path]}\"\n"
174
+ unless chef_config[:unix_bootstrap_file_cache_path].nil?
175
+ client_rb << "file_cache_path \"#{chef_config[:unix_bootstrap_file_cache_path]}\"\n"
176
176
  end
177
177
 
178
- unless chef_config[:file_backup_path].nil?
179
- client_rb << "file_backup_path \"#{chef_config[:file_backup_path]}\"\n"
178
+ unless chef_config[:unix_bootstrap_file_backup_path].nil?
179
+ client_rb << "file_backup_path \"#{chef_config[:unix_bootstrap_file_backup_path]}\"\n"
180
180
  end
181
181
 
182
182
  client_rb
@@ -71,8 +71,8 @@ class Chef
71
71
  client_rb = <<~CONFIG
72
72
  chef_server_url "#{chef_config[:chef_server_url]}"
73
73
  validation_client_name "#{chef_config[:validation_client_name]}"
74
- file_cache_path "#{ChefConfig::PathHelper.escapepath(ChefConfig::Config.var_chef_dir(windows: true))}\\\\cache"
75
- file_backup_path "#{ChefConfig::PathHelper.escapepath(ChefConfig::Config.var_chef_dir(windows: true))}\\\\backup"
74
+ file_cache_path "#{ChefConfig::PathHelper.escapepath(chef_config[:windows_bootstrap_file_cache_path] || "")}"
75
+ file_backup_path "#{ChefConfig::PathHelper.escapepath(chef_config[:windows_bootstrap_file_backup_path] || "")}"
76
76
  cache_options ({:path => "#{ChefConfig::PathHelper.escapepath(ChefConfig::Config.etc_chef_dir(windows: true))}\\\\cache\\\\checksums", :skip_expires => true})
77
77
  CONFIG
78
78
 
@@ -134,6 +134,18 @@ class Chef
134
134
  boolean: true,
135
135
  default: false
136
136
 
137
+ option :pty,
138
+ long: "--[no-]pty",
139
+ description: "Request a PTY, enabled by default.",
140
+ boolean: true,
141
+ default: true
142
+
143
+ option :require_pty,
144
+ long: "--[no-]require-pty",
145
+ description: "Raise exception if a PTY cannot be acquired, disabled by default.",
146
+ boolean: true,
147
+ default: false
148
+
137
149
  def session
138
150
  ssh_error_handler = Proc.new do |server|
139
151
  if config[:on_error]
@@ -353,26 +365,26 @@ class Chef
353
365
  ui.msg(str)
354
366
  end
355
367
 
356
- def ssh_command(command, subsession = nil)
368
+ # @param command [String] the command to run
369
+ # @param session_list [???] list of sessions, one per node
370
+ #
371
+ def ssh_command(command, session_list = session)
372
+ stderr = ""
357
373
  exit_status = 0
358
- subsession ||= session
359
374
  command = fixup_sudo(command)
360
375
  command.force_encoding("binary") if command.respond_to?(:force_encoding)
361
- begin
362
- open_session(subsession, command)
363
- rescue => e
364
- open_session(subsession, command, true)
365
- end
366
- end
367
-
368
- def open_session(subsession, command, pty = false)
369
- stderr = ""
370
- exit_status = 0
371
- subsession.open_channel do |chan|
376
+ session_list.open_channel do |chan|
372
377
  if config[:on_error] && exit_status != 0
373
378
  chan.close
374
379
  else
375
- chan.request_pty if pty
380
+ if config[:pty]
381
+ chan.request_pty do |ch, success|
382
+ unless success
383
+ ui.warn("Failed to obtain a PTY from #{ch.connection.host}")
384
+ raise ArgumentError, "Request for PTY failed" if config[:require_pty]
385
+ end
386
+ end
387
+ end
376
388
  chan.exec command do |ch, success|
377
389
  raise ArgumentError, "Cannot execute #{command}" unless success
378
390
 
@@ -383,13 +395,11 @@ class Chef
383
395
  ichannel.send_data("#{get_password}\n")
384
396
  end
385
397
  end
386
-
387
398
  ch.on_extended_data do |_, _type, data|
388
- raise ArgumentError if data.eql?("sudo: no tty present and no askpass program specified\n")
399
+ raise ArgumentError, "No PTY present. If a PTY is required use --require-pty" if data.eql?("sudo: no tty present and no askpass program specified\n")
389
400
 
390
401
  stderr += data
391
402
  end
392
-
393
403
  ch.on_request "exit-status" do |ichannel, data|
394
404
  exit_status = [exit_status, data.read_long].max
395
405
  end
@@ -398,6 +408,8 @@ class Chef
398
408
  end
399
409
  session.loop
400
410
  exit_status
411
+ ensure
412
+ session_list.close
401
413
  end
402
414
 
403
415
  def get_password
@@ -50,7 +50,8 @@ class Chef
50
50
  rescue Net::HTTPClientException => e
51
51
  raise e unless /Forbidden/.match?(e.message)
52
52
 
53
- ui.error "Forbidden: You must be the maintainer of #{@cookbook_name} to unshare it."
53
+ ui.error "Forbidden: You must be the maintainer of #{@cookbook_name} to unshare it & #{config[:supermarket_site]} must allow maintainers to unshare cookbooks."
54
+ ui.warn "The default supermarket #{default_config[:supermarket_site]} does not allow maintainers to unshare cookbooks."
54
55
  exit 1
55
56
  end
56
57
 
@@ -17,7 +17,7 @@
17
17
  class Chef
18
18
  class Knife
19
19
  KNIFE_ROOT = File.expand_path("../..", __dir__)
20
- VERSION = "17.3.13".freeze
20
+ VERSION = "17.3.48".freeze
21
21
  end
22
22
  end
23
23
 
@@ -66,7 +66,7 @@ describe "knife cookbook download", :workstation do
66
66
  Downloading root_files
67
67
  Cookbook downloaded to #{tmpdir}/x-1.0.1
68
68
  EOM
69
- )
69
+ )
70
70
  end
71
71
  end
72
72
  end
@@ -80,16 +80,16 @@ describe Chef::Knife::Core::BootstrapContext do
80
80
  end
81
81
  end
82
82
 
83
- describe "when file_cache_path is set" do
84
- let(:chef_config) { { file_cache_path: "/home/opscode/cache" } }
85
- it "sets file_cache_path in the generated config file" do
83
+ describe "when unix_bootstrap_file_cache_path is set" do
84
+ let(:chef_config) { { unix_bootstrap_file_cache_path: "/home/opscode/cache" } }
85
+ it "sets unix_bootstrap_file_cache_path in the generated config file" do
86
86
  expect(bootstrap_context.config_content).to include("file_cache_path \"/home/opscode/cache\"")
87
87
  end
88
88
  end
89
89
 
90
- describe "when file_backup_path is set" do
91
- let(:chef_config) { { file_backup_path: "/home/opscode/backup" } }
92
- it "sets file_backup_path in the generated config file" do
90
+ describe "when unix_bootstrap_file_backup_path is set" do
91
+ let(:chef_config) { { unix_bootstrap_file_backup_path: "/home/opscode/backup" } }
92
+ it "sets unix_bootstrap_file_backup_path in the generated config file" do
93
93
  expect(bootstrap_context.config_content).to include("file_backup_path \"/home/opscode/backup\"")
94
94
  end
95
95
  end
@@ -154,8 +154,8 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
154
154
  config_log_location: STDOUT,
155
155
  chef_server_url: "http://chef.example.com:4444",
156
156
  validation_client_name: "chef-validator-testing",
157
- file_cache_path: "c:/chef/cache",
158
- file_backup_path: "c:/chef/backup",
157
+ windows_bootstrap_file_cache_path: "c:/chef/cache",
158
+ windows_bootstrap_file_backup_path: "c:/chef/backup",
159
159
  cache_options: ({ path: "c:/chef/cache/checksums", skip_expires: true })
160
160
  )
161
161
  )
@@ -165,8 +165,8 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
165
165
  expected = <<~EXPECTED
166
166
  echo.chef_server_url "http://chef.example.com:4444"
167
167
  echo.validation_client_name "chef-validator-testing"
168
- echo.file_cache_path "C:\\\\chef\\\\cache"
169
- echo.file_backup_path "C:\\\\chef\\\\backup"
168
+ echo.file_cache_path "c:/chef/cache"
169
+ echo.file_backup_path "c:/chef/backup"
170
170
  echo.cache_options ^({:path =^> "C:\\\\chef\\\\cache\\\\checksums", :skip_expires =^> true}^)
171
171
  echo.# Using default node name ^(fqdn^)
172
172
  echo.log_level :auto
@@ -289,7 +289,7 @@ describe Chef::Knife::Ssh do
289
289
  let(:execution_channel2) { double(:execution_channel, on_data: nil, on_extended_data: nil) }
290
290
  let(:session_channel2) { double(:session_channel, request_pty: nil) }
291
291
 
292
- let(:session) { double(:session, loop: nil) }
292
+ let(:session) { double(:session, loop: nil, close: nil) }
293
293
 
294
294
  let(:command) { "false" }
295
295
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.3.13
4
+ version: 17.3.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-30 00:00:00.000000000 Z
11
+ date: 2021-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -1149,7 +1149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1149
1149
  - !ruby/object:Gem::Version
1150
1150
  version: '0'
1151
1151
  requirements: []
1152
- rubygems_version: 3.2.15
1152
+ rubygems_version: 3.2.22
1153
1153
  signing_key:
1154
1154
  specification_version: 4
1155
1155
  summary: The knife CLI for Chef Infra.