working changes
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
lbapi "certmanager/api/certmanagercontrol"
|
||||
cmapi "certmanager/api/certmanagercontrol"
|
||||
"certmanager/pkg/client"
|
||||
|
||||
"sigs.k8s.io/yaml"
|
||||
@@ -27,6 +27,17 @@ const (
|
||||
|
||||
getStatusCmd = "getStatus"
|
||||
helpCmd = "help"
|
||||
|
||||
createIssuerPairCmd = "createIssuerPair"
|
||||
importIssuerPairCmd = "importIssuerPair"
|
||||
revokeIssuerPairCmd = "revokeIssuerPair"
|
||||
unrevokeIssuerPairCmd = "unrevokeIssuerPair"
|
||||
listIssuerPairsCmd = "listIssuerPairs"
|
||||
getIssuerCertificateCmd = "getIssuerCertificate"
|
||||
createServicePairCmd = "createServicePair"
|
||||
revokeServicePairCmd = "revokeServicePair"
|
||||
listServicePairsCmd = "listServicePairs"
|
||||
getServicePairCmd = "getServicePair"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -40,12 +51,22 @@ func main() {
|
||||
}
|
||||
|
||||
type Util struct {
|
||||
subCmd string
|
||||
cmdTimeout int64
|
||||
access client.Access
|
||||
cont *lbapi.ControlClient
|
||||
subCmd string
|
||||
cmdTimeout int64
|
||||
access client.Access
|
||||
cont *cmapi.ControlClient
|
||||
|
||||
getStatusParams lbapi.GetStatusParams
|
||||
getStatusParams cmapi.GetStatusParams
|
||||
createIssuerPairParams cmapi.CreateIssuerPairParams
|
||||
importIssuerPairParams cmapi.ImportIssuerPairParams
|
||||
revokeIssuerPairParams cmapi.RevokeIssuerPairParams
|
||||
unrevokeIssuerPairParams cmapi.UnrevokeIssuerPairParams
|
||||
listIssuerPairsParams cmapi.ListIssuerPairsParams
|
||||
getIssuerCertificateParams cmapi.GetIssuerCertificateParams
|
||||
createServicePairParams cmapi.CreateServicePairParams
|
||||
revokeServicePairParams cmapi.RevokeServicePairParams
|
||||
listServicePairsParams cmapi.ListServicePairsParams
|
||||
getServicePairParams cmapi.GetServicePairParams
|
||||
}
|
||||
|
||||
func NewUtil() *Util {
|
||||
@@ -89,7 +110,18 @@ func (util *Util) GetOpt() error {
|
||||
fmt.Println("")
|
||||
fmt.Printf("Usage: %s [option] command [command option]\n", exeName)
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Command list: help, getStatus\n")
|
||||
fmt.Printf("Command list: help, %s\n", getStatusCmd)
|
||||
fmt.Printf("Command list: %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s\n",
|
||||
createIssuerPairCmd,
|
||||
importIssuerPairCmd,
|
||||
revokeIssuerPairCmd,
|
||||
unrevokeIssuerPairCmd,
|
||||
listIssuerPairsCmd,
|
||||
getIssuerCertificateCmd,
|
||||
createServicePairCmd,
|
||||
revokeServicePairCmd,
|
||||
listServicePairsCmd,
|
||||
getServicePairCmd)
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Global options:\n")
|
||||
flag.PrintDefaults()
|
||||
@@ -125,6 +157,146 @@ func (util *Util) GetOpt() error {
|
||||
flagSet.Parse(subArgs)
|
||||
util.subCmd = subCmd
|
||||
|
||||
case createIssuerPairCmd:
|
||||
flagSet := flag.NewFlagSet(createIssuerPairCmd, flag.ExitOnError)
|
||||
|
||||
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 importIssuerPairCmd:
|
||||
flagSet := flag.NewFlagSet(importIssuerPairCmd, flag.ExitOnError)
|
||||
|
||||
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 revokeIssuerPairCmd:
|
||||
flagSet := flag.NewFlagSet(revokeIssuerPairCmd, flag.ExitOnError)
|
||||
|
||||
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 unrevokeIssuerPairCmd:
|
||||
flagSet := flag.NewFlagSet(unrevokeIssuerPairCmd, flag.ExitOnError)
|
||||
|
||||
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 listIssuerPairsCmd:
|
||||
flagSet := flag.NewFlagSet(listIssuerPairsCmd, flag.ExitOnError)
|
||||
|
||||
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 getIssuerCertificateCmd:
|
||||
flagSet := flag.NewFlagSet(getIssuerCertificateCmd, flag.ExitOnError)
|
||||
|
||||
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 createServicePairCmd:
|
||||
flagSet := flag.NewFlagSet(createServicePairCmd, flag.ExitOnError)
|
||||
|
||||
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 revokeServicePairCmd:
|
||||
flagSet := flag.NewFlagSet(revokeServicePairCmd, flag.ExitOnError)
|
||||
|
||||
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 listServicePairsCmd:
|
||||
flagSet := flag.NewFlagSet(listServicePairsCmd, flag.ExitOnError)
|
||||
|
||||
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 getServicePairCmd:
|
||||
flagSet := flag.NewFlagSet(getServicePairCmd, flag.ExitOnError)
|
||||
|
||||
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")
|
||||
@@ -170,18 +342,17 @@ func (util *Util) Exec() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (util *Util) GetStatus(ctx context.Context) (*lbapi.GetStatusResult, error) {
|
||||
func (util *Util) GetStatus(ctx context.Context) (*cmapi.GetStatusResult, error) {
|
||||
var err error
|
||||
res := &lbapi.GetStatusResult{}
|
||||
res := &cmapi.GetStatusResult{}
|
||||
cont, err := client.NewClient(&util.access)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
req := util.getStatusParams
|
||||
res, err = cont.GetStatus(ctx, &req)
|
||||
params := util.getStatusParams
|
||||
res, err = cont.GetStatus(ctx, ¶ms)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user