Added some ctl boilerplate

This commit is contained in:
2026-03-27 18:34:53 +08:00
parent bf85462e34
commit 87aa1d4b0b
30 changed files with 1813 additions and 19 deletions

View File

@@ -0,0 +1,30 @@
package checkconfig
import (
"fmt"
"undecided.project/monok8s/pkg/config"
"github.com/spf13/cobra"
)
func NewCmdCheckConfig() *cobra.Command {
var configPath string
cmd := &cobra.Command{
Use: "checkconfig",
Short: "Validate a MonoKSConfig",
RunE: func(cmd *cobra.Command, _ []string) error {
path, err := (config.Loader{}).ResolvePath(configPath)
if err != nil {
return err
}
cfg, err := (config.Loader{}).Load(path)
if err != nil {
return err
}
fmt.Fprintf(cmd.OutOrStdout(), "OK: %s (%s / %s)\n", path, cfg.Spec.NodeName, cfg.Spec.KubernetesVersion)
return nil
},
}
cmd.Flags().StringVarP(&configPath, "config", "c", "", "path to MonoKSConfig yaml")
return cmd
}