Skip to content

Commit

Permalink
Handle 3-alpha based on review comments
Browse files Browse the repository at this point in the history
Signed-off-by: jesus m. rodriguez <jesusr@redhat.com>
  • Loading branch information
jmrodri committed Apr 7, 2021
1 parent 2a26cd8 commit 3a6040d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"github.com/spf13/pflag"

"sigs.k8s.io/kubebuilder/v3/pkg/config"
"sigs.k8s.io/kubebuilder/v3/pkg/config/store"
yamlstore "sigs.k8s.io/kubebuilder/v3/pkg/config/store/yaml"
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
"sigs.k8s.io/kubebuilder/v3/pkg/model/stage"
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
)

Expand Down Expand Up @@ -146,16 +146,11 @@ func (c *CLI) buildCmd() error {
c.cmd = c.newRootCmd()

// Get project version and plugin keys.
err := c.getInfo()
if err != nil {
if le, ok := err.(store.LoadError); ok {
// ignore UnsupportedVersionError, I'd prefer to verify a specific type
// of error instead of the string, but alas LoadError consists wrapped
// errors.
if !strings.Contains(le.Err.Error(), "unable to create config for version") {
return err
}
}
// Ignore 3-alpha error
switch err := c.getInfo(); {
case err == nil:
case !errors.Is(err, config.UnsupportedVersionError{Version: config.Version{Number: 3, Stage: stage.Alpha}}):
return err
}

// Resolve plugins for project version and plugin keys.
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/store/yaml/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *yamlStore) LoadFrom(path string) error {
var cfg config.Config
cfg, err = config.New(versioned.Version)
if err != nil {
return store.LoadError{Err: fmt.Errorf("unable to create config for version %q: %w", versioned.Version, err)}
return store.LoadError{Err: config.UnsupportedVersionError{Version: versioned.Version}}
}

// Unmarshal the file content
Expand Down

0 comments on commit 3a6040d

Please sign in to comment.