mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Service accounts: RBAC the service account UI (#47788)
* WIP * fix: bug for saving name did not remove edit * refactor: better error msg * Display the column Roles even when user can't see the role picker * Remove spaces when building the search query request * Disable Edit button and fix token addition and deletion * Fix the error message text Co-authored-by: Vardan Torosyan <vardants@gmail.com>
This commit is contained in:
@@ -93,7 +93,7 @@ func (api *ServiceAccountsAPI) CreateServiceAccount(c *models.ReqContext) respon
|
||||
serviceAccount, err := api.store.CreateServiceAccount(c.Req.Context(), c.OrgId, cmd.Name)
|
||||
switch {
|
||||
case errors.Is(err, &database.ErrSAInvalidName{}):
|
||||
return response.Error(http.StatusBadRequest, "Invalid service account name", err)
|
||||
return response.Error(http.StatusBadRequest, "Failed due to %s", err)
|
||||
case err != nil:
|
||||
return response.Error(http.StatusInternalServerError, "Failed to create service account", err)
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@ func (e *ErrSAInvalidName) Unwrap() error {
|
||||
return models.ErrUserAlreadyExists
|
||||
}
|
||||
|
||||
type ErrMisingSAToken struct {
|
||||
type ErrMissingSAToken struct {
|
||||
}
|
||||
|
||||
func (e *ErrMisingSAToken) Error() string {
|
||||
func (e *ErrMissingSAToken) Error() string {
|
||||
return "service account token not found"
|
||||
}
|
||||
|
||||
func (e *ErrMisingSAToken) Unwrap() error {
|
||||
func (e *ErrMissingSAToken) Unwrap() error {
|
||||
return models.ErrApiKeyNotFound
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ type ErrDuplicateSAToken struct {
|
||||
}
|
||||
|
||||
func (e *ErrDuplicateSAToken) Error() string {
|
||||
return fmt.Sprintf("service account token %s already exists", e.name)
|
||||
return fmt.Sprintf("service account token %s already exists in the organization", e.name)
|
||||
}
|
||||
|
||||
func (e *ErrDuplicateSAToken) Unwrap() error {
|
||||
|
||||
@@ -57,7 +57,7 @@ func (s *ServiceAccountsStoreImpl) DeleteServiceAccountToken(ctx context.Context
|
||||
if err != nil {
|
||||
return err
|
||||
} else if n == 0 {
|
||||
return &ErrMisingSAToken{}
|
||||
return &ErrMissingSAToken{}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user