diff --git a/.gitignore b/.gitignore index 8427f1b..960e42f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ bin/docker-machine-driver-* checksums +.idea/ + diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b61a86..f649cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.2.1] - 2020-02-24 +### Added +- Hardware reservation string argument to specift either an ID or 'next-available' + +## [0.2.0] - 2019-08-26 +### Added +- Replaced dependencies with go modules. +- Several fixes and tweaks. ## [0.1.5] - 2017-11-07 ### Added diff --git a/Makefile b/Makefile index f8733bb..59e2cfd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ default: build -version := v0.1.5 +version := v0.2.1 version_description := "Docker Machine Driver Plugin to Provision on Packet" human_name := "$(version) - Docker Machine v0.8.2+" version := "$(version)" diff --git a/driver.go b/driver.go index 42a12c7..48f1373 100644 --- a/driver.go +++ b/driver.go @@ -27,21 +27,22 @@ var _ drivers.Driver = &Driver{} type Driver struct { *drivers.BaseDriver - ApiKey string - ProjectID string - Plan string - Facility string - OperatingSystem string - BillingCycle string - DeviceID string - UserData string - Tags []string - CaCertPath string - SSHKeyID string - UserDataFile string - SpotInstance bool - SpotPriceMax float64 - TerminationTime *packngo.Timestamp + ApiKey string + ProjectID string + Plan string + HardwareReserverationID string + Facility string + OperatingSystem string + BillingCycle string + DeviceID string + UserData string + Tags []string + CaCertPath string + SSHKeyID string + UserDataFile string + SpotInstance bool + SpotPriceMax float64 + TerminationTime *packngo.Timestamp } // NewDriver is a backward compatible Driver factory method. Using @@ -85,6 +86,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { Value: "baremetal_0", EnvVar: "PACKET_PLAN", }, + mcnflag.StringFlag{ + Name: "packet-hw-reservation-id", + Usage: "Packet Reserved hardware ID", + EnvVar: "PACKET_HW_ID", + }, mcnflag.StringFlag{ Name: "packet-billing-cycle", Usage: "Packet billing cycle, hourly or monthly", @@ -134,6 +140,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { d.UserDataFile = flags.String("packet-userdata") d.Plan = flags.String("packet-plan") + d.HardwareReserverationID = flags.String("packet-hw-reservation-id") d.SpotInstance = flags.Bool("packet-spot-instance") @@ -228,18 +235,25 @@ func (d *Driver) Create() error { d.SSHKeyID = key.ID + hardwareReservationId := "" + //check if hardware reservation requested + if d.HardwareReserverationID != "" { + hardwareReservationId = d.HardwareReserverationID + } + client := d.getClient() createRequest := &packngo.DeviceCreateRequest{ - Hostname: d.MachineName, - Plan: d.Plan, - Facility: d.Facility, - OS: d.OperatingSystem, - BillingCycle: d.BillingCycle, - ProjectID: d.ProjectID, - UserData: userdata, - Tags: d.Tags, - SpotInstance: d.SpotInstance, - SpotPriceMax: -1, + Hostname: d.MachineName, + Plan: d.Plan, + HardwareReservationID: hardwareReservationId, + Facility: d.Facility, + OS: d.OperatingSystem, + BillingCycle: d.BillingCycle, + ProjectID: d.ProjectID, + UserData: userdata, + Tags: d.Tags, + SpotInstance: d.SpotInstance, + SpotPriceMax: -1, } log.Info("Provisioning Packet server...")