Skip to content

Commit

Permalink
backport of commit fb9324c (#20514)
Browse files Browse the repository at this point in the history
Co-authored-by: Hamid Ghaf <83242695+hghaf099@users.noreply.github.com>
  • Loading branch information
1 parent da7618a commit 17e127d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog/20477.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cli: CLI should take days as a unit of time for ttl like flags
```
4 changes: 2 additions & 2 deletions command/base_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ type DurationVar struct {
func (f *FlagSet) DurationVar(i *DurationVar) {
initial := i.Default
if v, exist := os.LookupEnv(i.EnvVar); exist {
if d, err := time.ParseDuration(appendDurationSuffix(v)); err == nil {
if d, err := parseutil.ParseDurationSecond(v); err == nil {
initial = d
}
}
Expand Down Expand Up @@ -631,7 +631,7 @@ func (d *durationValue) Set(s string) error {
s = "-1"
}

v, err := time.ParseDuration(appendDurationSuffix(s))
v, err := parseutil.ParseDurationSecond(s)
if err != nil {
return err
}
Expand Down
6 changes: 6 additions & 0 deletions command/token_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ func TestTokenCreateCommand_Run(t *testing.T) {
"not present in secret",
1,
},
{
"ttl",
[]string{"-ttl", "1d", "-explicit-max-ttl", "2d"},
"token",
0,
},
}

t.Run("validations", func(t *testing.T) {
Expand Down

0 comments on commit 17e127d

Please sign in to comment.