1
0

feat: use distro info to create the container

This commit is contained in:
2023-05-23 16:54:34 +00:00
parent f2ce20e53b
commit 7ca989fd8d
12 changed files with 130 additions and 150 deletions

View File

@ -15,18 +15,12 @@ func init() {
releases := []string{"6", "7", "8"}
for _, release := range releases {
container := "out_of_tree_centos_" + release
distro.Register(CentOS{
release: release,
container: container,
})
distro.Register(CentOS{release: release})
}
}
type CentOS struct {
release string
container string
release string
}
func (centos CentOS) Equal(d distro.Distro) bool {
@ -38,7 +32,7 @@ func (centos CentOS) Distro() distro.Distro {
}
func (centos CentOS) Packages() (pkgs []string, err error) {
c, err := container.New(centos.container)
c, err := container.New(centos.Distro())
if err != nil {
return
}

View File

@ -11,8 +11,7 @@ import (
func TestCentOS(t *testing.T) {
assert := assert.New(t)
u := CentOS{release: "7", container: "out_of_tree_centos_7"}
u := CentOS{release: "7"}
assert.True(u.Equal(distro.Distro{Release: "7", ID: distro.CentOS}))

View File

@ -29,18 +29,12 @@ func init() {
}
for _, release := range releases {
container := fmt.Sprintf("out_of_tree_debian_%d", release)
distro.Register(Debian{
release: release,
container: container,
})
distro.Register(Debian{release: release})
}
}
type Debian struct {
release Release
container string
release Release
}
func (d Debian) Equal(dd distro.Distro) bool {
@ -56,7 +50,7 @@ func (d Debian) Distro() distro.Distro {
}
func (d Debian) Packages() (packages []string, err error) {
c, err := container.New(d.container)
c, err := container.New(d.Distro())
if err != nil {
return
}

View File

@ -46,8 +46,7 @@ func TestKernelRelease(t *testing.T) {
func TestDebian(t *testing.T) {
assert := assert.New(t)
u := Debian{release: Wheezy, container: "out_of_tree_debian_7"}
u := Debian{release: Wheezy}
assert.True(u.Equal(distro.Distro{Release: "wheezy", ID: distro.Debian}))

View File

@ -15,18 +15,12 @@ func init() {
releases := []string{"6", "7", "8", "9"}
for _, release := range releases {
container := "out_of_tree_oraclelinux_" + release
distro.Register(OracleLinux{
release: release,
container: container,
})
distro.Register(OracleLinux{release: release})
}
}
type OracleLinux struct {
release string
container string
release string
}
func (ol OracleLinux) Equal(d distro.Distro) bool {
@ -38,7 +32,7 @@ func (ol OracleLinux) Distro() distro.Distro {
}
func (ol OracleLinux) Packages() (pkgs []string, err error) {
c, err := container.New(ol.container)
c, err := container.New(ol.Distro())
if err != nil {
return
}

View File

@ -11,8 +11,7 @@ import (
func TestOracleLinux(t *testing.T) {
assert := assert.New(t)
u := OracleLinux{release: "9", container: "out_of_tree_oraclelinux_9"}
u := OracleLinux{release: "9"}
assert.True(u.Equal(distro.Distro{Release: "9", ID: distro.OracleLinux}))

View File

@ -20,19 +20,12 @@ func init() {
}
for _, release := range releases {
container := "out_of_tree_ubuntu_" + release
container = strings.Replace(container, ".", "__", -1)
distro.Register(Ubuntu{
release: release,
container: container,
})
distro.Register(Ubuntu{release: release})
}
}
type Ubuntu struct {
release string
container string
release string
}
func (u Ubuntu) Equal(d distro.Distro) bool {
@ -44,7 +37,7 @@ func (u Ubuntu) Distro() distro.Distro {
}
func (u Ubuntu) Packages() (pkgs []string, err error) {
c, err := container.New(u.container)
c, err := container.New(u.Distro())
if err != nil {
return
}

View File

@ -11,7 +11,7 @@ import (
func TestUbuntu(t *testing.T) {
assert := assert.New(t)
u := Ubuntu{release: "22.04", container: "out_of_tree_ubuntu_22__04"}
u := Ubuntu{release: "22.04"}
assert.True(u.Equal(distro.Distro{Release: "22.04", ID: distro.Ubuntu}))