Added some ctl boilerplate
This commit is contained in:
58
clitools/pkg/bootstrap/runner.go
Normal file
58
clitools/pkg/bootstrap/runner.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||
"undecided.project/monok8s/pkg/node"
|
||||
"undecided.project/monok8s/pkg/system"
|
||||
)
|
||||
|
||||
type Runner struct {
|
||||
NodeCtx *node.NodeContext
|
||||
Registry *Registry
|
||||
}
|
||||
|
||||
func NewRunner(cfg *monov1alpha1.MonoKSConfig) *Runner {
|
||||
runnerCfg := system.RunnerConfig{}
|
||||
nctx := &node.NodeContext{
|
||||
Config: cfg,
|
||||
System: system.NewRunner(runnerCfg),
|
||||
}
|
||||
return &Runner{
|
||||
NodeCtx: nctx,
|
||||
Registry: NewRegistry(nctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Runner) Init(ctx context.Context) error {
|
||||
for _, name := range []string{
|
||||
"check_prereqs",
|
||||
"validate_network_requirements",
|
||||
"install_cni_if_requested",
|
||||
"start_crio",
|
||||
"check_crio_running",
|
||||
"wait_for_existing_cluster_if_needed",
|
||||
"decide_bootstrap_action",
|
||||
"check_required_images",
|
||||
"generate_kubeadm_config",
|
||||
"run_kubeadm_init",
|
||||
"restart_kubelet",
|
||||
"apply_local_node_metadata_if_possible",
|
||||
"allow_single_node_scheduling",
|
||||
"print_summary",
|
||||
} {
|
||||
if err := r.RunNamedStep(ctx, name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Runner) RunNamedStep(ctx context.Context, name string) error {
|
||||
step, err := r.Registry.Get(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return step(ctx, r.NodeCtx)
|
||||
}
|
||||
Reference in New Issue
Block a user