Skip to content

Commit 8213b9a

Browse files
committed
Happy rubocop
1 parent c843ba0 commit 8213b9a

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

service/lib/agama/autoyast/root_reader.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ def read
4646
hsh["hashedPassword"] = true if password.value.encrypted?
4747
end
4848

49-
public_key = root_user.authorized_keys.first
50-
hsh["sshPublicKey"] = public_key if public_key
51-
hsh["sshPublicKeys"] = root_user.authorized_keys if !root_user.authorized_keys.empty?
49+
hsh.merge(setup_ssh(root))
5250

5351
return {} if hsh.empty?
5452

@@ -67,6 +65,17 @@ def config
6765
result = reader.read
6866
@config = result.config
6967
end
68+
69+
def setup_ssh(root_user)
70+
hsh = {}
71+
72+
public_key = root_user.authorized_keys.first
73+
74+
hsh["sshPublicKey"] = public_key if public_key
75+
hsh["sshPublicKeys"] = root_user.authorized_keys if !root_user.authorized_keys.empty?
76+
77+
hsh
78+
end
7079
end
7180
end
7281
end

service/lib/agama/autoyast/user_reader.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,15 @@ def read
3737
user = config.users.find { |u| !u.system? && !u.root? }
3838
return {} unless user
3939

40-
hsh = {
41-
"userName" => user.name,
42-
"fullName" => user.gecos.first.to_s
43-
}
40+
hsh = basic_user_info
4441

4542
password = user.password
4643
if password
4744
hsh["password"] = password.value.to_s
4845
hsh["hashedPassword"] = true if password.value.encrypted?
4946
end
5047

51-
hsh["sshPublicKeys"] user.authorized_keys if !user.authorized_keys.empty?
48+
hsh["sshPublicKeys"] = user.authorized_keys if !user.authorized_keys.empty?
5249

5350
{ "user" => hsh }
5451
end
@@ -65,6 +62,13 @@ def config
6562
result = reader.read
6663
@config = result.config
6764
end
65+
66+
def basic_user_info(user)
67+
{
68+
"userName" => user.name,
69+
"fullName" => user.gecos.first.to_s
70+
}
71+
end
6872
end
6973
end
7074
end

0 commit comments

Comments
 (0)