mirror of
https://github.com/holos-run/holos.git
synced 2026-04-07 18:15:00 +00:00
This adds a new holos subcommand: preflight Initially, this just checks that the GitHub CLI is installed and authenticated. The preflight command will be used to validate that the user has the neccessary CLI tools, access, and authorization to start using Holos and setup a Holos cluster.
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/pkg/cli/command"
|
|
"github.com/holos-run/holos/pkg/holos"
|
|
"github.com/holos-run/holos/pkg/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) *cobra.Command {
|
|
cfg, flagSet := newConfig()
|
|
|
|
cmd := command.New("preflight")
|
|
cmd.Short = "Run preflight checks to ensure you're ready to use Holos"
|
|
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
|
|
}
|
|
}
|