Added communication between Serve and CLI using KV table (helps in #52)
This commit is contained in:
parent
b83ecc3e6e
commit
97f7c90092
5 changed files with 118 additions and 2 deletions
2
db.go
2
db.go
|
@ -79,6 +79,7 @@ func (h *Headscale) openDB() (*gorm.DB, error) {
|
|||
return db, nil
|
||||
}
|
||||
|
||||
// getValue returns the value for the given key in KV
|
||||
func (h *Headscale) getValue(key string) (string, error) {
|
||||
var row KV
|
||||
if result := h.db.First(&row, "key = ?", key); errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
|
@ -87,6 +88,7 @@ func (h *Headscale) getValue(key string) (string, error) {
|
|||
return row.Value, nil
|
||||
}
|
||||
|
||||
// setValue sets value for the given key in KV
|
||||
func (h *Headscale) setValue(key string, value string) error {
|
||||
kv := KV{
|
||||
Key: key,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue