Added some ctl boilerplate
This commit is contained in:
34
clitools/pkg/cmd/initcmd/init.go
Normal file
34
clitools/pkg/cmd/initcmd/init.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package initcmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"undecided.project/monok8s/pkg/bootstrap"
|
||||
"undecided.project/monok8s/pkg/config"
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
func NewCmdInit(_ *genericclioptions.ConfigFlags) *cobra.Command {
|
||||
var configPath string
|
||||
cmd := &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Equivalent of apply-node-config + bootstrap-cluster",
|
||||
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
|
||||
}
|
||||
klog.InfoS("starting init", "config", path, "node", cfg.Spec.NodeName)
|
||||
return bootstrap.NewRunner(cfg).Init(cmd.Context())
|
||||
},
|
||||
}
|
||||
cmd.Flags().StringVarP(&configPath, "config", "c", "", "path to MonoKSConfig yaml")
|
||||
_ = context.Background()
|
||||
return cmd
|
||||
}
|
||||
Reference in New Issue
Block a user