diff --git a/pkg/dockerinstall/constants.go b/pkg/dockerinstall/constants.go index a45e14bc6c..5c5462d0a4 100644 --- a/pkg/dockerinstall/constants.go +++ b/pkg/dockerinstall/constants.go @@ -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" ) diff --git a/pkg/dockerinstall/detector.go b/pkg/dockerinstall/detector.go index 14bc9c6724..3929efb8c9 100644 --- a/pkg/dockerinstall/detector.go +++ b/pkg/dockerinstall/detector.go @@ -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 { diff --git a/pkg/dockerinstall/detector_test.go b/pkg/dockerinstall/detector_test.go index 395629b2e5..1f9fe50b62 100644 --- a/pkg/dockerinstall/detector_test.go +++ b/pkg/dockerinstall/detector_test.go @@ -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() { @@ -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") } @@ -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", ""}, } @@ -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}, @@ -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}, diff --git a/pkg/dockerinstall/validator_test.go b/pkg/dockerinstall/validator_test.go index 3d26bdad57..724470f6c6 100644 --- a/pkg/dockerinstall/validator_test.go +++ b/pkg/dockerinstall/validator_test.go @@ -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")