Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of CLI to take days as a unit of time into release/1.11.x #20512

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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