mirror of
https://github.com/holos-run/holos.git
synced 2026-03-20 09:15:02 +00:00
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package preflight
|
|
|
|
import (
|
|
"flag"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/holos-run/holos/internal/cli/command"
|
|
"github.com/holos-run/holos/internal/holos"
|
|
"github.com/holos-run/holos/internal/logger"
|
|
)
|
|
|
|
// Config holds configuration parameters for preflight checks.
|
|
type config struct {
|
|
githubInstance *string
|
|
}
|
|
|
|
// Build the shared configuration and flagset for the preflight command.
|
|
func newConfig() (*config, *flag.FlagSet) {
|
|
cfg := &config{}
|
|
flagSet := flag.NewFlagSet("", flag.ContinueOnError)
|
|
cfg.githubInstance = flagSet.String("github-instance", "github.com", "Address of the GitHub instance you want to use")
|
|
|
|
return cfg, flagSet
|
|
}
|
|
|
|
// New returns the preflight command for the root command.
|
|
func New(hc *holos.Config, feature holos.Flagger) *cobra.Command {
|
|
cfg, flagSet := newConfig()
|
|
cmd := command.New("preflight")
|
|
cmd.Hidden = !feature.Flag(holos.PreflightFeature)
|
|
cmd.Short = "run holos preflight checks"
|
|
cmd.Flags().AddGoFlagSet(flagSet)
|
|
cmd.RunE = makePreflightRunFunc(hc, cfg)
|
|
|
|
return cmd
|
|
}
|
|
|
|
// makePreflightRunFunc returns the internal implementation of the preflight cli command.
|
|
func makePreflightRunFunc(_ *holos.Config, cfg *config) command.RunFunc {
|
|
return func(cmd *cobra.Command, _ []string) error {
|
|
ctx := cmd.Context()
|
|
log := logger.FromContext(ctx)
|
|
log.Info("Starting preflight checks")
|
|
|
|
// GitHub checks
|
|
if err := RunGhChecks(ctx, cfg); err != nil {
|
|
return err
|
|
}
|
|
// Other checks can be added here
|
|
|
|
log.Info("Preflight checks complete. Ready to use Holos 🚀")
|
|
return nil
|
|
}
|
|
}
|