certmanager update
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2022 Oleg Borodin <borodin@unix7.org>
|
||||
* Copyright 2024 Oleg Borodin <borodin@unix7.org>
|
||||
*/
|
||||
|
||||
package main
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"time"
|
||||
|
||||
"certmanager/pkg/client"
|
||||
cmapi "certmanager/pkg/cmctl"
|
||||
"certmanager/pkg/cmctl"
|
||||
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
@@ -34,16 +34,20 @@ const (
|
||||
unrevokeIssuerPairCmd = "unrevokeIssuerPair"
|
||||
listIssuerPairsCmd = "listIssuerPairs"
|
||||
getIssuerCertificateCmd = "getIssuerCertificate"
|
||||
createServicePairCmd = "createServicePair"
|
||||
revokeServicePairCmd = "revokeServicePair"
|
||||
unrevokeServicePairCmd = "unrevokeServicePair"
|
||||
listServicePairsCmd = "listServicePairs"
|
||||
getServicePairCmd = "getServicePair"
|
||||
|
||||
createServicePairCmd = "createServicePair"
|
||||
revokeServicePairCmd = "revokeServicePair"
|
||||
unrevokeServicePairCmd = "unrevokeServicePair"
|
||||
listServicePairsCmd = "listServicePairs"
|
||||
getServicePairCmd = "getServicePair"
|
||||
|
||||
createAccountCmd = "createAccount"
|
||||
updateAccountCmd = "updateAccount"
|
||||
deleteAccountCmd = "revokeAccount"
|
||||
deleteAccountCmd = "deleteAccount"
|
||||
listAccountsCmd = "listAccounts"
|
||||
|
||||
setGrantCmd = "setGrant"
|
||||
deleteGrantCmd = "deleteGrant"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -60,7 +64,7 @@ type Util struct {
|
||||
subCmd string
|
||||
cmdTimeout int64
|
||||
access client.Access
|
||||
cont *cmapi.ControlClient
|
||||
cont *cmctl.ControlClient
|
||||
|
||||
caFilenamesList string
|
||||
certFilename string
|
||||
@@ -82,6 +86,7 @@ type Util struct {
|
||||
disable bool
|
||||
newUsername string
|
||||
newPassword string
|
||||
operation string
|
||||
}
|
||||
|
||||
func NewUtil() *Util {
|
||||
@@ -126,23 +131,27 @@ func (util *Util) GetOpt() error {
|
||||
fmt.Printf("Usage: %s [option] command [command option]\n", exeName)
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Command list: help, %s\n", getStatusCmd)
|
||||
fmt.Printf("Command list: %s, %s, %s, %s, %s, %s\n",
|
||||
fmt.Printf("Command list: %s, %s, %s, %s, %s, %s,\n",
|
||||
createIssuerPairCmd,
|
||||
importIssuerPairCmd,
|
||||
revokeIssuerPairCmd,
|
||||
unrevokeIssuerPairCmd,
|
||||
listIssuerPairsCmd,
|
||||
getIssuerCertificateCmd)
|
||||
fmt.Printf("Command list: %s, %s, %s, %s\n",
|
||||
fmt.Printf(" %s, %s, %s, %s,\n",
|
||||
createServicePairCmd,
|
||||
revokeServicePairCmd,
|
||||
listServicePairsCmd,
|
||||
getServicePairCmd)
|
||||
fmt.Printf("Command list: %s, %s, %s, %s\n",
|
||||
fmt.Printf(" %s, %s, %s, %s,\n",
|
||||
createAccountCmd,
|
||||
deleteAccountCmd,
|
||||
listAccountsCmd,
|
||||
updateAccountCmd)
|
||||
fmt.Printf(" %s, %s\n",
|
||||
setGrantCmd,
|
||||
deleteGrantCmd)
|
||||
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Global options:\n")
|
||||
flag.PrintDefaults()
|
||||
@@ -415,8 +424,8 @@ func (util *Util) GetOpt() error {
|
||||
flagSet.StringVar(&util.username, "username", util.username, "user name")
|
||||
flagSet.Int64Var(&util.accountID, "accountId", util.accountID, "account ID")
|
||||
|
||||
flagSet.StringVar(&util.newUsername, "username", util.newUsername, "new user name")
|
||||
flagSet.StringVar(&util.newPassword, "password", util.newPassword, "new user password")
|
||||
flagSet.StringVar(&util.newUsername, "newUsername", util.newUsername, "new user name")
|
||||
flagSet.StringVar(&util.newPassword, "newPassword", util.newPassword, "new user password")
|
||||
flagSet.BoolVar(&util.disable, "disable", util.disable, "disable account")
|
||||
|
||||
flagSet.Usage = func() {
|
||||
@@ -430,6 +439,42 @@ func (util *Util) GetOpt() error {
|
||||
flagSet.Parse(subArgs)
|
||||
util.subCmd = subCmd
|
||||
|
||||
case setGrantCmd:
|
||||
flagSet := flag.NewFlagSet(setGrantCmd, flag.ExitOnError)
|
||||
|
||||
flagSet.StringVar(&util.username, "username", util.username, "user name")
|
||||
flagSet.Int64Var(&util.accountID, "accountId", util.accountID, "account ID")
|
||||
flagSet.StringVar(&util.operation, "operation", util.operation, "grant type")
|
||||
|
||||
flagSet.Usage = func() {
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Usage: %s [global options] %s [command options]\n", exeName, subCmd)
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("The command options: none\n")
|
||||
flagSet.PrintDefaults()
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
flagSet.Parse(subArgs)
|
||||
util.subCmd = subCmd
|
||||
|
||||
case deleteGrantCmd:
|
||||
flagSet := flag.NewFlagSet(deleteGrantCmd, flag.ExitOnError)
|
||||
|
||||
flagSet.StringVar(&util.username, "username", util.username, "user name")
|
||||
flagSet.Int64Var(&util.accountID, "accountId", util.accountID, "account ID")
|
||||
flagSet.StringVar(&util.operation, "operation", util.operation, "grant type")
|
||||
|
||||
flagSet.Usage = func() {
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Usage: %s [global options] %s [command options]\n", exeName, subCmd)
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("The command options: none\n")
|
||||
flagSet.PrintDefaults()
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
flagSet.Parse(subArgs)
|
||||
util.subCmd = subCmd
|
||||
|
||||
default:
|
||||
help()
|
||||
return errors.New("Unknown command")
|
||||
@@ -470,6 +515,7 @@ func (util *Util) Exec() error {
|
||||
res, err = util.ListIssuerPairs(ctx)
|
||||
case getIssuerCertificateCmd:
|
||||
res, err = util.GetIssuerCertificate(ctx)
|
||||
|
||||
case createServicePairCmd:
|
||||
res, err = util.CreateServicePair(ctx)
|
||||
case revokeServicePairCmd:
|
||||
@@ -490,6 +536,11 @@ func (util *Util) Exec() error {
|
||||
case deleteAccountCmd:
|
||||
res, err = util.DeleteAccount(ctx)
|
||||
|
||||
case setGrantCmd:
|
||||
res, err = util.SetGrant(ctx)
|
||||
case deleteGrantCmd:
|
||||
res, err = util.DeleteGrant(ctx)
|
||||
|
||||
default:
|
||||
err = errors.New("Unknown cli command")
|
||||
}
|
||||
@@ -507,14 +558,14 @@ func (util *Util) Exec() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (util *Util) GetStatus(ctx context.Context) (*cmapi.GetStatusResult, error) {
|
||||
func (util *Util) GetStatus(ctx context.Context) (*cmctl.GetStatusResult, error) {
|
||||
var err error
|
||||
res := &cmapi.GetStatusResult{}
|
||||
res := &cmctl.GetStatusResult{}
|
||||
cont, err := client.NewClient(&util.access)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
params := &cmapi.GetStatusParams{}
|
||||
params := &cmctl.GetStatusParams{}
|
||||
res, err = cont.GetStatus(ctx, params)
|
||||
if err != nil {
|
||||
return res, err
|
||||
|
||||
Reference in New Issue
Block a user