Added: ctl create controller

This commit is contained in:
2026-04-25 00:46:43 +08:00
parent e4a19e5926
commit 1354e83813
13 changed files with 372 additions and 450 deletions

View File

@@ -3,11 +3,12 @@ package create
import (
"fmt"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
render "example.com/monok8s/pkg/render"
)
func NewCmdCreate() *cobra.Command {
func NewCmdCreate(flags *genericclioptions.ConfigFlags) *cobra.Command {
cmd := &cobra.Command{Use: "create", Short: "Create starter resources"}
cmd.AddCommand(
&cobra.Command{
@@ -26,7 +27,29 @@ func NewCmdCreate() *cobra.Command {
Use: "osupgrade",
Short: "Print an OSUpgrade template",
RunE: func(cmd *cobra.Command, _ []string) error {
out, err := render.RenderOSUpgrade()
ns, _, err := flags.ToRawKubeConfigLoader().Namespace()
if err != nil {
return err
}
out, err := render.RenderOSUpgrade(ns)
if err != nil {
return err
}
_, err = fmt.Fprint(cmd.OutOrStdout(), out)
return err
},
},
&cobra.Command{
Use: "controller",
Short: "Print controller deployment template",
RunE: func(cmd *cobra.Command, _ []string) error {
ns, _, err := flags.ToRawKubeConfigLoader().Namespace()
if err != nil {
return err
}
out, err := render.RenderControllerDeployments(ns)
if err != nil {
return err
}