* wip * IAM: Create Service Account * Add dual writer * Update openapi_test.go * Add integration tests * Add sql tests * Add Role to SA spec, add validation, add DBTime, add tests * Format, update test * Fixes * Add check for External * Address feedback * Update tests * Address feedback * make gen-go * Simplify a bit * Fixes * make update-workspace * Update pkg/registry/apis/iam/serviceaccount/store.go Co-authored-by: Ryan McKinley <ryantxu@gmail.com> * Address feedback, add test for generateName --------- Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
17 lines
388 B
Go
17 lines
388 B
Go
package serviceaccount
|
|
|
|
import (
|
|
"context"
|
|
|
|
iamv0alpha1 "github.com/grafana/grafana/apps/iam/pkg/apis/iam/v0alpha1"
|
|
)
|
|
|
|
func MutateOnCreate(ctx context.Context, obj *iamv0alpha1.ServiceAccount) error {
|
|
// External service accounts have None org role by default
|
|
if obj.Spec.Plugin != "" && obj.Spec.Role == "" {
|
|
obj.Spec.Role = iamv0alpha1.ServiceAccountOrgRoleNone
|
|
}
|
|
|
|
return nil
|
|
}
|