Skip to content

Commit

Permalink
Merge pull request #1801 from deads2k/by-gate-14-filter-iou
Browse files Browse the repository at this point in the history
tighten up the useCRD interface
  • Loading branch information
openshift-merge-bot[bot] committed Mar 12, 2024
2 parents 16eec10 + 98c5970 commit ad26456
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
29 changes: 13 additions & 16 deletions tools/codegen/pkg/manifestmerge/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func (f *ClusterProfileFilter) UseManifest(data []byte) (bool, error) {
return forThisProfile, nil
}

func (f *ClusterProfileFilter) UseCRD(metadata crdForFeatureSet) (bool, error) {
return metadata.clusterProfile == f.clusterProfile, nil
func (f *ClusterProfileFilter) UseCRD(metadata crdForFeatureSet) bool {
return metadata.clusterProfile == f.clusterProfile
}

func (f *ClusterProfileFilter) String() string {
Expand Down Expand Up @@ -185,25 +185,22 @@ func (f *AndManifestFilter) String() string {
}

type CRDFilter interface {
UseCRD(metadata crdForFeatureSet) (bool, error)
UseCRD(metadata crdForFeatureSet) bool
}

type AndCRDFilter struct {
filters []CRDFilter
}

func (f *AndCRDFilter) UseCRD(metadata crdForFeatureSet) (bool, error) {
func (f *AndCRDFilter) UseCRD(metadata crdForFeatureSet) bool {
for _, curr := range f.filters {
ret, err := curr.UseCRD(metadata)
if err != nil {
return false, err
}
ret := curr.UseCRD(metadata)
if !ret {
return false, nil
return false
}
}

return true, nil
return true
}

func (f *AndCRDFilter) String() string {
Expand All @@ -228,8 +225,8 @@ func (f *FeatureSetFilter) UseManifest(data []byte) (bool, error) {
return forThisFeatureSet, nil
}

func (f *FeatureSetFilter) UseCRD(metadata crdForFeatureSet) (bool, error) {
return metadata.featureSet == f.featureSetName, nil
func (f *FeatureSetFilter) UseCRD(metadata crdForFeatureSet) bool {
return metadata.featureSet == f.featureSetName
}

func (f *FeatureSetFilter) String() string {
Expand All @@ -239,8 +236,8 @@ func (f *FeatureSetFilter) String() string {
type HasData struct {
}

func (f *HasData) UseCRD(metadata crdForFeatureSet) (bool, error) {
return metadata.noData == false, nil
func (f *HasData) UseCRD(metadata crdForFeatureSet) bool {
return metadata.noData == false
}

func (f *HasData) String() string {
Expand All @@ -254,8 +251,8 @@ func (f *Everything) UseManifest(data []byte) (bool, error) {
return true, nil
}

func (f *Everything) UseCRD(metadata crdForFeatureSet) (bool, error) {
return true, nil
func (f *Everything) UseCRD(metadata crdForFeatureSet) bool {
return true
}

func (f *Everything) String() string {
Expand Down
2 changes: 1 addition & 1 deletion tools/codegen/pkg/manifestmerge/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ func featureSetsFromCRDs(resultingCRDs []crdForFeatureSet) sets.String {
func filterCRDs(resultingCRDs []crdForFeatureSet, filter CRDFilter) []crdForFeatureSet {
ret := []crdForFeatureSet{}
for i, currCRD := range resultingCRDs {
if ok, _ := filter.UseCRD(currCRD); ok {
if ok := filter.UseCRD(currCRD); ok {
ret = append(ret, resultingCRDs[i])
}
}
Expand Down

0 comments on commit ad26456

Please sign in to comment.