Skip to content

Commit

Permalink
Fix for operator-single-crd-owner test case. (#2603)
Browse files Browse the repository at this point in the history
As stated in issue
#2593 ,
the test case operator-single-crd-owner might produce false positives.

The original implementation didn't handle cases where a single CRD name
can have more than one version.
  • Loading branch information
greyerof authored Dec 3, 2024
1 parent 4661a84 commit d6482e5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/operator/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,19 @@ func testOperatorSingleCrdOwner(check *checksdb.Check, env *provider.TestEnviron
for i := range env.Operators {
operator := env.Operators[i]
ownedCrds := operator.Csv.Spec.CustomResourceDefinitions.Owned

// Helper map to filter out different versions of the same CRD name.
uniqueOnwnedCrds := map[string]struct{}{}
for j := range ownedCrds {
crdOwners[ownedCrds[j].Name] = append(crdOwners[ownedCrds[j].Name], operator.Name)
uniqueOnwnedCrds[ownedCrds[j].Name] = struct{}{}
}

// Now we can append the operator as CRD owner
for crdName := range uniqueOnwnedCrds {
crdOwners[crdName] = append(crdOwners[crdName], operator.Name)
}

check.LogInfo("CRDs owned by operator %s: %+v", operator.Name, uniqueOnwnedCrds)
}

// Flag those that are owned by more than one operator
Expand Down

0 comments on commit d6482e5

Please sign in to comment.