Skip to content

Commit

Permalink
cleanup/refactory : Re-Generate Alpha Command
Browse files Browse the repository at this point in the history
refactor: improve error handling, encapsulate logic, and streamline flow in rescaffold command
move code implementation from pkg to CLI since it is a command
  • Loading branch information
camilamacedo86 committed Sep 23, 2024
1 parent b4e57ed commit 1a4f851
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 126 deletions.
8 changes: 4 additions & 4 deletions pkg/cli/alpha/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ package alpha

import (
log "github.com/sirupsen/logrus"
"sigs.k8s.io/kubebuilder/v4/pkg/cli"

Check failure on line 18 in pkg/cli/alpha/generate.go

View workflow job for this annotation

GitHub Actions / golangci-lint

could not import sigs.k8s.io/kubebuilder/v4/pkg/cli (-: import cycle not allowed: import stack: [sigs.k8s.io/kubebuilder/v4/cmd sigs.k8s.io/kubebuilder/v4/pkg/cli sigs.k8s.io/kubebuilder/v4/pkg/cli/alpha sigs.k8s.io/kubebuilder/v4/pkg/cli]) (typecheck)

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

// NewScaffoldCommand return a new scaffold command
func NewScaffoldCommand() *cobra.Command {
opts := rescaffold.MigrateOptions{}
opts := cli.ReGenerate{}
scaffoldCmd := &cobra.Command{
Use: "generate",
Short: "Re-scaffold an existing Kuberbuilder project",
Expand All @@ -36,8 +36,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 1a4f851

Please # to comment.