Skip to content

Commit

Permalink
chore: fix cmpv service version match compDef with regexp (#8292)
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Rookie authored Oct 17, 2024
1 parent 6af7b76 commit c774152
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions controllers/apps/componentversion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,12 @@ func serviceVersionToCompDefinitions(ctx context.Context, cli client.Reader,

// compatibleServiceVersions4Definition returns all service versions that are compatible with specified component definition.
func compatibleServiceVersions4Definition(compDef *appsv1.ComponentDefinition, compVersion *appsv1.ComponentVersion) sets.Set[string] {
prefixMatch := func(prefix string) bool {
return strings.HasPrefix(compDef.Name, prefix)
match := func(pattern string) bool {
return component.PrefixOrRegexMatched(compDef.Name, pattern)
}
releases := make(map[string]bool, 0)
for _, rule := range compVersion.Spec.CompatibilityRules {
if slices.IndexFunc(rule.CompDefs, prefixMatch) >= 0 {
if slices.IndexFunc(rule.CompDefs, match) >= 0 {
for _, release := range rule.Releases {
releases[release] = true
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/component/component_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func checkNMergeImages(serviceVersion string, appsInDef, appsInVer map[string]ap
if len(ver.name) == 0 {
match, err := CompareServiceVersion(serviceVersion, def.version)
if err != nil {
def.err = err
def.err = fmt.Errorf("failed to compare service version (service version: %s, def version: %s): %w", serviceVersion, def.version, err)
}
if !match && def.required {
def.err = fmt.Errorf("no matched image found for container %s with required version %s", name, serviceVersion)
Expand Down

0 comments on commit c774152

Please sign in to comment.