Skip to content
Snippets Groups Projects
Commit 8246c2c5 authored by Tomasz Maczukin's avatar Tomasz Maczukin
Browse files

Merge branch 'amzn-os-release' into 'main'

add CPE_NAME in OsRelease to support Amazon Linux 2

Closes #66

See merge request gitlab-org/ci-cd/docker-machine!82
parents 1b436f08 b84e7ffe
Branches
Tags
No related merge requests found
...@@ -29,6 +29,7 @@ type OsRelease struct { ...@@ -29,6 +29,7 @@ type OsRelease struct {
HomeURL string `osr:"HOME_URL"` HomeURL string `osr:"HOME_URL"`
SupportURL string `osr:"SUPPORT_URL"` SupportURL string `osr:"SUPPORT_URL"`
BugReportURL string `osr:"BUG_REPORT_URL"` BugReportURL string `osr:"BUG_REPORT_URL"`
CPEName string `osr:"CPE_NAME"`
} }
func stripQuotes(val string) string { func stripQuotes(val string) string {
......
...@@ -58,6 +58,15 @@ ANSI_COLOR="0;34" ...@@ -58,6 +58,15 @@ ANSI_COLOR="0;34"
HOME_URL="https://fedoraproject.org/" HOME_URL="https://fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/" BUG_REPORT_URL="https://bugzilla.redhat.com/"
`) `)
amzn2 = []byte(`NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"`)
) )
osr, err := NewOsRelease(ubuntuTrusty) osr, err := NewOsRelease(ubuntuTrusty)
...@@ -168,6 +177,28 @@ BUG_REPORT_URL="https://bugzilla.redhat.com/" ...@@ -168,6 +177,28 @@ BUG_REPORT_URL="https://bugzilla.redhat.com/"
if !reflect.DeepEqual(*osr, expectedOsr) { if !reflect.DeepEqual(*osr, expectedOsr) {
t.Fatal("Error with fedora osr parsing: structs do not match") t.Fatal("Error with fedora osr parsing: structs do not match")
} }
osr, err = NewOsRelease(amzn2)
if err != nil {
t.Fatalf("Unexpected error parsing os release: %s", err)
}
expectedOsr = OsRelease{
Name: "Amazon Linux",
Version: "2",
ID: "amzn",
IDLike: "centos rhel fedora",
VersionID: "2",
PrettyName: "Amazon Linux 2",
AnsiColor: "0;33",
CPEName: "cpe:2.3:o:amazon:amazon_linux:2",
HomeURL: "https://amazonlinux.com/",
}
if !reflect.DeepEqual(*osr, expectedOsr) {
t.Fatal("Error with amazon linux osr parsing: structs do not match")
}
} }
func TestParseLine(t *testing.T) { func TestParseLine(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment