Skip to content

Commit 3637f46

Browse files
author
Eric Stroczynski
authored
cmd/.../gen-csv.go: fix setting operatorName from config (#2297)
* cmd/.../gen-csv.go: set operatorName from config after CLI if empty * CHANGELOG.md: add bugfix
1 parent 92d78a2 commit 3637f46

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
### Bug Fixes
2626
- Fix issue faced in the Ansible based operators when `jmespath` queries are used because it was not installed. ([#2252](https://github.com/operator-framework/operator-sdk/pull/2252))
2727
- Fix scorecard behavior such that a CSV file is read correctly when `olm-deployed` is set to `true`. ([#2274](https://github.com/operator-framework/operator-sdk/pull/2274))
28+
- A CSV config's `operator-name` field will be used if `--operator-name` is not set. ([#2297](https://github.com/operator-framework/operator-sdk/pull/2297))
2829

2930
## v0.12.0
3031

cmd/operator-sdk/olmcatalog/gen-csv.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,17 @@ func genCSVFunc(cmd *cobra.Command, args []string) error {
9090

9191
log.Infof("Generating CSV manifest version %s", csvVersion)
9292

93+
csvCfg, err := catalog.GetCSVConfig(csvConfigPath)
94+
if err != nil {
95+
return err
96+
}
9397
if operatorName == "" {
94-
operatorName = filepath.Base(absProjectPath)
98+
// Use config operator name if not set by CLI, i.e. prefer CLI value over
99+
// config value.
100+
if operatorName = csvCfg.OperatorName; operatorName == "" {
101+
// Default to using project name if both are empty.
102+
operatorName = filepath.Base(absProjectPath)
103+
}
95104
}
96105

97106
s := &scaffold.Scaffold{}
@@ -101,7 +110,7 @@ func genCSVFunc(cmd *cobra.Command, args []string) error {
101110
ConfigFilePath: csvConfigPath,
102111
OperatorName: operatorName,
103112
}
104-
err := s.Execute(cfg,
113+
err = s.Execute(cfg,
105114
csv,
106115
&catalog.PackageManifest{
107116
CSVVersion: csvVersion,
@@ -120,11 +129,7 @@ func genCSVFunc(cmd *cobra.Command, args []string) error {
120129
if err != nil {
121130
return err
122131
}
123-
cfg, err := catalog.GetCSVConfig(csvConfigPath)
124-
if err != nil {
125-
return err
126-
}
127-
err = writeCRDsToDir(cfg.CRDCRPaths, filepath.Dir(input.Path))
132+
err = writeCRDsToDir(csvCfg.CRDCRPaths, filepath.Dir(input.Path))
128133
if err != nil {
129134
return err
130135
}

0 commit comments

Comments
 (0)