mirror of
https://github.com/hashicorp/vault.git
synced 2026-06-09 00:33:28 -04:00
Allow Default for TimeDurationSecond values to be time.Duration (#6934)
This commit is contained in:
parent
6183eb4bf5
commit
9c68bf2a20
2 changed files with 7 additions and 0 deletions
|
|
@ -579,6 +579,8 @@ func (s *FieldSchema) DefaultOrZero() interface{} {
|
|||
return s.Type.Zero()
|
||||
}
|
||||
result = int(valInt64)
|
||||
case time.Duration:
|
||||
result = int(inp.Seconds())
|
||||
default:
|
||||
return s.Type.Zero()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -564,6 +564,11 @@ func TestFieldSchemaDefaultOrZero(t *testing.T) {
|
|||
60,
|
||||
},
|
||||
|
||||
"default duration time.Duration": {
|
||||
&FieldSchema{Type: TypeDurationSecond, Default: 60 * time.Second},
|
||||
60,
|
||||
},
|
||||
|
||||
"default duration not set": {
|
||||
&FieldSchema{Type: TypeDurationSecond},
|
||||
0,
|
||||
|
|
|
|||
Loading…
Reference in a new issue