added skip vetify of server cert

This commit is contained in:
2026-02-21 14:07:19 +02:00
parent 7be3cf8de7
commit b2c60c41c4
15 changed files with 113 additions and 94 deletions
+13 -11
View File
@@ -33,6 +33,7 @@ func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
subCmd.PersistentFlags().StringVarP(&util.commonGrantParams.Username, "user", "u", "", "Username")
subCmd.PersistentFlags().StringVarP(&util.commonGrantParams.Password, "pass", "p", "", "Password")
subCmd.PersistentFlags().Uint64VarP(&util.commonGrantParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
subCmd.PersistentFlags().BoolVarP(&util.commonGrantParams.SkipTLSVerify, "skipVerify", "S", true, "Skip server certificate verify")
vi := viper.New()
vi.SetEnvPrefix("mstore")
@@ -102,10 +103,11 @@ type GrantUtil struct {
}
type CommonGrantParams struct {
Username string
Password string
Hostname string
Timeout uint64
Username string
Password string
Hostname string
Timeout uint64
SkipTLSVerify bool
}
// CreateGrant
@@ -140,9 +142,9 @@ func (util *GrantUtil) createGrant(common *CommonGrantParams, params *CreateGran
id := strings.ToLower(params.AccountID)
var operRes string
if re.MatchString(id) {
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, id, params.Right, params.Pattern)
operRes, err = client.NewClient(common.SkipTLSVerify).CreateGrantByAccountID(ctx, hostname, id, params.Right, params.Pattern)
} else {
operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, params.Right, params.Pattern)
operRes, err = client.NewClient(common.SkipTLSVerify).CreateGrantByUsername(ctx, hostname, params.AccountID, params.Right, params.Pattern)
}
if err != nil {
return res, err
@@ -176,7 +178,7 @@ func (util *GrantUtil) updateGrant(common *CommonGrantParams, params *UpdateGran
timeout := time.Duration(common.Timeout) * time.Second
ctx, _ := context.WithTimeout(context.Background(), timeout)
id := strings.ToLower(params.GrantID)
err = client.NewClient().UpdateGrant(ctx, hostname, id, params.Pattern)
err = client.NewClient(common.SkipTLSVerify).UpdateGrant(ctx, hostname, id, params.Pattern)
if err != nil {
return res, err
}
@@ -212,7 +214,7 @@ func (util *GrantUtil) getGrant(common *CommonGrantParams, params *GetGrantParam
opRes := &descr.Grant{}
id := strings.ToLower(params.GrantID)
opRes, err = client.NewClient().GetGrant(ctx, hostname, id)
opRes, err = client.NewClient(common.SkipTLSVerify).GetGrant(ctx, hostname, id)
if err != nil {
return res, err
}
@@ -243,7 +245,7 @@ func (util *GrantUtil) deleteGrant(common *CommonGrantParams, params *DeleteGran
timeout := time.Duration(common.Timeout) * time.Second
ctx, _ := context.WithTimeout(context.Background(), timeout)
id := strings.ToLower(params.GrantID)
err = client.NewClient().DeleteGrant(ctx, hostname, id)
err = client.NewClient(common.SkipTLSVerify).DeleteGrant(ctx, hostname, id)
if err != nil {
return res, err
}
@@ -280,9 +282,9 @@ func (util *GrantUtil) listGrants(common *CommonGrantParams, params *ListGrantsP
re := regexp.MustCompile(uuidRegex)
id := strings.ToLower(params.AccountID)
if re.MatchString(id) {
grants, err = client.NewClient().ListGrantsByAccountID(ctx, hostname, id)
grants, err = client.NewClient(common.SkipTLSVerify).ListGrantsByAccountID(ctx, hostname, id)
} else {
grants, err = client.NewClient().ListGrantsByUsername(ctx, hostname, params.AccountID)
grants, err = client.NewClient(common.SkipTLSVerify).ListGrantsByUsername(ctx, hostname, params.AccountID)
}
if err != nil {
return res, err