Skip to content

Commit

Permalink
pkg/plugin: updates based on review in SDK repo
Browse files Browse the repository at this point in the history
  • Loading branch information
joelanford committed Jul 16, 2020
1 parent 02c860b commit d06b703
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
2 changes: 0 additions & 2 deletions pkg/plugin/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strings"

"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/pkg/model/resource"
"sigs.k8s.io/kubebuilder/pkg/plugin"
Expand All @@ -36,7 +35,6 @@ type createAPIPlugin struct {
config *config.Config

createOptions chartutil.CreateOptions
gvk schema.GroupVersionKind
}

var (
Expand Down
5 changes: 3 additions & 2 deletions pkg/plugin/v1/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (p *initPlugin) Validate() error {
}

defaultOpts := chartutil.CreateOptions{CRDVersion: "v1"}
if !p.apiPlugin.gvk.Empty() || p.apiPlugin.createOptions != defaultOpts {
if !p.apiPlugin.createOptions.GVK.Empty() || p.apiPlugin.createOptions != defaultOpts {
p.doAPIScaffold = true
return p.apiPlugin.Validate()
}
Expand All @@ -164,6 +164,7 @@ func (p *initPlugin) GetScaffolder() (scaffold.Scaffolder, error) {
func (p *initPlugin) PostScaffold() error {
if !p.doAPIScaffold {
fmt.Printf("Next: define a resource with:\n$ %s create api\n", p.commandName)
return nil
}
return nil
return p.apiPlugin.PostScaffold()
}
23 changes: 7 additions & 16 deletions pkg/plugin/v1/scaffolds/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,6 @@ func NewAPIScaffolder(config *config.Config, opts chartutil.CreateOptions) scaff

// Scaffold implements Scaffolder
func (s *apiScaffolder) Scaffold() error {
switch {
case s.config.IsV2(), s.config.IsV3():
return s.scaffold()
default:
return fmt.Errorf("unknown project version %v", s.config.Version)
}
}

func (s *apiScaffolder) newUniverse(r *resource.Resource) *model.Universe {
return model.NewUniverse(
model.WithConfig(s.config),
model.WithResource(r),
)
}

func (s *apiScaffolder) scaffold() error {
projectDir, err := os.Getwd()
if err != nil {
return err
Expand Down Expand Up @@ -136,3 +120,10 @@ func (s *apiScaffolder) scaffold() error {

return nil
}

func (s *apiScaffolder) newUniverse(r *resource.Resource) *model.Universe {
return model.NewUniverse(
model.WithConfig(s.config),
model.WithResource(r),
)
}

0 comments on commit d06b703

Please sign in to comment.