Skip to content

Commit

Permalink
fixes(HMS-4620): add RHEL 8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap authored and loadtheaccumulator committed Sep 10, 2024
1 parent f6f90be commit 3b3ce1c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
5 changes: 5 additions & 0 deletions config/repo_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
package config

// List of supported RHEL distributions
// See https://github.com/osbuild/image-builder/blob/main/internal/v1/api.yaml#L1083
// schema component Distributions
const distRHEL84 = "rhel-84"
const distRHEL85 = "rhel-85"
const distRHEL86 = "rhel-86"
const distRHEL87 = "rhel-87"
const distRHEL88 = "rhel-88"
const distRHEL89 = "rhel-89"
const distRHEL810 = "rhel-8.10"
const distRHEL90 = "rhel-90"
const distRHEL91 = "rhel-91"
const distRHEL92 = "rhel-92"
Expand Down Expand Up @@ -46,6 +49,7 @@ var DistributionsPackages = map[string][]string{
distRHEL87: RHEL8X,
distRHEL88: RHEL8X,
distRHEL89: RHEL8X,
distRHEL810: RHEL8X,
distRHEL90: RHEL9,
distRHEL91: RHEL9,
distRHEL92: RHEL9,
Expand All @@ -61,6 +65,7 @@ var DistributionsRefs = map[string]string{
distRHEL87: OstreeRefRHEL8,
distRHEL88: OstreeRefRHEL8,
distRHEL89: OstreeRefRHEL8,
distRHEL810: OstreeRefRHEL8,
distRHEL90: OstreeRefRHEL9,
distRHEL91: OstreeRefRHEL9,
distRHEL92: OstreeRefRHEL9,
Expand Down
29 changes: 21 additions & 8 deletions config/repo_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,41 @@
package config

import (
"regexp"
"strings"
"testing"
)

// Validate distribution ref values should return refs by distribution"
func TestValidateRepo(t *testing.T) {
// matches rhel-80 format and rhel-8.10 format
dre := regexp.MustCompile(`(?P<dist>rhel)-((?P<maj>\d)(?P<min>\d)|(?P<maj>\d+)\.(?P<min>\d+))`)
for key, d := range DistributionsRefs {
// match the distro string
match := dre.FindSubmatch([]byte(key))
if match == nil {
t.Errorf("%s does not match the requested pattern", key)
return
}

dist := strings.Split(key, "-")
distribution := dist[0]
version := strings.Split(dist[1], "")
majorVersion := strings.Join(version[:len(version)-1], "")
// construct a map of groups: dist, maj, min
grp := make(map[string]string)
for i, name := range dre.SubexpNames() {
if i != 0 && name != "" {
grp[name] = string(match[i])
}
}

// validate
t.Run("validate distribution", func(t *testing.T) {
if !strings.Contains(DistributionsRefs[key], distribution) {
t.Errorf(" %q not found: %q", distribution, DistributionsRefs[d])
if !strings.Contains(DistributionsRefs[key], grp["dist"]) {
t.Errorf(" %q not found: %q", grp["dist"], DistributionsRefs[d])
}
})

t.Run("validate major", func(t *testing.T) {
if !strings.Contains(DistributionsRefs[key], majorVersion) {
t.Errorf("%q not found: %q", majorVersion, DistributionsRefs[d])
if !strings.Contains(DistributionsRefs[key], grp["maj"]) {
t.Errorf("%q not found: %q", grp["maj"], DistributionsRefs[d])
}
})

Expand Down

0 comments on commit 3b3ce1c

Please sign in to comment.