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