Skip to content

Commit

Permalink
CLI to take days as a unit of time (hashicorp#20477)
Browse files Browse the repository at this point in the history
* CLI to take days as a unit of time

* CL
  • Loading branch information
hghaf099 committed May 4, 2023
1 parent b81a94b commit fb9324c
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 @@ -594,7 +594,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 @@ -634,7 +634,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 @@ -71,6 +71,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 fb9324c

Please sign in to comment.