Skip to content

Commit

Permalink
handle for versionprefix and custom provider names
Browse files Browse the repository at this point in the history
Signed-off-by: Dentrax <[email protected]>
  • Loading branch information
Dentrax committed Jul 15, 2024
1 parent 8f16499 commit ed92254
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
23 changes: 15 additions & 8 deletions pkg/lint/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,19 @@ var AllRules = func(l *Linter) Rules { //nolint:gocyclo
return fmt.Errorf("package is version streamed but package.version %s starts with different than given version stream %s", c.Package.Version, versionStream)
}

providesList := []string{
fmt.Sprintf("%s=%s-r%d", packageName, c.Package.Version, c.Package.Epoch),
fmt.Sprintf("%s=%s-r%d", packageName, versionStream, c.Package.Epoch),
fmt.Sprintf("%s=%s", packageName, c.Package.Version),
fmt.Sprintf("%s=%s", packageName, versionStream),
fmt.Sprintf("%s=%s.999", packageName, versionStream),
var providesList []string
addToProvidesList := func(key string) {
providesList = append(providesList, fmt.Sprintf("%s=%s-r%d", key, c.Package.Version, c.Package.Epoch))
providesList = append(providesList, fmt.Sprintf("%s=%s-r%d", key, versionStream, c.Package.Epoch))
providesList = append(providesList, fmt.Sprintf("%s=%s", key, c.Package.Version))
providesList = append(providesList, fmt.Sprintf("%s=%s", key, versionStream))
providesList = append(providesList, fmt.Sprintf("%s=%s.999", key, versionStream))
}
addToProvidesList(packageName)

// Some packages have different provides for package name, i.e. python-3 instead of python.
if majorMinor := strings.Split(versionStream, "."); len(majorMinor) > 1 {
addToProvidesList(fmt.Sprintf("%s-%s", packageName, majorMinor[0]))
}

anyMatch := false
Expand All @@ -489,7 +496,7 @@ var AllRules = func(l *Linter) Rules { //nolint:gocyclo
}

if c.Update.Enabled && !c.Update.Manual && c.Update.GitHubMonitor != nil {
prefixesToCheck := []string{"", "v", packageName, "release"}
prefixesToCheck := []string{"", "v", packageName, "release", strings.ReplaceAll(packageName, "-fips", ""), c.Update.GitHubMonitor.StripPrefix}
separators := []string{"", ".", "-", "_"}
versionsToCheck := []string{versionStream, strings.ReplaceAll(versionStream, ".", "-"), strings.ReplaceAll(versionStream, ".", "_")}

Expand All @@ -505,7 +512,7 @@ var AllRules = func(l *Linter) Rules { //nolint:gocyclo
}

if !slices.Contains(filtersToCheck, c.Update.GitHubMonitor.TagFilter) && !slices.Contains(filtersToCheck, c.Update.GitHubMonitor.TagFilterPrefix) {
return fmt.Errorf("package is version streamed but tag filter %s is missing on update.github", versionStream)
return fmt.Errorf("package is version streamed but tag filter %s is mismatch on update.github", versionStream)
}
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/lint/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func TestLinter_Rules(t *testing.T) {
Name: "valid-version-stream",
Severity: SeverityError,
},
Error: fmt.Errorf("[valid-version-stream]: package is version streamed but tag filter 1.2 is missing on update.github (ERROR)"),
Error: fmt.Errorf("[valid-version-stream]: package is version streamed but tag filter 1.2 is mismatch on update.github (ERROR)"),
},
},
},
Expand All @@ -444,7 +444,7 @@ func TestLinter_Rules(t *testing.T) {
Name: "valid-version-stream",
Severity: SeverityError,
},
Error: fmt.Errorf("[valid-version-stream]: package is version streamed but tag filter 1.2 is missing on update.github (ERROR)"),
Error: fmt.Errorf("[valid-version-stream]: package is version streamed but tag filter 1.2 is mismatch on update.github (ERROR)"),
},
},
},
Expand Down

0 comments on commit ed92254

Please sign in to comment.