Skip to content

Commit

Permalink
fixed manual install not supporting configuration url
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Payne <jacob@spectrocloud.com>
  • Loading branch information
paynejacob committed Feb 24, 2023
1 parent 57193de commit de44ff1
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions internal/agent/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"encoding/json"
"errors"
"fmt"
"net/url"
"os"
"os/exec"
"path/filepath"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -63,28 +63,34 @@ func displayInfo(agentConfig *Config) {
}

func ManualInstall(c string, options map[string]string, strictValidations bool) error {
dat, err := os.ReadFile(c)
if err != nil {
return err
}
if _, err := url.Parse(c); err == nil {
f, err := os.CreateTemp(os.TempDir(), "kairos-install-*.yaml")
if err != nil {
return nil
}

dir, err := os.MkdirTemp("", "kairos-install")
if err != nil {
return err
}
defer os.RemoveAll(dir)
cfg := config.Config{
ConfigURL: c,
}
if err = yaml.NewEncoder(f).Encode(cfg); err != nil {
return err
}

if err := os.WriteFile(filepath.Join(dir, "config.yaml"), dat, 0600); err != nil {
return err
c = f.Name()

defer os.RemoveAll(f.Name())
}

cc, err := config.Scan(config.Directories(dir), config.MergeBootLine, config.StrictValidation(strictValidations))
cc, err := config.Scan(config.Directories(c), config.MergeBootLine, config.StrictValidation(strictValidations))
if err != nil {
return err
}

options["cc"] = cc.String()

if options["device"] == "" {
options["device"] = cc.Install.Device
}

return RunInstall(options)
}

Expand Down

0 comments on commit de44ff1

Please sign in to comment.