Skip to content

Commit

Permalink
Fix sql user error msg (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
FingerLeader authored Sep 20, 2024
1 parent c79e6db commit d8b7da5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/cli/serverless/sqluser/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ func CreateCmd(h *internal.Helper) *cobra.Command {
return errors.Trace(err)
}

if util.IsNilOrEmpty(builtinRole) {
return errors.New("built-in role must be set")
}

authMethod := util.MYSQLNATIVEPASSWORD
autoPrefix := DefaultAutoPrefix
params := &iam.ApiCreateSqlUserReq{
Expand Down
6 changes: 5 additions & 1 deletion internal/cli/serverless/sqluser/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ func UpdateCmd(h *internal.Helper) *cobra.Command {
if err != nil {
return errors.Trace(err)
}
if util.IsNilOrEmpty(u.BuiltinRole) {
return errors.New("built-in role must be set")
}
}

if len(addRole) != 0 {
Expand All @@ -244,8 +247,9 @@ func UpdateCmd(h *internal.Helper) *cobra.Command {
if deleteBuiltinRole == u.BuiltinRole {
// it doesn't work yet, because the API doesn't support to delete the builtin role
u.BuiltinRole = nil
return errors.New("can not delete built-in role")
} else {
return errors.New(fmt.Sprintf("role %s doesn't exist in the SQL user", *deleteBuiltinRole))
return errors.New("can not delete built-in role")
}
}
for _, role := range deleteCustomRoles {
Expand Down

0 comments on commit d8b7da5

Please sign in to comment.