-
Notifications
You must be signed in to change notification settings - Fork 1
/
user_def.cue
50 lines (43 loc) · 942 Bytes
/
user_def.cue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package kube
import "text/template"
_#user: {
name: string
uidnumber: int
primarygroup: int
passbcrypt: string
search: bool | *false
mail: string | *null
}
_users: [Name=_]: _#user & {
name: Name
}
let usersList = [ for x in _users {x}]
let users = [
for i, x in usersList {
x & {
passbcrypt: _secrets.bcryptPasswords[x.name]
// If uidnumber is not provided, set one starting with 3000
if x.uidnumber == _|_ {
uidnumber: i + 3000
}
}
},
]
let userTemplate = """
{{- range $u := . }}
[[users]]
name = "{{$u.name}}"
uidnumber = {{$u.uidnumber}}
primarygroup = {{$u.primarygroup}}
{{- if $u.mail}}
mail = "{{$u.mail}}"
{{- end }}
passbcrypt = "{{$u.passbcrypt}}"
{{- if $u.search}}
[[users.capabilities]]
action = "search"
object = "*"
{{end -}}
{{ end }}
"""
_userConfig: template.Execute(userTemplate, users)