Skip to content

Commit

Permalink
✨ handle version ranges (#93)
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
  • Loading branch information
pranavgaikwad committed Sep 26, 2023
1 parent 241f23d commit 085ca70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
19 changes: 6 additions & 13 deletions pkg/conversion/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,31 +232,24 @@ func getRulesetLabels(m windup.Metadata) []string {
labels = append(labels,
fmt.Sprintf("%s=%s%s", konveyor.SourceTechnologyLabel, sourceTech.Id, version))
}
if len(versions) == 0 {
labels = append(labels,
fmt.Sprintf("%s=%s", konveyor.SourceTechnologyLabel, sourceTech.Id))
}
labels = append(labels,
fmt.Sprintf("%s=%s", konveyor.SourceTechnologyLabel, sourceTech.Id))
}
for _, targetTech := range m.TargetTechnology {
versions := getVersionsFromMavenVersionRange(targetTech.VersionRange)
for _, version := range versions {
labels = append(labels,
fmt.Sprintf("%s=%s%s", konveyor.TargetTechnologyLabel, targetTech.Id, version))
}
if len(versions) == 0 {
labels = append(labels,
fmt.Sprintf("%s=%s", konveyor.TargetTechnologyLabel, targetTech.Id))
}
labels = append(labels,
fmt.Sprintf("%s=%s", konveyor.TargetTechnologyLabel, targetTech.Id))
}
if m.SourceTechnology == nil || len(m.SourceTechnology) == 0 {
labels = append(labels, konveyor.SourceTechnologyLabel)
}
if m.TargetTechnology == nil || len(m.TargetTechnology) == 0 {
labels = append(labels, konveyor.TargetTechnologyLabel)
}
if m.Phase != "" {
labels = append(labels, fmt.Sprintf("phase=%v", m.Phase))
}
// rulesets have <tags> too
labels = append(labels, m.Tag...)
return labels
Expand All @@ -280,10 +273,10 @@ func getVersionsFromMavenVersionRange(versionRange string) []string {
return []string{}
}
if minVersion == "" && match[2] != "" {
return []string{maxVersion}
return []string{fmt.Sprintf("%s-", maxVersion)}
}
if maxVersion == "" && match[2] != "" {
return []string{minVersion}
return []string{fmt.Sprintf("%s+", minVersion)}
}
minVerFloat, err := strconv.ParseFloat(minVersion, 64)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/conversion/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ func Test_parseMavenVersionRange(t *testing.T) {
{
name: "case 6",
verRange: "(,7]",
want: []string{"7"},
want: []string{"7-"},
},
{
name: "case 7",
verRange: "[6,)",
want: []string{"6"},
want: []string{"6+"},
},
{
name: "case 8",
Expand Down

0 comments on commit 085ca70

Please sign in to comment.