From e29c77bff38de15f00d5c7d1ad5a3fc30f9840db Mon Sep 17 00:00:00 2001 From: Charlie Drage Date: Mon, 4 Jul 2016 17:24:32 -0400 Subject: [PATCH] Add VARIANT and VARIANT_ID to os-release In order to provision different variant types such as embedded and server releases, it's required to grep the VARIANT and VARIANT_ID variables of os-release. Specifically from this commit: https://pagure.io/fork/sgallagh/fedora-release/c/56267336c738f80e3e7a344c740b5d02730c76c6 Which adds the VARIANT_ID="atomic.host" in order to differentiate between Fedora Server and container-centric Atomic Host releases. This commit adds the accessability of VARIANT and VARIANT_ID in order for Docker Machine to successfully provision different variants of Fedora releases. Signed-off-by: Charlie Drage --- libmachine/provision/os_release.go | 2 ++ libmachine/provision/os_release_test.go | 34 ++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/libmachine/provision/os_release.go b/libmachine/provision/os_release.go index 363495f56f..4c3bdf2a13 100644 --- a/libmachine/provision/os_release.go +++ b/libmachine/provision/os_release.go @@ -20,6 +20,8 @@ type OsRelease struct { AnsiColor string `osr:"ANSI_COLOR"` Name string `osr:"NAME"` Version string `osr:"VERSION"` + Variant string `osr:"VARIANT"` + VariantID string `osr:"VARIANT_ID"` ID string `osr:"ID"` IDLike string `osr:"ID_LIKE"` PrettyName string `osr:"PRETTY_NAME"` diff --git a/libmachine/provision/os_release_test.go b/libmachine/provision/os_release_test.go index eb4d35093e..87ffefd54d 100644 --- a/libmachine/provision/os_release_test.go +++ b/libmachine/provision/os_release_test.go @@ -46,7 +46,17 @@ PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" - +`) + fedora = []byte(`NAME=Fedora +VERSION="23 (Twenty Three)" +ID=fedora +VERSION_ID=23 +VARIANT="Server Edition" +VARIANT_ID=server +PRETTY_NAME="Fedora 23 (Twenty Three)" +ANSI_COLOR="0;34" +HOME_URL="https://fedoraproject.org/" +BUG_REPORT_URL="https://bugzilla.redhat.com/" `) ) @@ -136,6 +146,28 @@ BUG_REPORT_URL="https://bugs.centos.org/" if !reflect.DeepEqual(*osr, expectedOsr) { t.Fatal("Error with centos osr parsing: structs do not match") } + + osr, err = NewOsRelease(fedora) + if err != nil { + t.Fatalf("Unexpected error parsing os release: %s", err) + } + + expectedOsr = OsRelease{ + Name: "Fedora", + Version: "23 (Twenty Three)", + ID: "fedora", + PrettyName: "Fedora 23 (Twenty Three)", + Variant: "Server Edition", + VariantID: "server", + AnsiColor: "0;34", + VersionID: "23", + HomeURL: "https://fedoraproject.org/", + BugReportURL: "https://bugzilla.redhat.com/", + } + + if !reflect.DeepEqual(*osr, expectedOsr) { + t.Fatal("Error with fedora osr parsing: structs do not match") + } } func TestParseLine(t *testing.T) {