diff --git a/libmachine/provision/amazon2.go b/libmachine/provision/amazon2.go new file mode 100644 index 0000000000..34de8089cd --- /dev/null +++ b/libmachine/provision/amazon2.go @@ -0,0 +1,25 @@ +package provision + +import ( + "github.com/docker/machine/libmachine/drivers" +) + +func init() { + Register("Amazon2", &RegisteredProvisioner{ + New: NewAmazon2Provisioner, + }) +} + +func NewAmazon2Provisioner(d drivers.Driver) Provisioner { + return &Amazon2Provisioner{ + NewRedHatProvisioner("amazon2", d), + } +} + +type Amazon2Provisioner struct { + *RedHatProvisioner +} + +func (provisioner *Amazon2Provisioner) String() string { + return "amazon2" +} diff --git a/libmachine/provision/os_release_test.go b/libmachine/provision/os_release_test.go index 87ffefd54d..bf13afc79c 100644 --- a/libmachine/provision/os_release_test.go +++ b/libmachine/provision/os_release_test.go @@ -57,6 +57,17 @@ PRETTY_NAME="Fedora 23 (Twenty Three)" ANSI_COLOR="0;34" HOME_URL="https://fedoraproject.org/" BUG_REPORT_URL="https://bugzilla.redhat.com/" +`) + + amazon2 = []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/" `) ) @@ -168,6 +179,27 @@ BUG_REPORT_URL="https://bugzilla.redhat.com/" if !reflect.DeepEqual(*osr, expectedOsr) { t.Fatal("Error with fedora osr parsing: structs do not match") } + + osr, err = NewOsRelease(amazon2) + 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", + PrettyName: "Amazon Linux 2", + AnsiColor: "0;33", + VersionID: "2", + HomeURL: "https://amazonlinux.com/", + } + + if !reflect.DeepEqual(*osr, expectedOsr) { + t.Fatal("Error with amazon2 osr parsing: structs do not match") + } + } func TestParseLine(t *testing.T) {