knife 18.8.13 → 18.8.68
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/lib/chef/knife/user_list.rb +15 -1
- data/lib/chef/knife/version.rb +1 -1
- data/lib/chef/knife/yaml_convert.rb +3 -1
- data/spec/unit/knife/user_list_spec.rb +34 -2
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13bca26f312d5e068e005be12728ee58921e90fc573fe757d27ea8c4b5b812f6
|
|
4
|
+
data.tar.gz: 0da54bfaa9b437f52dbbb203c570e6bbeda840ca5dd5d94d7d6947ead3a8a84f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53c7412d0e45a4bc29aac831cb3852e88c7440dae8784ef7056e8c0f92c59e864a18a569b1a6e1f7517295ada533e61059e19aee59721114a63d9c1d3471cff8
|
|
7
|
+
data.tar.gz: fc6a97ff8ef6205aa2f1c9693250a8373a29e3579f28bcfd90f627e09fafb101d20a8a4b03a9465168cc4ef0eb6fd87bdd45f4878703052f1de5a6a65ca828f3
|
data/lib/chef/knife/user_list.rb
CHANGED
|
@@ -34,8 +34,22 @@ class Chef
|
|
|
34
34
|
long: "--with-uri",
|
|
35
35
|
description: "Show corresponding URIs."
|
|
36
36
|
|
|
37
|
+
option :all_users,
|
|
38
|
+
short: "-a",
|
|
39
|
+
long: "--all-users",
|
|
40
|
+
description: "Show all user details."
|
|
37
41
|
def run
|
|
38
|
-
|
|
42
|
+
users = Chef::UserV1.list(config[:all_users])
|
|
43
|
+
if config[:all_users]
|
|
44
|
+
# When showing all user details, convert UserV1 objects to hashes for display
|
|
45
|
+
detailed_users = {}
|
|
46
|
+
users.each do |name, user|
|
|
47
|
+
detailed_users[name] = user.to_h
|
|
48
|
+
end
|
|
49
|
+
output(detailed_users)
|
|
50
|
+
else
|
|
51
|
+
output(format_list_for_display(users))
|
|
52
|
+
end
|
|
39
53
|
end
|
|
40
54
|
|
|
41
55
|
end
|
data/lib/chef/knife/version.rb
CHANGED
|
@@ -51,7 +51,9 @@ class Chef::Knife::YamlConvert < Chef::Knife
|
|
|
51
51
|
yaml_contents = File.read(yaml_file)
|
|
52
52
|
|
|
53
53
|
# YAML can contain multiple documents (--- is the separator), let's not support that.
|
|
54
|
-
|
|
54
|
+
# Count document separators instead of using unsafe load_stream
|
|
55
|
+
doc_count = yaml_contents.scan(/^---\s*$/).length
|
|
56
|
+
if doc_count > 1
|
|
55
57
|
ui.fatal!("YAML recipe '#{yaml_file}' contains multiple documents, only one is supported")
|
|
56
58
|
end
|
|
57
59
|
|
|
@@ -34,6 +34,8 @@ describe Chef::Knife::UserList do
|
|
|
34
34
|
@rest = double("Chef::ServerAPI")
|
|
35
35
|
allow(Chef::ServerAPI).to receive(:new).and_return(@rest)
|
|
36
36
|
allow(@rest).to receive(:get).with("users").and_return(users)
|
|
37
|
+
allow(Chef::UserV1).to receive(:list).with(nil).and_return(users)
|
|
38
|
+
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
describe "with no arguments" do
|
|
@@ -45,12 +47,42 @@ describe Chef::Knife::UserList do
|
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
describe "with all_users argument" do
|
|
50
|
+
let(:user1_object) do
|
|
51
|
+
u = Chef::UserV1.new
|
|
52
|
+
u.username "user1"
|
|
53
|
+
u.email "user1@example.com"
|
|
54
|
+
u.display_name "User One"
|
|
55
|
+
u
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
let(:user2_object) do
|
|
59
|
+
u = Chef::UserV1.new
|
|
60
|
+
u.username "user2"
|
|
61
|
+
u.email "user2@example.com"
|
|
62
|
+
u.display_name "User Two"
|
|
63
|
+
u
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
let(:inflated_users) do
|
|
67
|
+
{
|
|
68
|
+
"user1" => user1_object,
|
|
69
|
+
"user2" => user2_object,
|
|
70
|
+
}
|
|
71
|
+
end
|
|
48
72
|
before do
|
|
49
73
|
knife.config[:all_users] = true
|
|
74
|
+
allow(Chef::UserV1).to receive(:list).with(true).and_return(inflated_users)
|
|
75
|
+
|
|
50
76
|
end
|
|
51
77
|
|
|
52
|
-
it "lists all users
|
|
53
|
-
expect(knife.ui).to receive(:output)
|
|
78
|
+
it "lists all users with full details" do
|
|
79
|
+
expect(knife.ui).to receive(:output) do |arg|
|
|
80
|
+
expect(arg).to be_a(Hash)
|
|
81
|
+
expect(arg.keys).to contain_exactly("user1", "user2")
|
|
82
|
+
expect(arg["user1"]["username"]).to eq("user1")
|
|
83
|
+
expect(arg["user1"]["email"]).to eq("user1@example.com")
|
|
84
|
+
expect(arg["user2"]["username"]).to eq("user2")
|
|
85
|
+
end
|
|
54
86
|
knife.run
|
|
55
87
|
end
|
|
56
88
|
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: 18.8.
|
|
4
|
+
version: 18.8.68
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Jacob
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-12-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: chef-config
|
|
@@ -1177,7 +1177,7 @@ metadata:
|
|
|
1177
1177
|
homepage_uri: https://www.chef.io
|
|
1178
1178
|
mailing_list_uri: https://discourse.chef.io/
|
|
1179
1179
|
source_code_uri: https://github.com/chef/chef/
|
|
1180
|
-
post_install_message:
|
|
1180
|
+
post_install_message:
|
|
1181
1181
|
rdoc_options: []
|
|
1182
1182
|
require_paths:
|
|
1183
1183
|
- lib
|
|
@@ -1192,8 +1192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1192
1192
|
- !ruby/object:Gem::Version
|
|
1193
1193
|
version: '0'
|
|
1194
1194
|
requirements: []
|
|
1195
|
-
rubygems_version: 3.3.
|
|
1196
|
-
signing_key:
|
|
1195
|
+
rubygems_version: 3.3.27
|
|
1196
|
+
signing_key:
|
|
1197
1197
|
specification_version: 4
|
|
1198
1198
|
summary: The knife CLI for Chef Infra.
|
|
1199
1199
|
test_files: []
|