mirror of
https://github.com/grafana/grafana.git
synced 2025-09-26 13:14:32 +08:00

* ServiceAccounts: modernize SA creation interface * ServiceAccounts: improve service account ID generation * ServiceAccounts: remove unused method * ServiceAccounts: Make SA ID display name dependent * ServiceAccounts: Add tests for Service Account creation * trim trailing whitespace * Update pkg/services/serviceaccounts/api/api.go Co-authored-by: Ieva <ieva.vasiljeva@grafana.com> * Update pkg/services/serviceaccounts/api/api.go Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
53 lines
991 B
Go
53 lines
991 B
Go
package database
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
type ErrSAInvalidName struct {
|
|
}
|
|
|
|
func (e *ErrSAInvalidName) Error() string {
|
|
return "service account name already in use"
|
|
}
|
|
|
|
func (e *ErrSAInvalidName) Unwrap() error {
|
|
return models.ErrUserAlreadyExists
|
|
}
|
|
|
|
type ErrMisingSAToken struct {
|
|
}
|
|
|
|
func (e *ErrMisingSAToken) Error() string {
|
|
return "service account token not found"
|
|
}
|
|
|
|
func (e *ErrMisingSAToken) Unwrap() error {
|
|
return models.ErrApiKeyNotFound
|
|
}
|
|
|
|
type ErrInvalidExpirationSAToken struct {
|
|
}
|
|
|
|
func (e *ErrInvalidExpirationSAToken) Error() string {
|
|
return "service account token not found"
|
|
}
|
|
|
|
func (e *ErrInvalidExpirationSAToken) Unwrap() error {
|
|
return models.ErrInvalidApiKeyExpiration
|
|
}
|
|
|
|
type ErrDuplicateSAToken struct {
|
|
name string
|
|
}
|
|
|
|
func (e *ErrDuplicateSAToken) Error() string {
|
|
return fmt.Sprintf("service account token %s already exists", e.name)
|
|
}
|
|
|
|
func (e *ErrDuplicateSAToken) Unwrap() error {
|
|
return models.ErrDuplicateApiKey
|
|
}
|