Skip to content

Commit

Permalink
Preflight: Add getPreflightChecksHelper function
Browse files Browse the repository at this point in the history
This remove some of code duplication.
  • Loading branch information
praveenkumar committed Sep 29, 2023
1 parent 5cc6a32 commit 706f392
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/crc/preflight/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,26 @@ func doRegisterSettings(cfg crcConfig.Schema, checks []Check) {
}
}

// StartPreflightChecks performs the preflight checks before starting the cluster
func StartPreflightChecks(config crcConfig.Storage) error {
func getPreflightChecksHelper(config crcConfig.Storage) []Check {
experimentalFeatures := config.Get(crcConfig.ExperimentalFeatures).AsBool()
mode := crcConfig.GetNetworkMode(config)
bundlePath := config.Get(crcConfig.Bundle).AsString()
preset := crcConfig.GetPreset(config)
if err := doPreflightChecks(config, getPreflightChecks(experimentalFeatures, mode, bundlePath, preset)); err != nil {
logging.Infof("Using bundle path %s", bundlePath)
return getPreflightChecks(experimentalFeatures, mode, bundlePath, preset)
}

// StartPreflightChecks performs the preflight checks before starting the cluster
func StartPreflightChecks(config crcConfig.Storage) error {
if err := doPreflightChecks(config, getPreflightChecksHelper(config)); err != nil {
return &errors.PreflightError{Err: err}
}
return nil
}

// SetupHost performs the prerequisite checks and setups the host to run the cluster
func SetupHost(config crcConfig.Storage, checkOnly bool) error {
experimentalFeatures := config.Get(crcConfig.ExperimentalFeatures).AsBool()
mode := crcConfig.GetNetworkMode(config)
bundlePath := config.Get(crcConfig.Bundle).AsString()
preset := crcConfig.GetPreset(config)
logging.Infof("Using bundle path %s", bundlePath)
return doFixPreflightChecks(config, getPreflightChecks(experimentalFeatures, mode, bundlePath, preset), checkOnly)
return doFixPreflightChecks(config, getPreflightChecksHelper(config), checkOnly)
}

func RegisterSettings(config crcConfig.Schema) {
Expand Down

0 comments on commit 706f392

Please sign in to comment.