mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-07-19 10:36:47 +00:00
* 🌱 Add webui Signed-off-by: mudler <mudler@c3os.io> * 🌱 Re-read config files after loading bundles Signed-off-by: mudler <mudler@c3os.io> * [check-spelling] Update metadata Update for https://github.com/kairos-io/kairos/actions/runs/3806058276/attempts/1 Accepted in https://github.com/kairos-io/kairos/pull/587#issuecomment-1367859480 Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com> Signed-off-by: mudler <mudler@c3os.io> * 🎨 Beautify index page Signed-off-by: mudler <mudler@c3os.io> * Do not rerun if we were successful or we are already running Signed-off-by: mudler <mudler@c3os.io> * Add syntax highlight Signed-off-by: mudler <mudler@c3os.io> * Add error message Signed-off-by: mudler <mudler@c3os.io> * Add YAML validation and highlight Signed-off-by: mudler <mudler@c3os.io> * Fixup terminal output Signed-off-by: mudler <mudler@c3os.io> * Fix newlines Signed-off-by: mudler <mudler@c3os.io> * fixups Signed-off-by: mudler <mudler@c3os.io> * 🎨 Fixup lint issues Signed-off-by: mudler <mudler@c3os.io> * Mark dependencies Signed-off-by: mudler <mudler@c3os.io> * Let configure the listening address Signed-off-by: mudler <mudler@c3os.io> Signed-off-by: mudler <mudler@c3os.io> Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
71 lines
1.5 KiB
Go
71 lines
1.5 KiB
Go
package agent
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/kairos-io/kairos/internal/kairos"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type BrandingText struct {
|
|
InteractiveInstall string `yaml:"interactive-install"`
|
|
Install string `yaml:"install"`
|
|
Reset string `yaml:"reset"`
|
|
Recovery string `yaml:"recovery"`
|
|
}
|
|
type WebUI struct {
|
|
Disable bool `yaml:"disable"`
|
|
ListenAddress string `yaml:"listen_address"`
|
|
}
|
|
type Config struct {
|
|
Fast bool `yaml:"fast,omitempty"`
|
|
WebUI WebUI `yaml:"webui"`
|
|
Branding BrandingText `yaml:"branding"`
|
|
}
|
|
|
|
func LoadConfig(path ...string) (*Config, error) {
|
|
if len(path) == 0 {
|
|
path = append(path, "/etc/kairos/agent.yaml", "/etc/elemental/config.yaml")
|
|
}
|
|
|
|
cfg := &Config{}
|
|
|
|
for _, p := range path {
|
|
f, err := os.ReadFile(p)
|
|
if err == nil {
|
|
yaml.Unmarshal(f, cfg) //nolint:errcheck
|
|
}
|
|
}
|
|
|
|
if cfg.Branding.InteractiveInstall == "" {
|
|
f, err := os.ReadFile(kairos.BrandingFile("interactive_install_text"))
|
|
if err == nil {
|
|
cfg.Branding.InteractiveInstall = string(f)
|
|
}
|
|
}
|
|
|
|
if cfg.Branding.Install == "" {
|
|
f, err := os.ReadFile(kairos.BrandingFile("install_text"))
|
|
if err == nil {
|
|
cfg.Branding.Install = string(f)
|
|
}
|
|
}
|
|
|
|
if cfg.Branding.Recovery == "" {
|
|
f, err := os.ReadFile(kairos.BrandingFile("recovery_text"))
|
|
if err == nil {
|
|
cfg.Branding.Recovery = string(f)
|
|
}
|
|
}
|
|
|
|
if cfg.Branding.Reset == "" {
|
|
f, err := os.ReadFile(kairos.BrandingFile("reset_text"))
|
|
if err == nil {
|
|
cfg.Branding.Reset = string(f)
|
|
}
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|