feat: add entry's fields Create and LastUpdate
This commit is contained in:
parent
48a47144a1
commit
be8d5dfe60
3 changed files with 15 additions and 8 deletions
|
@ -10,6 +10,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
|
|||
### Added
|
||||
|
||||
- Test build with travis
|
||||
- Add entry's fields Create and LastUpdate
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
18
gpm/entry.go
18
gpm/entry.go
|
@ -24,14 +24,16 @@ import(
|
|||
|
||||
// Entry struct have the password informations
|
||||
type Entry struct {
|
||||
Name string `yaml:"name"`
|
||||
ID string `yaml:"id"`
|
||||
URI string `yaml:"uri"`
|
||||
User string `yaml:"login"`
|
||||
Password string `yaml:"password"`
|
||||
OTP string `yaml:"otp"`
|
||||
Group string `yaml:"group"`
|
||||
Comment string `yaml:"comment"`
|
||||
Name string
|
||||
ID string
|
||||
URI string
|
||||
User string
|
||||
Password string
|
||||
OTP string
|
||||
Group string
|
||||
Comment string
|
||||
Create int64
|
||||
LastUpdate int64
|
||||
}
|
||||
|
||||
// Verify if the item have'nt error
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"math/rand"
|
||||
"os"
|
||||
"regexp"
|
||||
"time"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
@ -151,6 +152,8 @@ func (w *Wallet) AddEntry(entry Entry) error {
|
|||
return fmt.Errorf("the id already exists in wallet, can't add the entry")
|
||||
}
|
||||
|
||||
entry.Create = time.Now().Unix()
|
||||
entry.LastUpdate = entry.Create
|
||||
w.Entries = append(w.Entries, entry)
|
||||
|
||||
return nil
|
||||
|
@ -180,6 +183,7 @@ func (w *Wallet) UpdateEntry(entry Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
entry.LastUpdate = time.Now().Unix()
|
||||
for index, i := range w.Entries {
|
||||
if entry.ID == i.ID {
|
||||
w.Entries[index] = entry
|
||||
|
|
Loading…
Reference in a new issue