Skip to content

Commit f0a4b9e

Browse files
authored
fix(args): empty time parsing (#3185)
1 parent 95798c4 commit f0a4b9e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/ghodss/yaml v1.0.0
1818
github.com/gorilla/websocket v1.5.0
1919
github.com/hashicorp/go-version v1.6.0
20-
github.com/karrick/tparse v2.4.2+incompatible
20+
github.com/karrick/tparse/v2 v2.8.2
2121
github.com/kubernetes-client/go-base v0.0.0-20190205182333-3d0e39759d98
2222
github.com/mattn/go-colorable v0.1.13
2323
github.com/mattn/go-isatty v0.0.19

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC
381381
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0=
382382
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
383383
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
384-
github.com/karrick/tparse v2.4.2+incompatible h1:+cW306qKAzrASC5XieHkgN7/vPaGKIuK62Q7nI7DIRc=
385-
github.com/karrick/tparse v2.4.2+incompatible/go.mod h1:ASPA+vrIcN1uEW6BZg8vfWbzm69ODPSYZPU6qJyfdK0=
384+
github.com/karrick/tparse/v2 v2.8.2 h1:NhvrrB7nXYa0VLn0JKn9L3oG/GZN+LB/+g5QfWE30rU=
385+
github.com/karrick/tparse/v2 v2.8.2/go.mod h1:OzmKMqNal7LYYHaO/Ie1f/wXmLWAaGKwJmxUFNQCVxg=
386386
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
387387
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
388388
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=

internal/args/unmarshal.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"time"
1515

1616
"github.com/dustin/go-humanize"
17-
"github.com/karrick/tparse"
17+
"github.com/karrick/tparse/v2"
1818
"github.com/scaleway/scaleway-sdk-go/scw"
1919
"github.com/scaleway/scaleway-sdk-go/strcase"
2020
)
@@ -69,6 +69,10 @@ var unmarshalFuncs = map[reflect.Type]UnmarshalFunc{
6969
return nil
7070
}
7171

72+
if len(value) == 0 {
73+
return fmt.Errorf("empty time given")
74+
}
75+
7276
// Handle relative time
7377
if value[0] != '+' && value[0] != '-' {
7478
value = "+" + value

0 commit comments

Comments
 (0)