Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sql user error msg #240

Merged
merged 6 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading