Skip to content

Commit a0782e3

Browse files
authored
internal/pkg/scaffold/olm-catalog/config.go: omit owned CRD's from CSV if no default CRD's dir (#1347)
* internal/pkg/scaffold/olm-catalog/config.go: omit owned CRD's from CSV if no default CRD's dir, with info msg * CHANGELOG.md: bug entry for omitting deploy/crds
1 parent faa70e3 commit a0782e3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
- In Helm-based operators, when a custom resource with a failing release is reverted back to a working state, the `ReleaseFailed` condition is now correctly removed. ([#1321](https://github.com/operator-framework/operator-sdk/pull/1321))
3030
- [`operator-sdk generate openapi`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#openapi) no longer overwrites CRD values derived from `+kubebuilder` annotations in Go API code. See issues ([#1212](https://github.com/operator-framework/operator-sdk/issues/1212)) and ([#1323](https://github.com/operator-framework/operator-sdk/issues/1323)) for discussion. ([#1278](https://github.com/operator-framework/operator-sdk/pull/1278))
31+
- Running [`operator-sdk gen-csv`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#gen-csv) on operators that do not have a CRDs directory, ex. `deploy/crds`, or do not have any [owned CRDs](https://github.com/operator-framework/operator-lifecycle-manager/blob/master/Documentation/design/building-your-csv.md#your-custom-resource-definitions), will not generate a "deploy/crds not found" error.
3132

3233
## v0.7.0
3334

internal/pkg/scaffold/olm-catalog/config.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/operator-framework/operator-sdk/internal/pkg/scaffold"
2424

2525
"github.com/ghodss/yaml"
26+
log "github.com/sirupsen/logrus"
2627
)
2728

2829
// CSVConfig is a configuration file for CSV composition. Its fields contain
@@ -78,10 +79,16 @@ func (c *CSVConfig) setFields() error {
7879

7980
if len(c.CRDCRPaths) == 0 {
8081
paths, err := getManifestPathsFromDir(scaffold.CRDsDir)
81-
if err != nil {
82+
if err != nil && !os.IsNotExist(err) {
8283
return err
8384
}
84-
c.CRDCRPaths = paths
85+
if os.IsNotExist(err) {
86+
log.Infof(`Default CRDs dir "%s" does not exist. Omitting field spec.customresourcedefinitions.owned from CSV.`, scaffold.CRDsDir)
87+
} else if len(paths) == 0 {
88+
log.Infof(`Default CRDs dir "%s" is empty. Omitting field spec.customresourcedefinitions.owned from CSV.`, scaffold.CRDsDir)
89+
} else {
90+
c.CRDCRPaths = paths
91+
}
8592
} else {
8693
// Allow user to specify a list of dirs to search. Avoid duplicate files.
8794
paths, seen := make([]string, 0), make(map[string]struct{})

0 commit comments

Comments
 (0)