knife 19.0.105 → 19.0.128
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 +4 -4
- data/Gemfile +1 -1
- data/Rakefile +11 -13
- data/knife.gemspec +2 -2
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/edit.rb +1 -1
- data/lib/chef/knife/user_edit.rb +1 -1
- data/lib/chef/knife/version.rb +1 -1
- data/lib/chef/knife.rb +26 -10
- data/spec/unit/knife_spec.rb +62 -0
- metadata +12 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eeae2baecd778463ca309c0b348c3c531a2ff534603b7f1d3b5668a60cf460a6
|
|
4
|
+
data.tar.gz: 2ed971ba06ff2116df89ba4c20df43a93178eaf53bf80d74a9ddc4a400d49e59
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c323e72f2c9e1fbe0208ca8416f0ea139486c26ed986b0e81ac182ce9223635cc0d8b0f93d70eb9885e904ee830619027b0e2715690852af64413c82ac6017f
|
|
7
|
+
data.tar.gz: 339034783d91f0b83bf0ca27f990ab1b5b5d85acf7a4d7447756a509734017392eabe8f1de18ed77bbb654c3305e5c9c06632c417821e0ccf14984291c1ad40b
|
data/Gemfile
CHANGED
|
@@ -28,7 +28,7 @@ gem "mixlib-authentication", "=3.0.10" #Pinning this to a specific version to av
|
|
|
28
28
|
group :development, :test do
|
|
29
29
|
gem "cheffish", ">= 14"
|
|
30
30
|
gem "webmock"
|
|
31
|
-
gem "crack", "< 0.
|
|
31
|
+
gem "crack", "< 1.0.2"
|
|
32
32
|
gem "rake", ">= 12.3.3"
|
|
33
33
|
gem "rspec"
|
|
34
34
|
gem "abbrev"
|
data/Rakefile
CHANGED
|
@@ -32,25 +32,23 @@ rescue LoadError
|
|
|
32
32
|
puts "rspec not available. bundle install first to make sure all dependencies are installed."
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
desc "Check Linting and code style."
|
|
36
|
+
task :style do
|
|
37
37
|
require "rubocop/rake_task"
|
|
38
|
+
require "cookstyle/chefstyle"
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
|
|
41
|
+
# Windows-specific command, rubocop erroneously reports the CRLF in each file which is removed when your PR is uploaded to GitHub.
|
|
42
|
+
# This is a workaround to ignore the CRLF from the files before running cookstyle.
|
|
43
|
+
sh "cookstyle --chefstyle -c .rubocop.yml --except Layout/EndOfLine"
|
|
44
|
+
else
|
|
45
|
+
sh "cookstyle --chefstyle -c .rubocop.yml"
|
|
44
46
|
end
|
|
45
|
-
|
|
46
|
-
# Alias for convenience
|
|
47
|
-
desc "Run cookstyle style checks"
|
|
48
|
-
task style: "style:cookstyle"
|
|
49
47
|
rescue LoadError
|
|
50
|
-
puts "
|
|
48
|
+
puts "Rubocop or Cookstyle gems are not installed. bundle install first to make sure all dependencies are installed."
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
desc "Run all quality tasks"
|
|
54
|
-
task quality: [
|
|
52
|
+
task quality: [:style]
|
|
55
53
|
|
|
56
54
|
task default: [:spec]
|
data/knife.gemspec
CHANGED
|
@@ -21,14 +21,14 @@ Gem::Specification.new do |s|
|
|
|
21
21
|
s.add_dependency "mixlib-cli", ">= 2.1.1", "< 3.0"
|
|
22
22
|
s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
|
|
23
23
|
s.add_dependency "ffi", ">= 1.15", "< 1.18.0"
|
|
24
|
-
s.add_dependency "ffi-yajl", "
|
|
24
|
+
s.add_dependency "ffi-yajl", ">= 2.2", "< 4.0"
|
|
25
25
|
s.add_dependency "net-ssh", ">= 5.1", "< 8"
|
|
26
26
|
s.add_dependency "net-ssh-multi", "~> 1.2", ">= 1.2.1"
|
|
27
27
|
s.add_dependency "bcrypt_pbkdf", "~> 1.1" # ed25519 ssh key support
|
|
28
28
|
s.add_dependency "ed25519", ">= 1.2", "< 2.0" # ed25519 ssh key support
|
|
29
29
|
# disabling this until we get get it to compile on RHEL 7
|
|
30
30
|
# s.add_dependency "x25519", ">= 1.0.9" # ed25519 KEX module. 1.0.9+ required to resolve sigill failures
|
|
31
|
-
s.add_dependency "highline", ">= 1.6.9", "<
|
|
31
|
+
s.add_dependency "highline", ">= 1.6.9", "< 4" # Used in UI to present a list, no other usage.
|
|
32
32
|
s.add_dependency "abbrev"
|
|
33
33
|
|
|
34
34
|
s.add_dependency "tty-prompt", "~> 0.21" # knife ui.ask prompt
|
data/lib/chef/knife/core/ui.rb
CHANGED
|
@@ -234,7 +234,7 @@ class Chef
|
|
|
234
234
|
tf.sync = true
|
|
235
235
|
tf.puts output
|
|
236
236
|
tf.close
|
|
237
|
-
raise "Please set EDITOR environment variable. See https://docs.chef.io/workstation/
|
|
237
|
+
raise "Please set EDITOR environment variable. See https://docs.chef.io/workstation/26/tools/knife/set_up/#set-a-text-editor for details." unless system("#{config[:editor]} #{tf.path}")
|
|
238
238
|
|
|
239
239
|
output = File.read(tf.path)
|
|
240
240
|
end
|
data/lib/chef/knife/edit.rb
CHANGED
|
@@ -74,7 +74,7 @@ class Chef
|
|
|
74
74
|
|
|
75
75
|
# Let the user edit the temporary file
|
|
76
76
|
unless system("#{config[:editor]} #{file.path}")
|
|
77
|
-
raise "Please set EDITOR environment variable. See https://docs.chef.io/workstation/
|
|
77
|
+
raise "Please set EDITOR environment variable. See https://docs.chef.io/workstation/26/tools/knife/set_up/#set-a-text-editor for details."
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
result_text = File.read(file.path)
|
data/lib/chef/knife/user_edit.rb
CHANGED
|
@@ -81,7 +81,7 @@ class Chef
|
|
|
81
81
|
f.sync = true
|
|
82
82
|
f.puts output
|
|
83
83
|
f.close
|
|
84
|
-
raise "Please set EDITOR environment variable. See https://docs.chef.io/workstation/
|
|
84
|
+
raise "Please set EDITOR environment variable. See https://docs.chef.io/workstation/26/tools/knife/set_up/#set-a-text-editor for details." unless system("#{config[:editor]} #{f.path}")
|
|
85
85
|
|
|
86
86
|
edited_user = JSON.parse(File.read(f.path))
|
|
87
87
|
end
|
data/lib/chef/knife/version.rb
CHANGED
data/lib/chef/knife.rb
CHANGED
|
@@ -102,17 +102,33 @@ class Chef
|
|
|
102
102
|
def self.inherited(subclass)
|
|
103
103
|
super
|
|
104
104
|
unless subclass.unnamed?
|
|
105
|
+
caller_path = if subclass.superclass.to_s == "Chef::ChefFS::Knife"
|
|
106
|
+
# ChefFS-based commands have a superclass that defines an
|
|
107
|
+
# inherited method which calls super. This means that the
|
|
108
|
+
# top of the call stack is not the class definition for
|
|
109
|
+
# our subcommand. Try the second entry in the call stack.
|
|
110
|
+
path_from_caller(caller[1])
|
|
111
|
+
else
|
|
112
|
+
path_from_caller(caller[0])
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Skip classes defined inside a subdirectory of the lib/chef/knife/ tree
|
|
116
|
+
# (e.g. lib/chef/knife/cloud/server/create_command.rb). By convention,
|
|
117
|
+
# real knife subcommands live directly at lib/chef/knife/<name>.rb —
|
|
118
|
+
# the same flat pattern that GemGlobLoader uses when discovering
|
|
119
|
+
# commands. Abstract base classes from plugins like knife-cloud are
|
|
120
|
+
# nested in subdirs and are only loaded transitively; registering them
|
|
121
|
+
# causes spurious categories (e.g. ** SERVER COMMANDS **) to appear in
|
|
122
|
+
# 'knife --help'.
|
|
123
|
+
#
|
|
124
|
+
# NOTE: The regex anchors to /lib/chef/knife/ to avoid false positives
|
|
125
|
+
# from Habitat package paths, where the package origin and name appear
|
|
126
|
+
# in the path (e.g. /hab/pkgs/chef/knife/19.0.99/…) and would otherwise
|
|
127
|
+
# match a looser pattern like /chef/knife/[^/]+/.
|
|
128
|
+
return if caller_path.match?(%r{/lib/chef/knife/[^/]+/})
|
|
129
|
+
|
|
105
130
|
subcommands[subclass.snake_case_name] = subclass
|
|
106
|
-
subcommand_files[subclass.snake_case_name] +=
|
|
107
|
-
if subclass.superclass.to_s == "Chef::ChefFS::Knife"
|
|
108
|
-
# ChefFS-based commands have a superclass that defines an
|
|
109
|
-
# inherited method which calls super. This means that the
|
|
110
|
-
# top of the call stack is not the class definition for
|
|
111
|
-
# our subcommand. Try the second entry in the call stack.
|
|
112
|
-
[path_from_caller(caller[1])]
|
|
113
|
-
else
|
|
114
|
-
[path_from_caller(caller[0])]
|
|
115
|
-
end
|
|
131
|
+
subcommand_files[subclass.snake_case_name] += [caller_path]
|
|
116
132
|
end
|
|
117
133
|
end
|
|
118
134
|
|
data/spec/unit/knife_spec.rb
CHANGED
|
@@ -158,6 +158,68 @@ describe Chef::Knife do
|
|
|
158
158
|
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
+
describe "subdirectory subcommand filtering" do
|
|
162
|
+
before do
|
|
163
|
+
Chef::Knife.reset_subcommands!
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
after do
|
|
167
|
+
%i{CloudSubdirCommand FlatKnifeCommand HabitatKnifeCommand CheffsSubdirCommand}.each do |const|
|
|
168
|
+
KnifeSpecs.send(:remove_const, const) if KnifeSpecs.const_defined?(const)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it "does not register subcommands defined in a subdirectory of lib/chef/knife/" do
|
|
173
|
+
allow(Chef::Knife).to receive(:path_from_caller)
|
|
174
|
+
.and_return("/some/gem/lib/chef/knife/cloud/server/create_command.rb")
|
|
175
|
+
|
|
176
|
+
module KnifeSpecs
|
|
177
|
+
class CloudSubdirCommand < Chef::Knife; end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
expect(Chef::Knife.subcommands).not_to have_key("cloud_subdir_command")
|
|
181
|
+
expect(Chef::Knife.subcommand_files).not_to have_key("cloud_subdir_command")
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it "registers subcommands defined directly in lib/chef/knife/ (flat path)" do
|
|
185
|
+
allow(Chef::Knife).to receive(:path_from_caller)
|
|
186
|
+
.and_return("/some/gem/lib/chef/knife/flat_knife_command.rb")
|
|
187
|
+
|
|
188
|
+
module KnifeSpecs
|
|
189
|
+
class FlatKnifeCommand < Chef::Knife; end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
expect(Chef::Knife.subcommands).to have_key("flat_knife_command")
|
|
193
|
+
expect(Chef::Knife.subcommand_files["flat_knife_command"]).to eq(["/some/gem/lib/chef/knife/flat_knife_command.rb"])
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "does not filter subcommands loaded from Habitat package paths" do
|
|
197
|
+
# Habitat paths contain /chef/knife/ as the package origin/name segment,
|
|
198
|
+
# e.g. /hab/pkgs/chef/knife/19.0.99/lib/chef/knife/foo.rb. The regex must
|
|
199
|
+
# anchor to /lib/chef/knife/ to avoid false positives on these paths.
|
|
200
|
+
allow(Chef::Knife).to receive(:path_from_caller)
|
|
201
|
+
.and_return("/hab/pkgs/chef/knife/19.0.99/lib/chef/knife/habitat_knife_command.rb")
|
|
202
|
+
|
|
203
|
+
module KnifeSpecs
|
|
204
|
+
class HabitatKnifeCommand < Chef::Knife; end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
expect(Chef::Knife.subcommands).to have_key("habitat_knife_command")
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it "does not register ChefFS-based subcommands defined in subdirectories of lib/chef/knife/" do
|
|
211
|
+
# ChefFS commands use caller[1] for path detection; filtering should still apply.
|
|
212
|
+
allow(Chef::Knife).to receive(:path_from_caller)
|
|
213
|
+
.and_return("/some/gem/lib/chef/knife/cloud/cheffs_subdir_command.rb")
|
|
214
|
+
|
|
215
|
+
module KnifeSpecs
|
|
216
|
+
class CheffsSubdirCommand < Chef::ChefFS::Knife; end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
expect(Chef::Knife.subcommands).not_to have_key("cheffs_subdir_command")
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
161
223
|
describe "the headers include X-Remote-Request-Id" do
|
|
162
224
|
|
|
163
225
|
let(:headers) do
|
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: 19.0.
|
|
4
|
+
version: 19.0.128
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Jacob
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-06-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: train-core
|
|
@@ -128,16 +128,22 @@ dependencies:
|
|
|
128
128
|
name: ffi-yajl
|
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
|
130
130
|
requirements:
|
|
131
|
-
- - "
|
|
131
|
+
- - ">="
|
|
132
132
|
- !ruby/object:Gem::Version
|
|
133
133
|
version: '2.2'
|
|
134
|
+
- - "<"
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: '4.0'
|
|
134
137
|
type: :runtime
|
|
135
138
|
prerelease: false
|
|
136
139
|
version_requirements: !ruby/object:Gem::Requirement
|
|
137
140
|
requirements:
|
|
138
|
-
- - "
|
|
141
|
+
- - ">="
|
|
139
142
|
- !ruby/object:Gem::Version
|
|
140
143
|
version: '2.2'
|
|
144
|
+
- - "<"
|
|
145
|
+
- !ruby/object:Gem::Version
|
|
146
|
+
version: '4.0'
|
|
141
147
|
- !ruby/object:Gem::Dependency
|
|
142
148
|
name: net-ssh
|
|
143
149
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -221,7 +227,7 @@ dependencies:
|
|
|
221
227
|
version: 1.6.9
|
|
222
228
|
- - "<"
|
|
223
229
|
- !ruby/object:Gem::Version
|
|
224
|
-
version: '
|
|
230
|
+
version: '4'
|
|
225
231
|
type: :runtime
|
|
226
232
|
prerelease: false
|
|
227
233
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -231,7 +237,7 @@ dependencies:
|
|
|
231
237
|
version: 1.6.9
|
|
232
238
|
- - "<"
|
|
233
239
|
- !ruby/object:Gem::Version
|
|
234
|
-
version: '
|
|
240
|
+
version: '4'
|
|
235
241
|
- !ruby/object:Gem::Dependency
|
|
236
242
|
name: abbrev
|
|
237
243
|
requirement: !ruby/object:Gem::Requirement
|