35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"scm.bstein.dev/bstein/ananke/internal/cluster"
|
|
"scm.bstein.dev/bstein/ananke/internal/config"
|
|
"scm.bstein.dev/bstein/ananke/internal/execx"
|
|
"scm.bstein.dev/bstein/ananke/internal/state"
|
|
)
|
|
|
|
// buildOrchestrator runs one orchestration or CLI step.
|
|
// Signature: buildOrchestrator(logger *log.Logger, cfgPath string, dryRun bool) (config.Config, *cluster.Orchestrator, error).
|
|
// Why: keeps behavior explicit so startup/shutdown workflows remain maintainable as services evolve.
|
|
func buildOrchestrator(logger *log.Logger, cfgPath string, dryRun bool) (config.Config, *cluster.Orchestrator, error) {
|
|
cfg, err := config.Load(cfgPath)
|
|
if err != nil {
|
|
return config.Config{}, nil, err
|
|
}
|
|
if err := state.EnsureDir(cfg.State.Dir); err != nil {
|
|
return config.Config{}, nil, err
|
|
}
|
|
if err := state.EnsureDir(cfg.State.ReportsDir); err != nil {
|
|
return config.Config{}, nil, err
|
|
}
|
|
runner := &execx.Runner{
|
|
DryRun: dryRun,
|
|
Kubeconfig: cfg.Kubeconfig,
|
|
Logger: logger,
|
|
}
|
|
store := state.New(cfg.State.RunHistoryPath)
|
|
orch := cluster.New(cfg, runner, store, logger)
|
|
return cfg, orch, nil
|
|
}
|