Added some ctl boilerplate
This commit is contained in:
30
clitools/pkg/cmd/internal/internal.go
Normal file
30
clitools/pkg/cmd/internal/internal.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"undecided.project/monok8s/pkg/bootstrap"
|
||||
"undecided.project/monok8s/pkg/config"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewCmdInternal() *cobra.Command {
|
||||
var configPath string
|
||||
cmd := &cobra.Command{Use: "internal", Hidden: true}
|
||||
cmd.AddCommand(&cobra.Command{
|
||||
Use: "run-step STEP",
|
||||
Short: "Run one internal step for testing",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
path, err := (config.Loader{}).ResolvePath(configPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cfg, err := (config.Loader{}).Load(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return bootstrap.NewRunner(cfg).RunNamedStep(cmd.Context(), args[0])
|
||||
},
|
||||
})
|
||||
cmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "path to MonoKSConfig yaml")
|
||||
return cmd
|
||||
}
|
||||
Reference in New Issue
Block a user