Skip to content

Commit 4cdbf93

Browse files
committed
Boot Services
1 parent 826603a commit 4cdbf93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+4328
-113
lines changed

doc/index.html

Lines changed: 1113 additions & 0 deletions
Large diffs are not rendered by default.

generate/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ go-mocks:
1717
--user $$(id -u):$$(id -g) \
1818
-w /work \
1919
-v $(PWD):/work \
20-
vektra/mockery:v2.53.0 --keeptree --inpackage --dir go --output go/tests/mocks --all --log-level debug
20+
vektra/mockery:v2.53.4 --keeptree --inpackage --dir go --output go/tests/mocks --all --log-level debug

generate/generate.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func servicePermissions(root string) (*permissions.ServicePermissions, error) {
9090
roles = permissions.Roles{
9191
Admin: permissions.Admin{},
9292
Infra: permissions.Infra{},
93+
Machine: permissions.Machine{},
9394
Tenant: permissions.Tenant{},
9495
Project: permissions.Project{},
9596
}
@@ -103,6 +104,7 @@ func servicePermissions(root string) (*permissions.ServicePermissions, error) {
103104
Self: map[string]bool{},
104105
Admin: map[string]bool{},
105106
Infra: map[string]bool{},
107+
Machine: map[string]bool{},
106108
Tenant: map[string]bool{},
107109
Project: map[string]bool{},
108110
}
@@ -182,6 +184,15 @@ func servicePermissions(root string) (*permissions.ServicePermissions, error) {
182184
visibility.Infra[methodName] = true
183185
case v1.InfraRole_INFRA_ROLE_UNSPECIFIED.String():
184186
// noop
187+
// Machine
188+
case v1.MachineRole_MACHINE_ROLE_EDITOR.String():
189+
roles.Infra[v1.MachineRole_MACHINE_ROLE_EDITOR.String()] = append(roles.Admin[v1.MachineRole_MACHINE_ROLE_EDITOR.String()], methodName)
190+
visibility.Machine[methodName] = true
191+
case v1.MachineRole_MACHINE_ROLE_VIEWER.String():
192+
roles.Infra[v1.MachineRole_MACHINE_ROLE_VIEWER.String()] = append(roles.Admin[v1.MachineRole_MACHINE_ROLE_VIEWER.String()], methodName)
193+
visibility.Machine[methodName] = true
194+
case v1.MachineRole_MACHINE_ROLE_UNSPECIFIED.String():
195+
// noop
185196
// Visibility
186197
case v1.Visibility_VISIBILITY_PUBLIC.String():
187198
visibility.Public[methodName] = true

generate/go_servicepermissions.tpl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ func GetServicePermissions() *ServicePermissions {
3434
},
3535
{{- end }}
3636
},
37+
Machine: Machine{
38+
{{- range $role, $methods := .Roles.Infra }}
39+
"{{ $role }}": []string{
40+
{{- range $method := $methods }}
41+
"{{ $method }}",
42+
{{- end }}
43+
},
44+
{{- end }}
45+
},
3746
Tenant: Tenant{
3847
{{- range $role, $methods := .Roles.Tenant }}
3948
"{{ $role }}": []string{
@@ -77,6 +86,11 @@ func GetServicePermissions() *ServicePermissions {
7786
Infra: map[string]bool{
7887
{{- range $key, $value := .Visibility.Infra }}
7988
"{{ $key }}": {{ $value }} ,
89+
{{- end }}
90+
},
91+
Machine: map[string]bool{
92+
{{- range $key, $value := .Visibility.Machine }}
93+
"{{ $key }}": {{ $value }} ,
8094
{{- end }}
8195
},
8296
Tenant: map[string]bool{
@@ -118,6 +132,11 @@ func IsInfraScope(req connect.AnyRequest) bool {
118132
return ok
119133
}
120134

135+
func IsMachineScope(req connect.AnyRequest) bool {
136+
_, ok := GetServicePermissions().Visibility.Machine[req.Spec().Procedure]
137+
return ok
138+
}
139+
121140
func IsTenantScope(req connect.AnyRequest) bool {
122141
_, ok := GetServicePermissions().Visibility.Tenant[req.Spec().Procedure]
123142
return ok
@@ -153,4 +172,15 @@ func GetProjectFromRequest(req connect.AnyRequest) (string, bool) {
153172
return rq.GetProject(), true
154173
}
155174
return "", false
175+
}
176+
177+
func GetMachineIdFromRequest(req connect.AnyRequest) (string, bool) {
178+
if !IsMachineScope(req) {
179+
return "", false
180+
}
181+
switch rq := req.Any().(type) {
182+
case interface{ GetUuid() string }:
183+
return rq.GetUuid(), true
184+
}
185+
return "", false
156186
}

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/metal-stack/api
33
go 1.24.0
44

55
require (
6-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1
6+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250603165357-b52ab10f4468.1
77
buf.build/go/protovalidate v0.12.0
88
connectrpc.com/connect v1.18.1
99
github.com/bufbuild/protocompile v0.14.1
@@ -24,10 +24,10 @@ require (
2424
github.com/pmezard/go-difflib v1.0.0 // indirect
2525
github.com/stoewer/go-strcase v1.3.0 // indirect
2626
github.com/stretchr/objx v0.5.2 // indirect
27-
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
28-
golang.org/x/text v0.25.0 // indirect
29-
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 // indirect
30-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 // indirect
27+
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect
28+
golang.org/x/text v0.26.0 // indirect
29+
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
30+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
3131
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
3232
gopkg.in/yaml.v3 v3.0.1 // indirect
3333
)

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 h1:YhMSc48s25kr7kv31Z8vf7sPUIq5YJva9z1mn/hAt0M=
2-
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U=
1+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250603165357-b52ab10f4468.1 h1:uwSqFkn8DDTzNlaV9TxgSXY5OCaNdb4rH+Axd2FujkE=
2+
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250603165357-b52ab10f4468.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U=
33
buf.build/go/protovalidate v0.12.0 h1:4GKJotbspQjRCcqZMGVSuC8SjwZ/FmgtSuKDpKUTZew=
44
buf.build/go/protovalidate v0.12.0/go.mod h1:q3PFfbzI05LeqxSwq+begW2syjy2Z6hLxZSkP1OH/D0=
55
cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=
@@ -48,16 +48,16 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
4848
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
4949
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
5050
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
51-
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
52-
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
51+
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 h1:bsqhLWFR6G6xiQcb+JoGqdKdRU6WzPWmK8E0jxTjzo4=
52+
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
5353
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
5454
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
55-
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
56-
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
57-
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 h1:vPV0tzlsK6EzEDHNNH5sa7Hs9bd7iXR7B1tSiPepkV0=
58-
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:pKLAc5OolXC3ViWGI62vvC0n10CpwAtRcTNCFwTKBEw=
59-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 h1:IqsN8hx+lWLqlN+Sc3DoMy/watjofWiU8sRFgQ8fhKM=
60-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
55+
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
56+
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
57+
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 h1:oWVWY3NzT7KJppx2UKhKmzPq4SRe0LdCijVRwvGeikY=
58+
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822/go.mod h1:h3c4v36UTKzUiuaOKQ6gr3S+0hovBtUrXzTG/i3+XEc=
59+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 h1:fc6jSaCT0vBduLYZHYrBBNY4dsWuvgyff9noRNDdBeE=
60+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
6161
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
6262
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
6363
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

go/client/client.go

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)