mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-17 20:25:50 +02:00
Introduce service accounts and bootstrap tokens (#22)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package v1
|
||||
|
||||
type ServiceAccount struct {
|
||||
Token string
|
||||
Roles []ServiceAccountRole
|
||||
|
||||
Meta
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var ErrUnsupportedServiceAccountRole = errors.New("unsupported service account role")
|
||||
|
||||
type ServiceAccountRole string
|
||||
|
||||
const (
|
||||
ServiceAccountRoleWorker ServiceAccountRole = "worker"
|
||||
ServiceAccountRoleComputeRead ServiceAccountRole = "compute:read"
|
||||
ServiceAccountRoleComputeWrite ServiceAccountRole = "compute:write"
|
||||
ServiceAccountRoleAdminRead ServiceAccountRole = "admin:read"
|
||||
ServiceAccountRoleAdminWrite ServiceAccountRole = "admin:write"
|
||||
)
|
||||
|
||||
func NewServiceAccountRole(name string) (ServiceAccountRole, error) {
|
||||
switch name {
|
||||
case string(ServiceAccountRoleWorker):
|
||||
return ServiceAccountRoleWorker, nil
|
||||
case string(ServiceAccountRoleComputeRead):
|
||||
return ServiceAccountRoleComputeRead, nil
|
||||
case string(ServiceAccountRoleComputeWrite):
|
||||
return ServiceAccountRoleComputeWrite, nil
|
||||
case string(ServiceAccountRoleAdminRead):
|
||||
return ServiceAccountRoleAdminRead, nil
|
||||
case string(ServiceAccountRoleAdminWrite):
|
||||
return ServiceAccountRoleAdminWrite, nil
|
||||
default:
|
||||
return "", fmt.Errorf("%w: %s", ErrUnsupportedServiceAccountRole, name)
|
||||
}
|
||||
}
|
||||
|
||||
func AllServiceAccountRoles() []ServiceAccountRole {
|
||||
return []ServiceAccountRole{
|
||||
ServiceAccountRoleWorker,
|
||||
ServiceAccountRoleComputeRead,
|
||||
ServiceAccountRoleComputeWrite,
|
||||
ServiceAccountRoleAdminRead,
|
||||
ServiceAccountRoleAdminWrite,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user