Skip to content

Commit

Permalink
chore: replace prefix match with compDefMatched
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei committed Dec 24, 2024
1 parent 5326a9f commit efd37a1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controllers/apps/componentversion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,12 @@ func serviceVersionToCompDefinitions(ctx context.Context, cli client.Reader,

// compatibleServiceVersions4Definition returns all service versions that are compatible with specified component definition.
func compatibleServiceVersions4Definition(compDef *appsv1alpha1.ComponentDefinition, compVersion *appsv1alpha1.ComponentVersion) sets.Set[string] {
prefixMatch := func(prefix string) bool {
return strings.HasPrefix(compDef.Name, prefix)
compDefMatched := func(compDefPattern string) bool {
return component.CompDefMatched(compDef.Name, compDefPattern)
}
releases := make(map[string]bool, 0)
for _, rule := range compVersion.Spec.CompatibilityRules {
if slices.IndexFunc(rule.CompDefs, prefixMatch) >= 0 {
if slices.IndexFunc(rule.CompDefs, compDefMatched) >= 0 {
for _, release := range rule.Releases {
releases[release] = true
}
Expand Down

0 comments on commit efd37a1

Please sign in to comment.