Skip to content

Commit 97782e6

Browse files
Merge pull request openshift#380 from grokspawn/opm-semver-veneer-error-msg
OCPBUGS-1004: dump descriptive source info on error instead of the source data (openshift#1021)
2 parents 208ce9a + bdfd23e commit 97782e6

File tree

2 files changed

+26
-10
lines changed
  • staging/operator-registry/cmd/opm/alpha/veneer
  • vendor/github.com/operator-framework/operator-registry/cmd/opm/alpha/veneer

2 files changed

+26
-10
lines changed

staging/operator-registry/cmd/opm/alpha/veneer/semver.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func newSemverCmd() *cobra.Command {
2727
// When no arguments or "-" is passed to the command,
2828
// assume input is coming from stdin
2929
// Otherwise open the file passed to the command
30-
data, err := openFileOrReadStdin(cmd, args)
30+
data, source, err := openFileOrReadStdin(cmd, args)
3131
if err != nil {
3232
return err
3333
}
@@ -64,7 +64,7 @@ func newSemverCmd() *cobra.Command {
6464
}
6565
out, err := veneer.Render(cmd.Context())
6666
if err != nil {
67-
log.Fatalf("semver %q: %v", data, err)
67+
log.Fatalf("semver %q: %v", source, err)
6868
}
6969

7070
if out != nil {
@@ -81,9 +81,17 @@ func newSemverCmd() *cobra.Command {
8181
return cmd
8282
}
8383

84-
func openFileOrReadStdin(cmd *cobra.Command, args []string) (io.Reader, error) {
84+
func openFileOrReadStdin(cmd *cobra.Command, args []string) (io.Reader, string, error) {
85+
var err error = nil
86+
var source string = ""
87+
var reader io.Reader
88+
8589
if len(args) == 0 || args[0] == "-" {
86-
return cmd.InOrStdin(), nil
90+
reader = cmd.InOrStdin()
91+
source = "stdin"
92+
} else {
93+
reader, err = os.Open(args[0])
94+
source = args[0]
8795
}
88-
return os.Open(args[0])
96+
return reader, source, err
8997
}

vendor/github.com/operator-framework/operator-registry/cmd/opm/alpha/veneer/semver.go

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)