Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion generate/go_servicepermissions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
package permissions

import (
"sync"

apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
"connectrpc.com/connect"
)
Expand All @@ -15,6 +17,12 @@ func GetServices() []string {
}

func GetServicePermissions() *ServicePermissions {
return getServicePermissions()
}

// servicePermissions are static and only need to be built once. The returned
// value is shared and must be treated as read-only.
var getServicePermissions = sync.OnceValue(func() *ServicePermissions {
return &ServicePermissions{
Roles: Roles{
Admin: Admin{
Expand Down Expand Up @@ -111,7 +119,7 @@ func GetServicePermissions() *ServicePermissions {
{{- end }}
},
}
}
})

func IsPublicScope(req connect.AnyRequest) bool {
_, ok := GetServicePermissions().Visibility.Public[req.Spec().Procedure]
Expand Down
10 changes: 9 additions & 1 deletion go/permissions/servicepermissions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading