Matches ctl version to upstream
This commit is contained in:
@@ -2,9 +2,9 @@ package create
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"undecided.project/monok8s/pkg/templates"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
render "undecided.project/monok8s/pkg/render"
|
||||
)
|
||||
|
||||
func NewCmdCreate() *cobra.Command {
|
||||
@@ -14,7 +14,11 @@ func NewCmdCreate() *cobra.Command {
|
||||
Use: "config",
|
||||
Short: "Print a MonoKSConfig template",
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
_, err := fmt.Fprint(cmd.OutOrStdout(), templates.MonoKSConfigYAML)
|
||||
out, err := render.RenderMonoKSConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = fmt.Fprint(cmd.OutOrStdout(), out)
|
||||
return err
|
||||
},
|
||||
},
|
||||
@@ -22,7 +26,11 @@ func NewCmdCreate() *cobra.Command {
|
||||
Use: "osupgrade",
|
||||
Short: "Print an OSUpgrade template",
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
_, err := fmt.Fprint(cmd.OutOrStdout(), templates.OSUpgradeYAML)
|
||||
out, err := render.RenderOSUpgrade()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = fmt.Fprint(cmd.OutOrStdout(), out)
|
||||
return err
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,15 +3,16 @@ package root
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/klog/v2"
|
||||
agentcmd "undecided.project/monok8s/pkg/cmd/agent"
|
||||
applycmd "undecided.project/monok8s/pkg/cmd/apply"
|
||||
checkconfigcmd "undecided.project/monok8s/pkg/cmd/checkconfig"
|
||||
createcmd "undecided.project/monok8s/pkg/cmd/create"
|
||||
initcmd "undecided.project/monok8s/pkg/cmd/initcmd"
|
||||
internalcmd "undecided.project/monok8s/pkg/cmd/internal"
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/klog/v2"
|
||||
versioncmd "undecided.project/monok8s/pkg/cmd/version"
|
||||
)
|
||||
|
||||
func NewRootCmd() *cobra.Command {
|
||||
@@ -30,6 +31,7 @@ func NewRootCmd() *cobra.Command {
|
||||
|
||||
flags.AddFlags(cmd.PersistentFlags())
|
||||
cmd.AddCommand(
|
||||
versioncmd.NewCmdVersion(),
|
||||
initcmd.NewCmdInit(flags),
|
||||
checkconfigcmd.NewCmdCheckConfig(),
|
||||
createcmd.NewCmdCreate(),
|
||||
|
||||
22
clitools/pkg/cmd/version/version.go
Normal file
22
clitools/pkg/cmd/version/version.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package apply
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
buildInfo "undecided.project/monok8s/pkg/buildinfo"
|
||||
)
|
||||
|
||||
func NewCmdVersion() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the version information",
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
|
||||
_, err := fmt.Fprintln(cmd.OutOrStdout(), buildInfo.Version)
|
||||
return err
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
Reference in New Issue
Block a user