provider-kairos/internal/role/common.go
Oz Tiram 70903fdec8
🌱 add version information directly from git (#175)
Partial fix for https://github.com/kairos-io/kairos/issues/643

Signed-off-by: Oz Tiram <oz@spectrocloud.com>
2023-01-17 10:19:43 +01:00

35 lines
750 B
Go

package role
import (
"io/ioutil" // nolint
"os"
service "github.com/mudler/edgevpn/api/client/service"
)
type Role func(*service.RoleConfig) error
func SentinelExist() bool {
if _, err := os.Stat("/usr/local/.kairos/deployed"); err == nil {
return true
}
return false
}
func CreateSentinel() error {
return ioutil.WriteFile("/usr/local/.kairos/deployed", []byte{}, os.ModePerm)
}
func getRoles(client *service.Client, nodes []string) ([]string, map[string]string) {
unassignedNodes := []string{}
currentRoles := map[string]string{}
for _, a := range nodes {
role, _ := client.Get("role", a)
currentRoles[a] = role
if role == "" {
unassignedNodes = append(unassignedNodes, a)
}
}
return unassignedNodes, currentRoles
}