Skip to content

Commit a116104

Browse files
oceanc80grokspawn
authored andcommitted
Addressing additional feedback from PR 1015 (#1017)
Signed-off-by: Catherine Chan-Tse <[email protected]> Upstream-commit: 856f0bcd161dfb420cabdc8b2896f78f49dbb3d4 Upstream-repository: operator-registry
1 parent c28533b commit a116104

File tree

4 files changed

+61
-36
lines changed

4 files changed

+61
-36
lines changed

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,13 @@ func newSemverCmd() *cobra.Command {
2323
Long: "Generate a file-based catalog from a single 'semver veneer' file \nWhen FILE is '-' or not provided, the veneer is read from standard input",
2424
Args: cobra.MaximumNArgs(1),
2525
RunE: func(cmd *cobra.Command, args []string) error {
26-
var (
27-
data io.Reader
28-
err error
29-
)
30-
3126
// Handle different input argument types
32-
if len(args) == 0 || args[0] == "-" {
33-
// When no arguments or "-" is passed to the command,
34-
// assume input is coming from stdin
35-
data = cmd.InOrStdin()
36-
} else {
37-
// Otherwise open the file passed to the command
38-
data, err = os.Open(args[0])
39-
if err != nil {
40-
return err
41-
}
27+
// When no arguments or "-" is passed to the command,
28+
// assume input is coming from stdin
29+
// Otherwise open the file passed to the command
30+
data, err := openFileOrReadStdin(cmd, args)
31+
if err != nil {
32+
return err
4233
}
4334

4435
var write func(declcfg.DeclarativeConfig, io.Writer) error
@@ -86,3 +77,10 @@ func newSemverCmd() *cobra.Command {
8677
cmd.Flags().StringVarP(&output, "output", "o", "json", "Output format (json|yaml|mermaid)")
8778
return cmd
8879
}
80+
81+
func openFileOrReadStdin(cmd *cobra.Command, args []string) (io.Reader, error) {
82+
if len(args) == 0 || args[0] == "-" {
83+
return cmd.InOrStdin(), nil
84+
}
85+
return os.Open(args[0])
86+
}

vendor/github.com/operator-framework/operator-registry/alpha/veneer/semver/README.md

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

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

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

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

0 commit comments

Comments
 (0)