Implement support for Chainguard Linux (#1198)

Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
This commit is contained in:
Dan Luhring 2023-03-28 10:52:33 -04:00 committed by GitHub
parent dfcce84cdb
commit 45c5f8c9c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 2 deletions

View file

@ -186,6 +186,10 @@ func Test_NamespaceForDistro(t *testing.T) {
version: "2022yzblah", // Wolfi is a rolling release
expected: "wolfi:rolling",
},
{
dist: distro.Chainguard,
expected: "chainguard:rolling",
},
}
observedDistros := strset.New()

View file

@ -133,6 +133,7 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
"ubuntu:distro:ubuntu:18.04",
"oracle:distro:oraclelinux:8",
"wolfi:distro:wolfi:rolling",
"chainguard:distro:chainguard:rolling",
"archlinux:distro:archlinux:rolling",
})
@ -267,6 +268,12 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
distro.NewNamespace("wolfi", osDistro.Wolfi, "rolling"),
},
},
{
distro: newDistro(t, osDistro.Chainguard, "20230214", []string{}),
namespaces: []*distro.Namespace{
distro.NewNamespace("chainguard", osDistro.Chainguard, "rolling"),
},
},
}
for _, test := range tests {

View file

@ -134,6 +134,7 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
"ubuntu:distro:ubuntu:18.04",
"oracle:distro:oraclelinux:8",
"wolfi:distro:wolfi:rolling",
"chainguard:distro:chainguard:rolling",
"archlinux:distro:archlinux:rolling",
})
@ -310,6 +311,14 @@ func TestIndex_NamespacesForDistro(t *testing.T) {
distro.NewNamespace("wolfi", osDistro.Wolfi, "rolling"),
},
},
{
name: "Chainguard matches chainguard rolling namespace",
distro: newDistro(t, osDistro.Chainguard, "20230214", []string{}),
namespaces: []*distro.Namespace{
distro.NewNamespace("chainguard", osDistro.Chainguard, "rolling"),
},
},
{
name: "Gentoo doesn't match any namespace since the gentoo rolling namespace doesn't exist in index",

View file

@ -87,7 +87,7 @@ func (d Distro) String() string {
}
func (d Distro) IsRolling() bool {
return d.Type == Wolfi || d.Type == ArchLinux || d.Type == Gentoo
return d.Type == Wolfi || d.Type == Chainguard || d.Type == ArchLinux || d.Type == Gentoo
}
// Unsupported Linux distributions

View file

@ -208,6 +208,10 @@ func Test_NewDistroFromRelease_Coverage(t *testing.T) {
fixture: "test-fixtures/os/wolfi",
Type: Wolfi,
},
{
fixture: "test-fixtures/os/chainguard",
Type: Chainguard,
},
}
observedDistros := internal.NewStringSet()
@ -243,7 +247,6 @@ func Test_NewDistroFromRelease_Coverage(t *testing.T) {
if test.Version != "" {
assert.Equal(t, d.Version.String(), test.Version)
}
})
}

View file

@ -0,0 +1,5 @@
ID=chainguard
NAME="Chainguard"
PRETTY_NAME="Chainguard"
VERSION_ID="20230214"
HOME_URL="https://chainguard.dev/"

View file

@ -29,6 +29,7 @@ const (
AlmaLinux Type = "almalinux"
Gentoo Type = "gentoo"
Wolfi Type = "wolfi"
Chainguard Type = "chainguard"
)
// All contains all Linux distribution options
@ -52,6 +53,7 @@ var All = []Type{
AlmaLinux,
Gentoo,
Wolfi,
Chainguard,
}
// IDMapping connects a distro ID like "ubuntu" to a Distro type
@ -75,6 +77,7 @@ var IDMapping = map[string]Type{
"almalinux": AlmaLinux,
"gentoo": Gentoo,
"wolfi": Wolfi,
"chainguard": Chainguard,
}
func TypeFromRelease(release linux.Release) Type {