Tesla Command: implement token storage (#12021)
This commit is contained in:
parent
7e37fb4a8f
commit
5627f57ebb
6 changed files with 203 additions and 46 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package settings
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"slices"
|
||||
|
|
@ -43,6 +44,18 @@ func Persist() error {
|
|||
return db.Instance.Save(settings).Error
|
||||
}
|
||||
|
||||
func All() []setting {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
|
||||
res := slices.Clone(settings)
|
||||
slices.SortFunc(res, func(i, j setting) int {
|
||||
return cmp.Compare(i.Key, j.Key)
|
||||
})
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func SetString(key string, val string) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue