feat: implement list of available distros
This commit is contained in:
@ -34,6 +34,10 @@ func (centos CentOS) ID() distro.ID {
|
||||
return distro.CentOS
|
||||
}
|
||||
|
||||
func (centos CentOS) Release() string {
|
||||
return centos.release
|
||||
}
|
||||
|
||||
func (centos CentOS) Equal(d distro.Distro) bool {
|
||||
return centos.release == d.Release && distro.CentOS == d.ID
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ func (d Debian) ID() distro.ID {
|
||||
return distro.Debian
|
||||
}
|
||||
|
||||
func (d Debian) Release() string {
|
||||
return d.release.String()
|
||||
}
|
||||
|
||||
func (d Debian) Equal(dd distro.Distro) bool {
|
||||
if dd.ID != distro.Debian {
|
||||
return false
|
||||
|
@ -9,6 +9,7 @@ var distros []distribution
|
||||
|
||||
type distribution interface {
|
||||
ID() ID
|
||||
Release() string
|
||||
Equal(Distro) bool
|
||||
Packages() (packages []string, err error)
|
||||
}
|
||||
@ -20,6 +21,20 @@ func Register(d distribution) {
|
||||
distros = append(distros, d)
|
||||
}
|
||||
|
||||
func List() (dds []Distro) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
for _, dd := range distros {
|
||||
dds = append(dds, Distro{
|
||||
ID: dd.ID(),
|
||||
Release: dd.Release(),
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
type Distro struct {
|
||||
ID ID
|
||||
Release string
|
||||
|
@ -34,6 +34,10 @@ func (ol OracleLinux) ID() distro.ID {
|
||||
return distro.OracleLinux
|
||||
}
|
||||
|
||||
func (ol OracleLinux) Release() string {
|
||||
return ol.release
|
||||
}
|
||||
|
||||
func (ol OracleLinux) Equal(d distro.Distro) bool {
|
||||
return ol.release == d.Release && distro.OracleLinux == d.ID
|
||||
}
|
||||
|
@ -40,6 +40,10 @@ func (u Ubuntu) ID() distro.ID {
|
||||
return distro.Ubuntu
|
||||
}
|
||||
|
||||
func (u Ubuntu) Release() string {
|
||||
return u.release
|
||||
}
|
||||
|
||||
func (u Ubuntu) Equal(d distro.Distro) bool {
|
||||
return u.release == d.Release && distro.Ubuntu == d.ID
|
||||
}
|
||||
|
Reference in New Issue
Block a user