Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/dockerinstall/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ const (
DistroRaspbian = "raspbian"
DistroOSMC = "osmc"
DistroDebian = "debian"

// Debian release codenames.
CodenameTrixie = "trixie"
CodenameBookworm = "bookworm"
CodenameBullseye = "bullseye"
CodenameBuster = "buster"
CodenameStretch = "stretch"
CodenameJessie = "jessie"
)
12 changes: 6 additions & 6 deletions pkg/dockerinstall/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ func (d *Detector) mapDebianVersion(data []byte) string {
version = strings.Split(version, ".")[0]

versionMap := map[string]string{
"13": "trixie",
"12": "bookworm",
"11": "bullseye",
"10": "buster",
"9": "stretch",
"8": "jessie",
"13": CodenameTrixie,
"12": CodenameBookworm,
"11": CodenameBullseye,
"10": CodenameBuster,
"9": CodenameStretch,
"8": CodenameJessie,
}

if mapped, ok := versionMap[version]; ok {
Expand Down
24 changes: 12 additions & 12 deletions pkg/dockerinstall/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ VERSION_CODENAME=bookworm`

distro := s.detector.parseOSRelease(strings.NewReader(osRelease))
s.Equal(DistroDebian, distro.ID)
s.Equal("bookworm", distro.Version)
s.Equal(CodenameBookworm, distro.Version)
}

func (s *DetectorTestSuite) TestParseOSRelease_Debian() {
Expand All @@ -72,7 +72,7 @@ BUG_REPORT_URL="https://bugs.debian.org/"`

distro := s.detector.parseOSRelease(strings.NewReader(osRelease))
s.Equal(DistroDebian, distro.ID)
s.Equal("trixie", distro.Version, "Should extract VERSION_CODENAME, not VERSION_ID")
s.Equal(CodenameTrixie, distro.Version, "Should extract VERSION_CODENAME, not VERSION_ID")
s.False(isNumericVersion(distro.Version), "Version should be codename, not numeric")
}

Expand Down Expand Up @@ -127,14 +127,14 @@ func (s *DetectorTestSuite) TestMapDebianVersion() {
input string
expected string
}{
{"13\n", "trixie"},
{"12\n", "bookworm"},
{"11\n", "bullseye"},
{"10\n", "buster"},
{"9\n", "stretch"},
{"8\n", "jessie"},
{"12.5\n", "bookworm"},
{"11/sid\n", "bullseye"},
{"13\n", CodenameTrixie},
{"12\n", CodenameBookworm},
{"11\n", CodenameBullseye},
{"10\n", CodenameBuster},
{"9\n", CodenameStretch},
{"8\n", CodenameJessie},
{"12.5\n", CodenameBookworm},
{"11/sid\n", CodenameBullseye},
{"99\n", ""},
{"invalid\n", ""},
}
Expand All @@ -160,7 +160,7 @@ func (s *DetectorTestSuite) TestIsNumericVersion() {
{"11", true},
{"12.5", true},
{"jammy", false},
{"bookworm", false},
{CodenameBookworm, false},
{"focal", false},
{"", false},
{"1.2.3", true},
Expand All @@ -186,7 +186,7 @@ func (s *DetectorTestSuite) TestDistro_HasCodename() {
expected bool
}{
{&Distro{ID: DistroUbuntu, Version: "jammy"}, true},
{&Distro{ID: DistroDebian, Version: "bookworm"}, true},
{&Distro{ID: DistroDebian, Version: CodenameBookworm}, true},
{&Distro{ID: DistroUbuntu, Version: "22.04"}, false},
{&Distro{ID: DistroDebian, Version: "12"}, false},
{&Distro{ID: "fedora", Version: "39"}, false},
Expand Down
2 changes: 1 addition & 1 deletion pkg/dockerinstall/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *ValidatorTestSuite) TestCheckDeprecation_DeprecatedUbuntu_DryRun() {
func (s *ValidatorTestSuite) TestCheckDeprecation_DeprecatedDebian() {
s.opts.dryRun = true
validator := NewValidator(s.opts)
distro := &Distro{ID: "debian", Version: "stretch"}
distro := &Distro{ID: "debian", Version: CodenameStretch}
validator.CheckDeprecation(distro)
s.Contains(s.stdout.String(), "DEPRECATION WARNING")
s.Contains(s.stdout.String(), "debian stretch")
Expand Down
Loading