add support for distro detection

Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
Alfredo Deza 2020-06-11 10:02:33 -04:00
parent f1851556a8
commit 56c2318ea1

View File

@ -3,41 +3,46 @@ package distro
const (
UnknownDistro Type = iota
Debian
// Ubuntu
// RedHat
// CentOS
Ubuntu
RedHat
CentOS
// Fedora
// Alpine
// Busybox
Busybox
// AmazonLinux
// OracleLinux
// ArchLinux
)
const (
// UnknownVersion is a default of 0.0.0 when it can't be parsed
UnknownVersion string = "0.0.0"
)
type Type int
var distroStr = []string{
"UnknownDistro",
"Debian",
// "Ubuntu",
// "RedHat",
// "CentOS",
// "Fedora",
// "Alpine",
// "Busybox",
// "AmazonLinux",
// "OracleLinux",
// "ArchLinux",
"debian",
"ubuntu",
"redhat",
"centos",
// "fedora",
// "alpine",
"busybox",
// "amazn",
// "oraclelinux",
// "archlinux",
}
var All = []Type{
Debian,
// Ubuntu,
// RedHat,
// CentOS,
Ubuntu,
RedHat,
CentOS,
// Fedora,
// Alpine,
// Busybox,
Busybox,
// AmazonLinux,
// OracleLinux,
// ArchLinux,
@ -50,3 +55,17 @@ func (t Type) String() string {
return distroStr[t]
}
// Mappings connects a distro ID like "ubuntu" to a Distro type
var Mappings = map[string]Type{
"debian": Debian,
"ubuntu": Ubuntu,
"rhel": RedHat,
"centos": CentOS,
// "fedora": Fedora,
// "alpine": Alpine,
"busybox": Busybox,
// "amazn": AmazonLinux,
// "oraclelinux": OracleLinux,
// "archlinux": ArchLinux,
}