Skip to content

Commit

Permalink
Backport: commands/.../generate: verbose codegen by default (#1271) (#…
Browse files Browse the repository at this point in the history
…1279)

* cmd/.../genutil: verbose codegen by default

* test/e2e: remove explicit setting of verbosity

* CHANGELOG.md: add generate verbosity change
  • Loading branch information
estroz authored Apr 2, 2019
1 parent 1ede19f commit f4e92a0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Changed

- Subcommands of [`operator-sdk generate`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#generate) are now verbose by default. ([#1271](https://github.com/operator-framework/operator-sdk/pull/1271))

### Deprecated

### Removed
Expand Down
1 change: 1 addition & 0 deletions commands/operator-sdk/cmd/generate/internal/genutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func runGoBuildCodegen(binDir, repoDir, genDir string) error {
cmd.Env = append(os.Environ(), projutil.GoFlagsEnv+"="+gf)
}

// Only print binary build info if verbosity is explicitly set.
if projutil.IsGoVerbose() {
return projutil.ExecCmd(cmd)
}
Expand Down
19 changes: 2 additions & 17 deletions commands/operator-sdk/cmd/generate/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package generate

import (
"fmt"
"io/ioutil"
"os/exec"
"path/filepath"
"strings"
Expand Down Expand Up @@ -118,14 +117,7 @@ func deepcopyGen(binDir, repoPkg string, gvMap map[string][]string) (err error)
"--bounding-dirs", apisPkg,
}
cmd := exec.Command(filepath.Join(binDir, "deepcopy-gen"), args...)
if projutil.IsGoVerbose() {
err = projutil.ExecCmd(cmd)
} else {
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
err = cmd.Run()
}
if err != nil {
if err = projutil.ExecCmd(cmd); err != nil {
return fmt.Errorf("failed to perform deepcopy code-generation: %v", err)
}
return nil
Expand All @@ -138,14 +130,7 @@ func defaulterGen(binDir, repoPkg string, gvMap map[string][]string) (err error)
"--output-file-base", "zz_generated.defaults",
}
cmd := exec.Command(filepath.Join(binDir, "defaulter-gen"), args...)
if projutil.IsGoVerbose() {
err = projutil.ExecCmd(cmd)
} else {
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
err = cmd.Run()
}
if err != nil {
if err = projutil.ExecCmd(cmd); err != nil {
return fmt.Errorf("failed to perform defaulter code-generation: %v", err)
}
return nil
Expand Down
9 changes: 1 addition & 8 deletions commands/operator-sdk/cmd/generate/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,7 @@ func openAPIGen(binDir string, fqApis []string) (err error) {
"--go-header-file", headerFile,
}
cmd := exec.Command(cgPath, args...)
if projutil.IsGoVerbose() {
err = projutil.ExecCmd(cmd)
} else {
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
err = cmd.Run()
}
if err != nil {
if err = projutil.ExecCmd(cmd); err != nil {
return fmt.Errorf("failed to perform openapi code-generation: %v", err)
}
}
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/memcached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ func TestMemcached(t *testing.T) {
"api",
"--api-version=cache.example.com/v1alpha1",
"--kind=Memcached")
// Generators will print errors if -v is set.
if !projutil.IsGoVerbose() {
os.Setenv(projutil.GoFlagsEnv, os.Getenv(projutil.GoFlagsEnv)+" -v")
}
cmd.Env = os.Environ()
cmdOut, err = cmd.CombinedOutput()
if err != nil {
Expand Down

0 comments on commit f4e92a0

Please sign in to comment.