Skip to content

Commit 323f06e

Browse files
authored
Merge pull request #59 from Miouge1/ttl
Fix termination-time and possibility to use strtotime strings
2 parents efe3d51 + d33ea2c commit 323f06e

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.14
44

55
require (
66
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
7+
github.com/carmo-evan/strtotime v0.0.0-20200108203155-3136cf889e3b // indirect
78
github.com/docker/docker v0.0.0-20180805161158-f57f260b49b6 // indirect
89
github.com/docker/machine v0.16.2
910
github.com/google/go-cmp v0.3.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
22
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
3+
github.com/carmo-evan/strtotime v0.0.0-20200108203155-3136cf889e3b h1:U3vQoEOmB8zQ34LR8jQt6XMIdOiq49OZ1aPGjG1fJKE=
4+
github.com/carmo-evan/strtotime v0.0.0-20200108203155-3136cf889e3b/go.mod h1:IqY2NtbgybBNEdxOZLXCF/OAAisAOiB4+F7/ovbQN8M=
35
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
46
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
57
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

pkg/drivers/metal/metal.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strings"
1111
"time"
1212

13+
"github.com/carmo-evan/strtotime"
1314
"github.com/docker/machine/libmachine/drivers"
1415
"github.com/docker/machine/libmachine/log"
1516
"github.com/docker/machine/libmachine/mcnflag"
@@ -173,12 +174,14 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
173174
if TerminationTime == "" {
174175
d.TerminationTime = nil
175176
} else {
176-
layout := "2006-01-02T15:04:05.000Z"
177-
TerminationTime, err := time.Parse(layout, TerminationTime)
177+
Timestamp, err := strtotime.Parse(TerminationTime, time.Now().Unix())
178178
if err != nil {
179179
return err
180180
}
181-
d.TerminationTime.Time = TerminationTime
181+
if Timestamp <= time.Now().Unix() {
182+
return fmt.Errorf("--metal-termination-time cannot be in the past")
183+
}
184+
d.TerminationTime = &packngo.Timestamp{Time: time.Unix(Timestamp, 0)}
182185
}
183186
}
184187

@@ -267,6 +270,7 @@ func (d *Driver) Create() error {
267270
Tags: d.Tags,
268271
SpotInstance: d.SpotInstance,
269272
SpotPriceMax: d.SpotPriceMax,
273+
TerminationTime: d.TerminationTime,
270274
}
271275

272276
log.Info("Provisioning Equinix Metal server...")

0 commit comments

Comments
 (0)