mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-26 14:55:01 +00:00
Remove Unix() invocations on 'time.Time' objects and removed conversion of time to UTC
This commit is contained in:
@@ -450,9 +450,9 @@ func (b *Backend) handleWALRollback(
|
||||
if age == 0 {
|
||||
age = 10 * time.Minute
|
||||
}
|
||||
minAge := time.Now().UTC().Add(-1 * age)
|
||||
minAge := time.Now().Add(-1 * age)
|
||||
if _, ok := req.Data["immediate"]; ok {
|
||||
minAge = time.Now().UTC().Add(1000 * time.Hour)
|
||||
minAge = time.Now().Add(1000 * time.Hour)
|
||||
}
|
||||
|
||||
for _, k := range keys {
|
||||
@@ -466,7 +466,7 @@ func (b *Backend) handleWALRollback(
|
||||
}
|
||||
|
||||
// If the entry isn't old enough, then don't roll it back
|
||||
if !time.Unix(entry.CreatedAt, 0).Before(minAge) {
|
||||
if !entry.CreatedAt.Before(minAge) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ func TestBackendHandleRequest_renewExtend(t *testing.T) {
|
||||
}
|
||||
|
||||
req := logical.RenewRequest("/foo", secret.Response(nil, nil).Secret, nil)
|
||||
req.Secret.IssueTime = time.Now().UTC()
|
||||
req.Secret.IssueTime = time.Now()
|
||||
req.Secret.Increment = 1 * time.Hour
|
||||
resp, err := b.HandleRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -45,10 +45,10 @@ func LeaseExtend(backendIncrement, backendMax time.Duration, systemView logical.
|
||||
}
|
||||
|
||||
// We cannot go past this time
|
||||
maxValidTime := leaseOpts.IssueTime.UTC().Add(max)
|
||||
maxValidTime := leaseOpts.IssueTime.Add(max)
|
||||
|
||||
// Get the current time
|
||||
now := time.Now().UTC()
|
||||
now := time.Now()
|
||||
|
||||
// If we are past the max TTL, we shouldn't be in this function...but
|
||||
// fast path out if we are
|
||||
|
||||
@@ -14,7 +14,7 @@ func TestLeaseExtend(t *testing.T) {
|
||||
MaxLeaseTTLVal: 30 * time.Hour,
|
||||
}
|
||||
|
||||
now := time.Now().UTC().Round(time.Hour)
|
||||
now := time.Now().Round(time.Hour)
|
||||
|
||||
cases := map[string]struct {
|
||||
BackendDefault time.Duration
|
||||
|
||||
@@ -15,7 +15,7 @@ type WALEntry struct {
|
||||
ID string `json:"-"`
|
||||
Kind string `json:"type"`
|
||||
Data interface{} `json:"data"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// PutWAL writes some data to the WAL.
|
||||
@@ -37,7 +37,7 @@ func PutWAL(s logical.Storage, kind string, data interface{}) (string, error) {
|
||||
value, err := json.Marshal(&WALEntry{
|
||||
Kind: kind,
|
||||
Data: data,
|
||||
CreatedAt: time.Now().UTC().Unix(),
|
||||
CreatedAt: time.Now(),
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user