From 6b493a4015b22d08678dcb704256378f32cae1c0 Mon Sep 17 00:00:00 2001 From: FingerLeader Date: Thu, 19 Sep 2024 22:23:30 +0800 Subject: [PATCH 1/5] change delete built-in role error msg Signed-off-by: FingerLeader --- internal/cli/serverless/sqluser/update.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/serverless/sqluser/update.go b/internal/cli/serverless/sqluser/update.go index a33aa37c..4f7fe272 100644 --- a/internal/cli/serverless/sqluser/update.go +++ b/internal/cli/serverless/sqluser/update.go @@ -245,7 +245,7 @@ func UpdateCmd(h *internal.Helper) *cobra.Command { // it doesn't work yet, because the API doesn't support to delete the builtin role u.BuiltinRole = nil } else { - return errors.New(fmt.Sprintf("role %s doesn't exist in the SQL user", *deleteBuiltinRole)) + return errors.New("can not delte built-in role") } } for _, role := range deleteCustomRoles { From 16ef11e27645e7ba2939621c0dd12888dba2d07c Mon Sep 17 00:00:00 2001 From: FingerLeader Date: Thu, 19 Sep 2024 22:39:35 +0800 Subject: [PATCH 2/5] change built-in role error msg Signed-off-by: FingerLeader --- internal/cli/serverless/sqluser/update.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/cli/serverless/sqluser/update.go b/internal/cli/serverless/sqluser/update.go index 4f7fe272..7acc594f 100644 --- a/internal/cli/serverless/sqluser/update.go +++ b/internal/cli/serverless/sqluser/update.go @@ -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 { From e3fbb31ea1a03f9896679e5814ba9bf24f6e8f1c Mon Sep 17 00:00:00 2001 From: FingerLeader Date: Thu, 19 Sep 2024 22:42:27 +0800 Subject: [PATCH 3/5] change built-in role error msg Signed-off-by: FingerLeader --- internal/cli/serverless/sqluser/create.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/cli/serverless/sqluser/create.go b/internal/cli/serverless/sqluser/create.go index 561afd01..c6009d11 100644 --- a/internal/cli/serverless/sqluser/create.go +++ b/internal/cli/serverless/sqluser/create.go @@ -200,6 +200,10 @@ func CreateCmd(h *internal.Helper) *cobra.Command { return errors.Trace(err) } + if util.IsNilOrEmpty(builtinRole) { + return errors.New("at least one built-in role must be set") + } + authMethod := util.MYSQLNATIVEPASSWORD autoPrefix := DefaultAutoPrefix params := &iam.ApiCreateSqlUserReq{ From 0c083927d777bf0365e460fce7dd88491bb8cec7 Mon Sep 17 00:00:00 2001 From: FingerLeader Date: Fri, 20 Sep 2024 00:07:29 +0800 Subject: [PATCH 4/5] change built-in role error msg & fix typo Signed-off-by: FingerLeader --- internal/cli/serverless/sqluser/update.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/cli/serverless/sqluser/update.go b/internal/cli/serverless/sqluser/update.go index 7acc594f..ef60f07e 100644 --- a/internal/cli/serverless/sqluser/update.go +++ b/internal/cli/serverless/sqluser/update.go @@ -247,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("can not delte built-in role") + return errors.New("can not delete built-in role") } } for _, role := range deleteCustomRoles { From 2cce4a244ebeceb9595d446859ab8dcf74b12b13 Mon Sep 17 00:00:00 2001 From: FingerLeader Date: Fri, 20 Sep 2024 11:25:07 +0800 Subject: [PATCH 5/5] fix Signed-off-by: FingerLeader --- internal/cli/serverless/sqluser/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/serverless/sqluser/create.go b/internal/cli/serverless/sqluser/create.go index c6009d11..ffe2ff36 100644 --- a/internal/cli/serverless/sqluser/create.go +++ b/internal/cli/serverless/sqluser/create.go @@ -201,7 +201,7 @@ func CreateCmd(h *internal.Helper) *cobra.Command { } if util.IsNilOrEmpty(builtinRole) { - return errors.New("at least one built-in role must be set") + return errors.New("built-in role must be set") } authMethod := util.MYSQLNATIVEPASSWORD