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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cd95c9dbe5fda112735648cc547204c0e8e22644f25eabd6f32eb4a77db0479
4
- data.tar.gz: 2e90de239ce72661cec2541039571666300e22d5075dd3099baac2e810026198
3
+ metadata.gz: eeae2baecd778463ca309c0b348c3c531a2ff534603b7f1d3b5668a60cf460a6
4
+ data.tar.gz: 2ed971ba06ff2116df89ba4c20df43a93178eaf53bf80d74a9ddc4a400d49e59
5
5
  SHA512:
6
- metadata.gz: a3d7932437feb38d272cbf31ea4559fab0a75f3b671b9135f668ad8c72ecbfcc5948266bded6d0e839190a271d47df3d46a9ffbfa54c445e9da1462cee52625a
7
- data.tar.gz: 9a8b210c74e903634527b2e12e91927f57ecadad3273932be04a14dd607279f4c88c37db19ba3434f21ced93f1f0b1378d5026d001b4fac17e77b5aaadf414d1
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.4.6"
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
- begin
36
- require "cookstyle/chefstyle"
35
+ desc "Check Linting and code style."
36
+ task :style do
37
37
  require "rubocop/rake_task"
38
+ require "cookstyle/chefstyle"
38
39
 
39
- namespace :style do
40
- desc "Run cookstyle style checks"
41
- RuboCop::RakeTask.new(:cookstyle) do |task|
42
- task.options += ["--display-cop-names", "--no-color"]
43
- end
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 "cookstyle/chefstyle is not available. (sudo) gem install cookstyle to do style checking."
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: ["style:cookstyle"]
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", "~> 2.2"
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", "< 3" # Used in UI to present a list, no other usage.
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
@@ -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/knife_setup/#setting-your-text-editor for details." unless system("#{config[:editor]} #{tf.path}")
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
@@ -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/knife_setup/#setting-your-text-editor for details."
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)
@@ -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/knife_setup/#setting-your-text-editor for details." unless system("#{config[:editor]} #{f.path}")
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
@@ -17,6 +17,6 @@
17
17
  class Chef
18
18
  class Knife
19
19
  KNIFE_ROOT = File.expand_path("../..", __dir__)
20
- VERSION = "19.0.105".freeze
20
+ VERSION = "19.0.128".freeze
21
21
  end
22
22
  end
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
 
@@ -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.105
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-04-08 00:00:00.000000000 Z
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: '3'
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: '3'
240
+ version: '4'
235
241
  - !ruby/object:Gem::Dependency
236
242
  name: abbrev
237
243
  requirement: !ruby/object:Gem::Requirement