Skip to content

Commit

Permalink
Refactor cli package
Browse files Browse the repository at this point in the history
  • Loading branch information
Adirio committed Nov 18, 2020
1 parent 5a78c19 commit 2177510
Show file tree
Hide file tree
Showing 19 changed files with 1,077 additions and 814 deletions.
7 changes: 6 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"log"

"sigs.k8s.io/kubebuilder/v2/pkg/cli"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"
pluginv2 "sigs.k8s.io/kubebuilder/v2/pkg/plugins/golang/v2"
pluginv3 "sigs.k8s.io/kubebuilder/v2/pkg/plugins/golang/v3"
)
Expand All @@ -28,11 +29,15 @@ func main() {
c, err := cli.New(
cli.WithCommandName("kubebuilder"),
cli.WithVersion(versionString()),
cli.WithDefaultProjectVersion(config.Version2),
cli.WithPlugins(
&pluginv2.Plugin{},
&pluginv3.Plugin{},
),
cli.WithDefaultPlugins(
cli.WithDefaultPlugins(config.Version2,
&pluginv2.Plugin{},
),
cli.WithDefaultPlugins(config.Version3Alpha,
&pluginv2.Plugin{},
),
cli.WithCompletion,
Expand Down
8 changes: 2 additions & 6 deletions pkg/cli/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"sigs.k8s.io/kubebuilder/v2/pkg/plugin"
)

func (c *cli) newCreateAPICmd() *cobra.Command {
func (c cli) newCreateAPICmd() *cobra.Command {
ctx := c.newAPIContext()
cmd := &cobra.Command{
Use: "api",
Expand All @@ -43,15 +43,11 @@ func (c *cli) newCreateAPICmd() *cobra.Command {
}

func (c cli) newAPIContext() plugin.Context {
ctx := plugin.Context{
return plugin.Context{
CommandName: c.commandName,
Description: `Scaffold a Kubernetes API.
`,
}
if !c.configured {
ctx.Description = fmt.Sprintf("%s\n%s", ctx.Description, runInProjectRootMsg)
}
return ctx
}

// nolint:dupl
Expand Down
Loading

0 comments on commit 2177510

Please sign in to comment.