diff options
Diffstat (limited to 'repository/config.go')
-rw-r--r-- | repository/config.go | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/repository/config.go b/repository/config.go index 70f11081..ec5094e0 100644 --- a/repository/config.go +++ b/repository/config.go @@ -1,11 +1,20 @@ package repository -import "time" +import ( + "strconv" + "time" +) // Config represent the common function interacting with the repository config storage type Config interface { - // Store writes a single key/value pair in the config of the repo - Store(key string, value string) error + // Store writes a single key/value pair in the config + StoreString(key, value string) error + + // Store writes a key and timestamp value to the config + StoreTimestamp(key string, value time.Time) error + + // Store writes a key and boolean value to the config + StoreBool(key string, value bool) error // ReadAll reads all key/value pair matching the key prefix ReadAll(keyPrefix string) (map[string]string, error) @@ -28,3 +37,13 @@ type Config interface { // RemoveAll removes all key/value pair matching the key prefix RemoveAll(keyPrefix string) error } + +func parseTimestamp(s string) (*time.Time, error) { + timestamp, err := strconv.Atoi(s) + if err != nil { + return nil, err + } + + t := time.Unix(int64(timestamp), 0) + return &t, nil +} |