knife 17.10.0 → 18.1.0

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: 555723f352d005f6f3433b771c6804d8cf70b83b983baa9d626d9c2438609443
4
- data.tar.gz: d310fe22078eecdf79bf322a0256dc3197cfe638471983429383a08f05946986
3
+ metadata.gz: f50483e20a5a03bee979772342e9e6edf457b3ae55305aa07fdb5686d79739bc
4
+ data.tar.gz: 8b3d3cddf2a89a74a1c39c634a87c6415480d2dc38ad3a6b443d1f2817ff11e0
5
5
  SHA512:
6
- metadata.gz: 68ab4a40999b28c80de1376cc0a1211d0150a7cac5d55257821d38da7faad43329b46cb7ce725ac19087bff494e007b311e9ebe3ac17f524533c5774118f85eb
7
- data.tar.gz: bee5256b0e182287ad22ac9bc7fdd664d917e7236d187e384e6673d388a42b28bc4a46f9887e7d80673c6783c87b52a99aa9c823a097e43a1c0993b8b7f20f25
6
+ metadata.gz: 7ec7cb8dbd3ae26dc5ff735849c30f8e39c4e7bc410e11215a9d0afb5e3a8f2224c75ce3b6437cdb38885f037f7ce4197a6f884523366fe4d96d309b33da5553
7
+ data.tar.gz: c1d2768abf634d5e089882128424f33500509028396f59615f4c2ae00685c263f0458e4e79f3e0a2257ba9d721a244d00d609be09121697d74e54ec77f9303fc
data/Gemfile CHANGED
@@ -2,6 +2,9 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "knife", path: "."
4
4
 
5
+ # proxifier gem is busted on ruby 3.1 and seems abandoned so use git fork of gem
6
+ gem "proxifier", git: "https://github.com/chef/ruby-proxifier", branch: "lcg/ruby-3"
7
+
5
8
  group(:development, :test) do
6
9
  gem "cheffish", ">= 14" # testing only , but why didn't this need to explicit in chef?
7
10
  gem "webmock" # testing only
@@ -20,7 +23,7 @@ group(:chefstyle) do
20
23
  gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "main"
21
24
  end
22
25
 
23
- gem "ohai", git: "https://github.com/chef/ohai.git", branch: "17-stable"
26
+ gem "ohai", git: "https://github.com/chef/ohai.git", branch: "main"
24
27
  gem "chef", path: ".."
25
28
  gem "chef-utils", path: File.expand_path("../chef-utils", __dir__) if File.exist?(File.expand_path("../chef-utils", __dir__))
26
29
  gem "chef-config", path: File.expand_path("../chef-config", __dir__) if File.exist?(File.expand_path("../chef-config", __dir__))
data/knife.gemspec CHANGED
@@ -13,20 +13,20 @@ Gem::Specification.new do |s|
13
13
  s.email = "adam@chef.io" # These seem a bit out of date, and this address probably doesn't go anywhere anymore?
14
14
  s.homepage = "https://www.chef.io"
15
15
 
16
- s.required_ruby_version = ">= 2.7.0"
16
+ s.required_ruby_version = ">= 3.1.0"
17
17
 
18
18
  s.add_dependency "chef-config", ">= #{Chef::Knife::VERSION.split(".").first}"
19
19
  s.add_dependency "chef-utils", ">= #{Chef::Knife::VERSION.split(".").first}"
20
20
  s.add_dependency "chef", ">= #{Chef::Knife::VERSION.split(".").first}"
21
- s.add_dependency "train-core", "~> 3.2", ">= 3.2.28" # 3.2.28 fixes sudo prompts. See https://github.com/chef/chef/pull/9635
21
+ s.add_dependency "train-core", "~> 3.10" # 3.2.28 fixes sudo prompts. See https://github.com/chef/chef/pull/9635
22
22
  s.add_dependency "train-winrm", ">= 0.2.5"
23
23
  s.add_dependency "license-acceptance", ">= 1.0.5", "< 3"
24
24
  s.add_dependency "mixlib-cli", ">= 2.1.1", "< 3.0"
25
25
  s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
26
- s.add_dependency "ohai", "~> 17.0"
26
+ s.add_dependency "ohai", "~> 18.0"
27
27
  s.add_dependency "ffi", ">= 1.15" # 1.14 versions are broken on i386 windows
28
28
  s.add_dependency "ffi-yajl", "~> 2.2"
29
- s.add_dependency "net-ssh", ">= 5.1", "< 7"
29
+ s.add_dependency "net-ssh", ">= 5.1", "< 8"
30
30
  s.add_dependency "net-ssh-multi", "~> 1.2", ">= 1.2.1"
31
31
  s.add_dependency "bcrypt_pbkdf", "~> 1.1" # ed25519 ssh key support
32
32
  # disabling this until we get get it to compile on RHEL 7
@@ -973,7 +973,7 @@ class Chef
973
973
  # for this. We will also set keys_only to false only if there are keys
974
974
  # and no password.
975
975
  # If both are present, train(via net/ssh) will prefer keys, falling back to password.
976
- # Reference: https://github.com/chef/chef/blob/master/lib/chef/knife/ssh.rb#L272
976
+ # Reference: https://github.com/chef/chef/blob/main/lib/chef/knife/ssh.rb#L272
977
977
  opts[:keys_only] = config.key?(:connection_password) == false
978
978
  else
979
979
  opts[:key_files] = []
@@ -138,7 +138,7 @@ class Chef
138
138
 
139
139
  # @return [String] the path to the user's .chef directory
140
140
  def chef_config_path
141
- @chef_config_path ||= ChefConfig::PathHelper.home(".chef")
141
+ @chef_config_path ||= ChefConfig::PathHelper.home(ChefUtils::Dist::Infra::USER_CONF_DIR)
142
142
  end
143
143
 
144
144
  # @return [String] the full path to the config file (credential file)
@@ -233,7 +233,7 @@ class Chef
233
233
  tf.sync = true
234
234
  tf.puts output
235
235
  tf.close
236
- raise "Please set EDITOR environment variable. See https://docs.chef.io/knife_setup/ for details." unless system("#{config[:editor]} #{tf.path}")
236
+ 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
237
 
238
238
  output = IO.read(tf.path)
239
239
  end
@@ -71,7 +71,8 @@ class Chef
71
71
 
72
72
  error = false
73
73
  pattern_args.each do |pattern|
74
- if Chef::ChefFS::FileSystem.copy_to(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, config, ui, proc { |entry| format_path(entry) })
74
+ fs_error, result = Chef::ChefFS::FileSystem.copy_to(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, config, ui, proc { |entry| format_path(entry) })
75
+ if fs_error
75
76
  error = true
76
77
  end
77
78
  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/knife_setup/ for details."
77
+ raise "Please set EDITOR environment variable. See https://docs.chef.io/workstation/knife_setup/#setting-your-text-editor for details."
78
78
  end
79
79
 
80
80
  result_text = IO.read(file.path)
@@ -156,7 +156,7 @@ class Chef
156
156
 
157
157
  def convert_path(upstream_file)
158
158
  # converts a Windows path (C:\foo) to a mingw path (/c/foo)
159
- if ENV["MSYSTEM"] == "MINGW32"
159
+ if ENV["MSYSTEM"] == ( "MINGW32" || "UCRT64" )
160
160
  upstream_file.sub(/^([[:alpha:]]):/, '/\1')
161
161
  else
162
162
  Shellwords.escape upstream_file
@@ -73,7 +73,8 @@ class Chef
73
73
 
74
74
  error = false
75
75
  pattern_args.each do |pattern|
76
- if Chef::ChefFS::FileSystem.copy_to(pattern, local_fs, chef_fs, config[:recurse] ? nil : 1, config, ui, proc { |entry| format_path(entry) })
76
+ fs_error, result = Chef::ChefFS::FileSystem.copy_to(pattern, local_fs, chef_fs, config[:recurse] ? nil : 1, config, ui, proc { |entry| format_path(entry) })
77
+ if fs_error
77
78
  error = true
78
79
  end
79
80
  end
@@ -128,6 +128,7 @@ class Chef
128
128
  display_name: "#{user.first_name} #{user.last_name}",
129
129
  email: user.email,
130
130
  password: password,
131
+ create_key: user.create_key,
131
132
  }
132
133
  else
133
134
  user_hash = {
@@ -137,6 +138,7 @@ class Chef
137
138
  display_name: user.display_name,
138
139
  email: user.email,
139
140
  password: password,
141
+ create_key: user.create_key,
140
142
  }
141
143
  end
142
144
 
@@ -159,13 +161,13 @@ class Chef
159
161
  end
160
162
 
161
163
  ui.info("Created #{user.username}")
162
- if final_user["private_key"]
164
+ if final_user["chef_key"] && final_user["chef_key"]["private_key"]
163
165
  if config[:file]
164
166
  File.open(config[:file], "w") do |f|
165
- f.print(final_user["private_key"])
167
+ f.print(final_user["chef_key"]["private_key"])
166
168
  end
167
169
  else
168
- ui.msg final_user["private_key"]
170
+ ui.msg final_user["chef_key"]["private_key"]
169
171
  end
170
172
  end
171
173
  end
@@ -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/knife_setup/ for details." unless system("#{config[:editor]} #{f.path}")
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}")
85
85
 
86
86
  edited_user = JSON.parse(IO.read(f.path))
87
87
  end
@@ -17,7 +17,7 @@
17
17
  class Chef
18
18
  class Knife
19
19
  KNIFE_ROOT = File.expand_path("../..", __dir__)
20
- VERSION = "17.10.0".freeze
20
+ VERSION = "18.1.0".freeze
21
21
  end
22
22
  end
23
23
 
@@ -127,6 +127,10 @@ def freebsd?
127
127
  RUBY_PLATFORM.include?("freebsd")
128
128
  end
129
129
 
130
+ def freebsd_gte_12_3?
131
+ RUBY_PLATFORM.include?("freebsd") && !!(ohai[:platform_version].to_f >= 12.3)
132
+ end
133
+
130
134
  def intel_64bit?
131
135
  !!(ohai[:kernel][:machine] == "x86_64")
132
136
  end
@@ -16,7 +16,6 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
  #
19
-
20
19
  require "knife_spec_helper"
21
20
 
22
21
  Chef::Knife::UserCreate.load_deps
@@ -80,7 +79,7 @@ describe Chef::Knife::UserCreate do
80
79
  before :each do
81
80
  @user = double("Chef::User")
82
81
  @key = "You don't come into cooking to get rich - Ramsay"
83
- allow(@user).to receive(:[]).with("private_key").and_return(@key)
82
+ allow(@user).to receive(:[]).with("chef_key").and_return(@key)
84
83
  knife.config[:passwordprompt] = true
85
84
  knife.name_args = name_args
86
85
  end
@@ -97,7 +96,7 @@ describe Chef::Knife::UserCreate do
97
96
  before do
98
97
  @user = double("Chef::User")
99
98
  @key = "You don't come into cooking to get rich - Ramsay"
100
- allow(@user).to receive(:[]).with("private_key").and_return(@key)
99
+ allow(@user).to receive(:[]).with("chef_key").and_return(@key)
101
100
  knife.name_args = %w{some_user some_display_name some_first_name some_last_name some_email some_password}
102
101
  end
103
102
 
@@ -177,17 +176,39 @@ describe Chef::Knife::UserCreate do
177
176
 
178
177
  describe "with user_name, first_name, last_name, email and password" do
179
178
  let(:name_args) { %w{some_user some_display_name some_first_name some_last_name test@email.com some_password} }
179
+ before :each do
180
+ @user = double("Chef::User")
181
+ expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest)
182
+ expect(root_rest).to receive(:post).and_return(@user)
183
+ @key = IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"))
184
+ allow(@user).to receive(:[]).with("chef_key").and_return(nil)
185
+ knife.name_args = name_args
186
+ end
187
+
188
+ it "creates an user without private key" do
189
+ expect(knife.ui).to_not receive(:msg).with(@key)
190
+ knife.run
191
+ end
192
+ end
180
193
 
194
+ describe "with user_name, first_name, last_name, email and password" do
195
+ let(:name_args) { %w{some_user some_display_name some_first_name some_last_name test@email.com some_password} }
181
196
  before :each do
182
197
  @user = double("Chef::User")
183
198
  expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest)
184
199
  expect(root_rest).to receive(:post).and_return(@user)
185
- @key = "You don't come into cooking to get rich - Ramsay"
186
- allow(@user).to receive(:[]).with("private_key").and_return(@key)
200
+ @username = "Created #{name_args.first}"
201
+ @key = IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"))
202
+ allow(@user).to receive(:[]).with("chef_key").and_return("private_key" => @key)
187
203
  knife.name_args = name_args
188
204
  end
189
205
 
190
206
  it "creates an user" do
207
+ expect(knife.ui).to receive(:info).with(@username)
208
+ knife.run
209
+ end
210
+
211
+ it "creates an user private key" do
191
212
  expect(knife.ui).to receive(:msg).with(@key)
192
213
  knife.run
193
214
  end
@@ -204,7 +225,6 @@ describe Chef::Knife::UserCreate do
204
225
  }
205
226
 
206
227
  it "creates an user, associates a user, and adds it to the admins group" do
207
-
208
228
  expect(root_rest).to receive(:post).with("organizations/ramsay/association_requests", request_body).and_return(@user)
209
229
  expect(root_rest).to receive(:put).with("users/some_user/association_requests/1", { response: "accept" })
210
230
  knife.run
@@ -219,14 +239,20 @@ describe Chef::Knife::UserCreate do
219
239
  @user = double("Chef::User")
220
240
  expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_root]).and_return(root_rest)
221
241
  expect(root_rest).to receive(:post).and_return(@user)
222
- @key = "You don't come into cooking to get rich - Ramsay"
223
- allow(@user).to receive(:[]).with("private_key").and_return(@key)
242
+ @username = "Created #{name_args.first}"
243
+ @key = IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"))
244
+ allow(@user).to receive(:[]).with("chef_key").and_return("private_key" => @key)
224
245
  knife.name_args = name_args
225
246
  knife.config[:email] = "test@email.com"
226
247
  knife.config[:password] = "some_password"
227
248
  end
228
249
 
229
250
  it "creates an user" do
251
+ expect(knife.ui).to receive(:info).with(@username)
252
+ knife.run
253
+ end
254
+
255
+ it "creates an user private key" do
230
256
  expect(knife.ui).to receive(:msg).with(@key)
231
257
  knife.run
232
258
  end
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.10.0
4
+ version: 18.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-09 00:00:00.000000000 Z
11
+ date: 2023-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,62 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '17'
19
+ version: '18'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '17'
26
+ version: '18'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '17'
33
+ version: '18'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '17'
40
+ version: '18'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: chef
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '17'
47
+ version: '18'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '17'
54
+ version: '18'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: train-core
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.2'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 3.2.28
61
+ version: '3.10'
65
62
  type: :runtime
66
63
  prerelease: false
67
64
  version_requirements: !ruby/object:Gem::Requirement
68
65
  requirements:
69
66
  - - "~>"
70
67
  - !ruby/object:Gem::Version
71
- version: '3.2'
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 3.2.28
68
+ version: '3.10'
75
69
  - !ruby/object:Gem::Dependency
76
70
  name: train-winrm
77
71
  requirement: !ruby/object:Gem::Requirement
@@ -152,14 +146,14 @@ dependencies:
152
146
  requirements:
153
147
  - - "~>"
154
148
  - !ruby/object:Gem::Version
155
- version: '17.0'
149
+ version: '18.0'
156
150
  type: :runtime
157
151
  prerelease: false
158
152
  version_requirements: !ruby/object:Gem::Requirement
159
153
  requirements:
160
154
  - - "~>"
161
155
  - !ruby/object:Gem::Version
162
- version: '17.0'
156
+ version: '18.0'
163
157
  - !ruby/object:Gem::Dependency
164
158
  name: ffi
165
159
  requirement: !ruby/object:Gem::Requirement
@@ -197,7 +191,7 @@ dependencies:
197
191
  version: '5.1'
198
192
  - - "<"
199
193
  - !ruby/object:Gem::Version
200
- version: '7'
194
+ version: '8'
201
195
  type: :runtime
202
196
  prerelease: false
203
197
  version_requirements: !ruby/object:Gem::Requirement
@@ -207,7 +201,7 @@ dependencies:
207
201
  version: '5.1'
208
202
  - - "<"
209
203
  - !ruby/object:Gem::Version
210
- version: '7'
204
+ version: '8'
211
205
  - !ruby/object:Gem::Dependency
212
206
  name: net-ssh-multi
213
207
  requirement: !ruby/object:Gem::Requirement
@@ -1129,14 +1123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
1129
1123
  requirements:
1130
1124
  - - ">="
1131
1125
  - !ruby/object:Gem::Version
1132
- version: 2.7.0
1126
+ version: 3.1.0
1133
1127
  required_rubygems_version: !ruby/object:Gem::Requirement
1134
1128
  requirements:
1135
1129
  - - ">="
1136
1130
  - !ruby/object:Gem::Version
1137
1131
  version: '0'
1138
1132
  requirements: []
1139
- rubygems_version: 3.2.22
1133
+ rubygems_version: 3.3.26
1140
1134
  signing_key:
1141
1135
  specification_version: 4
1142
1136
  summary: The knife CLI for Chef Infra.