mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-19 00:52:36 +00:00
committed by
Itxaka
parent
bb73b8164c
commit
5bee05cccc
@@ -10,8 +10,8 @@ import (
|
||||
"unicode"
|
||||
|
||||
retry "github.com/avast/retry-go"
|
||||
"github.com/c3os-io/c3os/pkg/machine"
|
||||
"github.com/c3os-io/c3os/sdk/bundles"
|
||||
"github.com/kairos-io/kairos/pkg/machine"
|
||||
"github.com/kairos-io/kairos/sdk/bundles"
|
||||
yip "github.com/mudler/yip/pkg/schema"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
@@ -56,7 +56,7 @@ func HasHeader(userdata, head string) (bool, string) {
|
||||
if head != "" {
|
||||
return head == header, header
|
||||
}
|
||||
return (header == "#cloud-config") || (header == "#c3os-config") || (header == "#node-config"), header
|
||||
return (header == "#cloud-config") || (header == "#kairos-config") || (header == "#node-config"), header
|
||||
}
|
||||
|
||||
func (b Bundles) Options() (res [][]bundles.BundleOption) {
|
||||
|
@@ -20,24 +20,24 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
. "github.com/c3os-io/c3os/pkg/config"
|
||||
. "github.com/kairos-io/kairos/pkg/config"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
type TConfig struct {
|
||||
C3OS struct {
|
||||
Kairos struct {
|
||||
NetworkToken string `yaml:"network_token"`
|
||||
} `yaml:"c3os"`
|
||||
} `yaml:"kairos"`
|
||||
}
|
||||
|
||||
var _ = Describe("Get config", func() {
|
||||
Context("directory", func() {
|
||||
It("reads config file greedly", func() {
|
||||
|
||||
var cc string = `#c3os-config
|
||||
var cc string = `#kairos-config
|
||||
baz: bar
|
||||
c3os:
|
||||
kairos:
|
||||
network_token: foo
|
||||
`
|
||||
d, _ := ioutil.TempDir("", "xxxx")
|
||||
@@ -56,15 +56,15 @@ fooz:
|
||||
providerCfg := &TConfig{}
|
||||
err = c.Unmarshal(providerCfg)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(providerCfg.C3OS).ToNot(BeNil())
|
||||
Expect(providerCfg.C3OS.NetworkToken).To(Equal("foo"))
|
||||
Expect(providerCfg.Kairos).ToNot(BeNil())
|
||||
Expect(providerCfg.Kairos.NetworkToken).To(Equal("foo"))
|
||||
Expect(c.String()).To(Equal(cc))
|
||||
})
|
||||
|
||||
It("merges with bootargs", func() {
|
||||
|
||||
var cc string = `#c3os-config
|
||||
c3os:
|
||||
var cc string = `#kairos-config
|
||||
kairos:
|
||||
network_token: "foo"
|
||||
|
||||
bb:
|
||||
@@ -85,8 +85,8 @@ bb:
|
||||
providerCfg := &TConfig{}
|
||||
err = c.Unmarshal(providerCfg)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(providerCfg.C3OS).ToNot(BeNil())
|
||||
Expect(providerCfg.C3OS.NetworkToken).To(Equal("foo"))
|
||||
Expect(providerCfg.Kairos).ToNot(BeNil())
|
||||
Expect(providerCfg.Kairos.NetworkToken).To(Equal("foo"))
|
||||
_, exists := c.Data()["zz"]
|
||||
Expect(exists).To(BeFalse())
|
||||
})
|
||||
|
@@ -4,8 +4,8 @@ import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/c3os-io/c3os/sdk/unstructured"
|
||||
"github.com/google/shlex"
|
||||
"github.com/kairos-io/kairos/sdk/unstructured"
|
||||
)
|
||||
|
||||
func DotToYAML(file string) ([]byte, error) {
|
||||
|
@@ -4,7 +4,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
. "github.com/c3os-io/c3os/pkg/machine"
|
||||
. "github.com/kairos-io/kairos/pkg/machine"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
@@ -6,11 +6,11 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/c3os-io/c3os/pkg/machine/openrc"
|
||||
"github.com/c3os-io/c3os/pkg/machine/systemd"
|
||||
"github.com/denisbrodbeck/machineid"
|
||||
"github.com/kairos-io/kairos/pkg/machine/openrc"
|
||||
"github.com/kairos-io/kairos/pkg/machine/systemd"
|
||||
|
||||
"github.com/c3os-io/c3os/pkg/utils"
|
||||
"github.com/kairos-io/kairos/pkg/utils"
|
||||
)
|
||||
|
||||
type Service interface {
|
||||
@@ -117,11 +117,11 @@ func UUID() string {
|
||||
}
|
||||
|
||||
func CreateSentinel(f string) error {
|
||||
return ioutil.WriteFile(fmt.Sprintf("/usr/local/.c3os/sentinel_%s", f), []byte{}, os.ModePerm)
|
||||
return ioutil.WriteFile(fmt.Sprintf("/usr/local/.kairos/sentinel_%s", f), []byte{}, os.ModePerm)
|
||||
}
|
||||
|
||||
func SentinelExist(f string) bool {
|
||||
if _, err := os.Stat(fmt.Sprintf("/usr/local/.c3os/sentinel_%s", f)); err == nil {
|
||||
if _, err := os.Stat(fmt.Sprintf("/usr/local/.kairos/sentinel_%s", f)); err == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/c3os-io/c3os/pkg/utils"
|
||||
"github.com/kairos-io/kairos/pkg/utils"
|
||||
)
|
||||
|
||||
type ServiceUnit struct {
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/c3os-io/c3os/pkg/utils"
|
||||
"github.com/kairos-io/kairos/pkg/utils"
|
||||
)
|
||||
|
||||
type ServiceUnit struct {
|
||||
|
@@ -27,9 +27,9 @@ func PowerOFF() {
|
||||
func Version() string {
|
||||
release, _ := godotenv.Read("/etc/os-release")
|
||||
v := release["VERSION"]
|
||||
v = strings.ReplaceAll(v, "+k3s1-c3OS", "-")
|
||||
v = strings.ReplaceAll(v, "+k3s-c3OS", "-")
|
||||
return strings.ReplaceAll(v, "c3OS", "")
|
||||
v = strings.ReplaceAll(v, "+k3s1-Kairos", "-")
|
||||
v = strings.ReplaceAll(v, "+k3s-Kairos", "-")
|
||||
return strings.ReplaceAll(v, "Kairos", "")
|
||||
}
|
||||
|
||||
func OSRelease(key string) (string, error) {
|
||||
@@ -47,7 +47,7 @@ func OSRelease(key string) (string, error) {
|
||||
func Flavor() string {
|
||||
release, _ := godotenv.Read("/etc/os-release")
|
||||
v := release["NAME"]
|
||||
return strings.ReplaceAll(v, "c3os-", "")
|
||||
return strings.ReplaceAll(v, "kairos-", "")
|
||||
}
|
||||
|
||||
func IsOpenRCBased() bool {
|
||||
|
Reference in New Issue
Block a user