35 lines
902 B
Go
35 lines
902 B
Go
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
|
|
}
|