certificates/authority/mgmt/admin.go

28 lines
749 B
Go
Raw Normal View History

2021-05-06 06:02:42 +00:00
package mgmt
import "context"
// Admin type.
type Admin struct {
2021-05-11 22:25:37 +00:00
ID string `json:"id"`
AuthorityID string `json:"-"`
ProvisionerID string `json:"provisionerID"`
Name string `json:"name"`
IsSuperAdmin bool `json:"isSuperAdmin"`
Status StatusType `json:"status"`
2021-05-06 06:02:42 +00:00
}
// CreateAdmin builds and stores an admin type in the DB.
2021-05-11 22:25:37 +00:00
func CreateAdmin(ctx context.Context, db DB, name string, provID string, isSuperAdmin bool) (*Admin, error) {
2021-05-06 06:02:42 +00:00
adm := &Admin{
2021-05-11 22:25:37 +00:00
Name: name,
ProvisionerID: provID,
IsSuperAdmin: isSuperAdmin,
Status: StatusActive,
2021-05-06 06:02:42 +00:00
}
if err := db.CreateAdmin(ctx, adm); err != nil {
return nil, WrapErrorISE(err, "error creating admin")
}
return adm, nil
}