Skip to content

Commit

Permalink
cleanup/refactor: Alpha Generate command
Browse files Browse the repository at this point in the history
- Refactored the code implementation to improve error handling, encapsulate logic, and streamline execution flow.
- Moved the code implementation from `pkg` to the CLI since it pertains directly to a command.
- Additionally, moved the implementation to `internal` to prevent exposing the `Generate` code and avoid unintentional extensions on this alpha feature.
  • Loading branch information
camilamacedo86 committed Sep 23, 2024
1 parent b4e57ed commit 33e24da
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 127 deletions.
9 changes: 4 additions & 5 deletions pkg/cli/alpha/generate.go → pkg/cli/alpha/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ package alpha

import (
log "github.com/sirupsen/logrus"

"github.com/spf13/cobra"
"sigs.k8s.io/kubebuilder/v4/pkg/rescaffold"
"sigs.k8s.io/kubebuilder/v4/pkg/cli/alpha/internal"
)

// NewScaffoldCommand return a new scaffold command
func NewScaffoldCommand() *cobra.Command {
opts := rescaffold.MigrateOptions{}
opts := internal.Generate{}
scaffoldCmd := &cobra.Command{
Use: "generate",
Short: "Re-scaffold an existing Kuberbuilder project",
Expand All @@ -36,8 +35,8 @@ Then we will re-scaffold the project by Kubebuilder in the directory specified b
return opts.Validate()
},
Run: func(_ *cobra.Command, _ []string) {
if err := opts.Rescaffold(); err != nil {
log.Fatalf("Failed to rescaffold %s", err)
if err := opts.Generate(); err != nil {
log.Fatalf("Failed to command %s", err)
}
},
}
Expand Down
Loading

0 comments on commit 33e24da

Please sign in to comment.