gc -> admin gc (#126, #116); cli cleanups and polish (#56)

This commit is contained in:
Michael Quigley 2022-12-01 13:19:37 -05:00
parent 313647b5aa
commit 4897fb399e
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 20 additions and 14 deletions

View File

@ -8,25 +8,25 @@ import (
) )
func init() { func init() {
rootCmd.AddCommand(newGcCmd().cmd) adminCmd.AddCommand(newAdminGcCommand().cmd)
} }
type gcCmd struct { type adminGcCommand struct {
cmd *cobra.Command cmd *cobra.Command
} }
func newGcCmd() *gcCmd { func newAdminGcCommand() *adminGcCommand {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "gc <configPath>", Use: "gc <configPath>",
Short: "Garbage collect a zrok instance", Short: "Garbage collect a zrok instance",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
} }
c := &gcCmd{cmd: cmd} c := &adminGcCommand{cmd: cmd}
cmd.Run = c.run cmd.Run = c.run
return c return c
} }
func (gc *gcCmd) run(_ *cobra.Command, args []string) { func (gc *adminGcCommand) run(_ *cobra.Command, args []string) {
cfg, err := controller.LoadConfig(args[0]) cfg, err := controller.LoadConfig(args[0])
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -16,7 +16,9 @@ func init() {
rootCmd.PersistentFlags().BoolVarP(&panicInstead, "panic", "p", false, "Panic instead of showing pretty errors") rootCmd.PersistentFlags().BoolVarP(&panicInstead, "panic", "p", false, "Panic instead of showing pretty errors")
zrokdir.AddZrokApiEndpointFlag(&apiEndpoint, rootCmd.PersistentFlags()) zrokdir.AddZrokApiEndpointFlag(&apiEndpoint, rootCmd.PersistentFlags())
rootCmd.AddCommand(accessCmd) rootCmd.AddCommand(accessCmd)
rootCmd.AddCommand(adminCmd)
rootCmd.AddCommand(shareCmd) rootCmd.AddCommand(shareCmd)
rootCmd.AddCommand(testCmd)
} }
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
@ -34,12 +36,22 @@ var apiEndpoint string
var accessCmd = &cobra.Command{ var accessCmd = &cobra.Command{
Use: "access", Use: "access",
Short: "Access services", Short: "Create frontend access for services",
}
var adminCmd = &cobra.Command{
Use: "admin",
Short: "Administration and operations functions",
} }
var shareCmd = &cobra.Command{ var shareCmd = &cobra.Command{
Use: "share", Use: "share",
Short: "Share resources", Short: "Create backend access for services",
}
var testCmd = &cobra.Command{
Use: "test",
Short: "Utilities for testing zrok deployments",
} }
func main() { func main() {

View File

@ -26,7 +26,7 @@ type reserveCommand struct {
func newReserveCommand() *reserveCommand { func newReserveCommand() *reserveCommand {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "reserve <public|private> <targetEndpoint>", Use: "reserve <public|private> <targetEndpoint>",
Short: "Reserve a service", Short: "Create a reserved service",
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
} }
command := &reserveCommand{cmd: cmd} command := &reserveCommand{cmd: cmd}

View File

@ -14,12 +14,6 @@ import (
func init() { func init() {
testCmd.AddCommand(newTestEndpointCommand().cmd) testCmd.AddCommand(newTestEndpointCommand().cmd)
rootCmd.AddCommand(testCmd)
}
var testCmd = &cobra.Command{
Use: "test",
Short: "Utilities used for testing zrok",
} }
type testEndpointCommand struct { type testEndpointCommand struct {