From 56c2318ea19cb44ea01c528dc5552d6b3d7508b8 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 11 Jun 2020 10:02:33 -0400 Subject: [PATCH] add support for distro detection Signed-off-by: Alfredo Deza --- imgbom/distro/type.go | 55 +++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/imgbom/distro/type.go b/imgbom/distro/type.go index 49f1742b3..05f73ee83 100644 --- a/imgbom/distro/type.go +++ b/imgbom/distro/type.go @@ -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, +}