Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions commands/operator-sdk/cmd/generate/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (

const (
k8sGenerated = "./tmp/codegen/update-generated.sh"
// dot represents current dir.
dot = "."
)

func NewGenerateK8SCmd() *cobra.Command {
Expand All @@ -44,8 +46,14 @@ func k8sFunc(cmd *cobra.Command, args []string) {
if len(args) != 0 {
cmdError.ExitWithError(cmdError.ExitBadArgs, errors.New("k8s command doesn't accept any arguments."))
}
K8sCodegen(dot)
}

// K8sCodegen performs code-generation for custom resources of this project given the projectDir.
func K8sCodegen(projectDir string) {
fmt.Fprintln(os.Stdout, "Run code-generation for custom resources")
kcmd := exec.Command(k8sGenerated)
kcmd.Dir = projectDir
o, err := kcmd.CombinedOutput()
if err != nil {
cmdError.ExitWithError(cmdError.ExitError, fmt.Errorf("failed to perform code-generation for CustomResources: (%v)", string(o)))
Expand Down
2 changes: 2 additions & 0 deletions commands/operator-sdk/cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"path/filepath"
"strings"

"github.com/coreos/operator-sdk/commands/operator-sdk/cmd/generate"
cmdError "github.com/coreos/operator-sdk/commands/operator-sdk/error"
"github.com/coreos/operator-sdk/pkg/generator"

Expand Down Expand Up @@ -82,6 +83,7 @@ func newFunc(cmd *cobra.Command, args []string) {
cmdError.ExitWithError(cmdError.ExitError, fmt.Errorf("failed to create project %v: %v", projectName, err))
}
pullDep()
generate.K8sCodegen(projectName)
}

func parse(args []string) {
Expand Down