Skip to content

Commit

Permalink
Validation: Put more meaningful message in case invalid bundle path
Browse files Browse the repository at this point in the history
With this PR now end user will observe more meaningful message to run
`crc setup` in case want to use the default bundle.
```
$ ./crc config set bundle /foo/bar
Value '/foo/bar' for configuration property 'bundle' is invalid, reason: /foo/bar is invalid or missing, run 'crc setup' to download the default bundle

$ ./crc start -b /foo/bar
/foo/bar is invalid or missing, run 'crc setup' to download the default bundle
```
  • Loading branch information
praveenkumar committed Sep 29, 2023
1 parent 1f00507 commit 5cc6a32
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/crc/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,15 @@ func ValidateBundlePath(bundlePath string, preset crcpreset.Preset) error {
logging.Debugf("Got bundle path: %s", bundlePath)
if err := ValidateURL(bundlePath); err != nil {
var urlError *url.Error
var invalidPathError *invalidPath
// If error occur due to invalid path, then return with a more meaningful error message
if errors.As(err, &invalidPathError) {
return fmt.Errorf("%s is invalid or missing, run 'crc setup' to download the default bundle", bundlePath)
}
// Some local paths (for example relative paths) can't be parsed/validated by `ValidateURL` and will be validated here
if errors.As(err, &urlError) {
if err1 := ValidatePath(bundlePath); err1 != nil {
return err1
return fmt.Errorf("%s is invalid or missing, run 'crc setup' to download the default bundle", bundlePath)
}
} else {
return err
Expand Down

0 comments on commit 5cc6a32

Please sign in to comment.