From c53c97dbcfff82e72fbd98f0012d212dd037e2a4 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Thu, 10 Dec 2020 20:57:32 -0800 Subject: [PATCH] Created template for server process subcommands --- internal/app/warewulfd/root.go | 15 +++++++------- .../app/wwctl/container/exec/child/root.go | 9 +++++---- internal/app/wwctl/container/exec/root.go | 11 +++++----- internal/app/wwctl/server/root.go | 20 +++++++++++++++++++ internal/app/wwctl/server/start/main.go | 8 ++++++++ internal/app/wwctl/server/start/root.go | 20 +++++++++++++++++++ internal/app/wwctl/server/status/main.go | 8 ++++++++ internal/app/wwctl/server/status/root.go | 20 +++++++++++++++++++ internal/app/wwctl/server/stop/main.go | 8 ++++++++ internal/app/wwctl/server/stop/root.go | 20 +++++++++++++++++++ .../wwctl/{service => system}/dhcp/main.go | 0 .../wwctl/{service => system}/tftp/main.go | 0 12 files changed, 122 insertions(+), 17 deletions(-) create mode 100644 internal/app/wwctl/server/root.go create mode 100644 internal/app/wwctl/server/start/main.go create mode 100644 internal/app/wwctl/server/start/root.go create mode 100644 internal/app/wwctl/server/status/main.go create mode 100644 internal/app/wwctl/server/status/root.go create mode 100644 internal/app/wwctl/server/stop/main.go create mode 100644 internal/app/wwctl/server/stop/root.go rename internal/app/wwctl/{service => system}/dhcp/main.go (100%) rename internal/app/wwctl/{service => system}/tftp/main.go (100%) diff --git a/internal/app/warewulfd/root.go b/internal/app/warewulfd/root.go index 9809b0b5..7d0032c3 100644 --- a/internal/app/warewulfd/root.go +++ b/internal/app/warewulfd/root.go @@ -7,17 +7,16 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "warewulfd", - Short: "Warewulf Daemon Service", - Long: "This is the primary Warewulf service for provisioning nodes", - RunE: CobraRunE, - PersistentPreRunE: rootPersistentPreRunE, + Use: "warewulfd", + Short: "Warewulf Daemon Service", + Long: "This is the primary Warewulf system for provisioning nodes", + RunE: CobraRunE, + PersistentPreRunE: rootPersistentPreRunE, } verboseArg bool - debugArg bool + debugArg bool ) - func init() { baseCmd.PersistentFlags().BoolVarP(&verboseArg, "verbose", "v", false, "Run with increased verbosity.") baseCmd.PersistentFlags().BoolVarP(&debugArg, "debug", "d", false, "Run with debugging messages enabled.") @@ -37,4 +36,4 @@ func rootPersistentPreRunE(cmd *cobra.Command, args []string) error { wwlog.SetLevel(wwlog.INFO) } return nil -} \ No newline at end of file +} diff --git a/internal/app/wwctl/container/exec/child/root.go b/internal/app/wwctl/container/exec/child/root.go index 6df31ff4..48aa0d8b 100644 --- a/internal/app/wwctl/container/exec/child/root.go +++ b/internal/app/wwctl/container/exec/child/root.go @@ -4,10 +4,11 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "__child", - Hidden: true, - RunE: CobraRunE, - Args: cobra.MinimumNArgs(1), + Use: "__child", + Hidden: true, + RunE: CobraRunE, + Args: cobra.MinimumNArgs(1), + FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, } ) diff --git a/internal/app/wwctl/container/exec/root.go b/internal/app/wwctl/container/exec/root.go index 049ca014..32b6c75b 100644 --- a/internal/app/wwctl/container/exec/root.go +++ b/internal/app/wwctl/container/exec/root.go @@ -7,11 +7,12 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "exec", - Short: "Spawn any command inside a Warewulf container", - Long: "Run a command inside a Warewulf container ", - RunE: CobraRunE, - Args: cobra.MinimumNArgs(1), + Use: "exec", + Short: "Spawn any command inside a Warewulf container", + Long: "Run a command inside a Warewulf container ", + RunE: CobraRunE, + Args: cobra.MinimumNArgs(1), + FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, } ) diff --git a/internal/app/wwctl/server/root.go b/internal/app/wwctl/server/root.go new file mode 100644 index 00000000..26870499 --- /dev/null +++ b/internal/app/wwctl/server/root.go @@ -0,0 +1,20 @@ +package server + +import "github.com/spf13/cobra" + +var ( + baseCmd = &cobra.Command{ + Use: "server", + Short: "Warewulf server process commands", + Long: "Warewulf profiles...", + } + test bool +) + +func init() { +} + +// GetRootCommand returns the root cobra.Command for the application. +func GetCommand() *cobra.Command { + return baseCmd +} diff --git a/internal/app/wwctl/server/start/main.go b/internal/app/wwctl/server/start/main.go new file mode 100644 index 00000000..3f368ae7 --- /dev/null +++ b/internal/app/wwctl/server/start/main.go @@ -0,0 +1,8 @@ +package start + +import "github.com/spf13/cobra" + +func CobraRunE(cmd *cobra.Command, args []string) error { + + return nil +} diff --git a/internal/app/wwctl/server/start/root.go b/internal/app/wwctl/server/start/root.go new file mode 100644 index 00000000..357e0169 --- /dev/null +++ b/internal/app/wwctl/server/start/root.go @@ -0,0 +1,20 @@ +package start + +import "github.com/spf13/cobra" + +var ( + baseCmd = &cobra.Command{ + Use: "start", + Short: "Start Warewulf server", + Long: "Warewulf Server ", + RunE: CobraRunE, + } +) + +func init() { +} + +// GetRootCommand returns the root cobra.Command for the application. +func GetCommand() *cobra.Command { + return baseCmd +} diff --git a/internal/app/wwctl/server/status/main.go b/internal/app/wwctl/server/status/main.go new file mode 100644 index 00000000..5c1b993d --- /dev/null +++ b/internal/app/wwctl/server/status/main.go @@ -0,0 +1,8 @@ +package status + +import "github.com/spf13/cobra" + +func CobraRunE(cmd *cobra.Command, args []string) error { + + return nil +} diff --git a/internal/app/wwctl/server/status/root.go b/internal/app/wwctl/server/status/root.go new file mode 100644 index 00000000..71805969 --- /dev/null +++ b/internal/app/wwctl/server/status/root.go @@ -0,0 +1,20 @@ +package status + +import "github.com/spf13/cobra" + +var ( + baseCmd = &cobra.Command{ + Use: "status", + Short: "Warewulf server status", + Long: "Warewulf Server ", + RunE: CobraRunE, + } +) + +func init() { +} + +// GetRootCommand returns the root cobra.Command for the application. +func GetCommand() *cobra.Command { + return baseCmd +} diff --git a/internal/app/wwctl/server/stop/main.go b/internal/app/wwctl/server/stop/main.go new file mode 100644 index 00000000..daa8898b --- /dev/null +++ b/internal/app/wwctl/server/stop/main.go @@ -0,0 +1,8 @@ +package stop + +import "github.com/spf13/cobra" + +func CobraRunE(cmd *cobra.Command, args []string) error { + + return nil +} diff --git a/internal/app/wwctl/server/stop/root.go b/internal/app/wwctl/server/stop/root.go new file mode 100644 index 00000000..fd331c56 --- /dev/null +++ b/internal/app/wwctl/server/stop/root.go @@ -0,0 +1,20 @@ +package stop + +import "github.com/spf13/cobra" + +var ( + baseCmd = &cobra.Command{ + Use: "stop", + Short: "Stop Warewulf server", + Long: "Warewulf Server ", + RunE: CobraRunE, + } +) + +func init() { +} + +// GetRootCommand returns the root cobra.Command for the application. +func GetCommand() *cobra.Command { + return baseCmd +} diff --git a/internal/app/wwctl/service/dhcp/main.go b/internal/app/wwctl/system/dhcp/main.go similarity index 100% rename from internal/app/wwctl/service/dhcp/main.go rename to internal/app/wwctl/system/dhcp/main.go diff --git a/internal/app/wwctl/service/tftp/main.go b/internal/app/wwctl/system/tftp/main.go similarity index 100% rename from internal/app/wwctl/service/tftp/main.go rename to internal/app/wwctl/system/tftp/main.go