Headscale: Sync users and update ACLs
Change-Id: Ie3488f6296567f5e2301476912d79de845299708
diff --git a/core/headscale/client.go b/core/headscale/client.go
index edc36ff..ce82291 100644
--- a/core/headscale/client.go
+++ b/core/headscale/client.go
@@ -1,11 +1,14 @@
package main
import (
+ "errors"
"fmt"
"os/exec"
"strings"
)
+var ErrorAlreadyExists = errors.New("already exists")
+
type client struct {
config string
}
@@ -19,7 +22,10 @@
func (c *client) createUser(name string) error {
cmd := exec.Command("headscale", c.config, "users", "create", name)
out, err := cmd.Output()
- fmt.Println(string(out))
+ outStr := string(out)
+ if err != nil && strings.Contains(outStr, "User already exists") {
+ return ErrorAlreadyExists
+ }
return err
}