Skip to content

Commit b3c1e7b

Browse files
cleanup/refactor: Alpha Generate command
- 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.
1 parent 253fde2 commit b3c1e7b

File tree

2 files changed

+157
-127
lines changed

2 files changed

+157
-127
lines changed

pkg/cli/alpha/generate.go renamed to pkg/cli/alpha/command.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ package alpha
1515

1616
import (
1717
log "github.com/sirupsen/logrus"
18-
1918
"github.com/spf13/cobra"
20-
"sigs.k8s.io/kubebuilder/v4/pkg/rescaffold"
19+
"sigs.k8s.io/kubebuilder/v4/pkg/cli/alpha/internal"
2120
)
2221

2322
// NewScaffoldCommand return a new scaffold command
2423
func NewScaffoldCommand() *cobra.Command {
25-
opts := rescaffold.MigrateOptions{}
24+
opts := internal.Generate{}
2625
scaffoldCmd := &cobra.Command{
2726
Use: "generate",
2827
Short: "Re-scaffold an existing Kuberbuilder project",
@@ -36,8 +35,8 @@ Then we will re-scaffold the project by Kubebuilder in the directory specified b
3635
return opts.Validate()
3736
},
3837
Run: func(_ *cobra.Command, _ []string) {
39-
if err := opts.Rescaffold(); err != nil {
40-
log.Fatalf("Failed to rescaffold %s", err)
38+
if err := opts.Generate(); err != nil {
39+
log.Fatalf("Failed to command %s", err)
4140
}
4241
},
4342
}

0 commit comments

Comments
 (0)