mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-04-27 19:28:59 +00:00
* 🎨 Split off cli into separate binaries This commit splits off the cli into 3 binaries: - agent - cli - provider The provider now is a separate component that can be tested by itself and have its own lifecycle. This paves the way to a ligher c3os variant, HA support and other features that can be provided on runtime. This is working, but still there are low hanging fruit to care about. Fixes #14 * 🤖 Add provider bin to releases * ⚙️ Handle signals * ⚙️ Reduce buildsize footprint * 🎨 Scan for providers also in /system/providers * 🤖 Run goreleaser * 🎨 Refactoring
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
|
|
"github.com/c3os-io/c3os/internal/github"
|
|
"github.com/c3os-io/c3os/internal/utils"
|
|
)
|
|
|
|
func upgrade(version, image string, force bool) error {
|
|
if version == "" && image == "" {
|
|
githubRepo, err := utils.OSRelease("GITHUB_REPO")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
releases, _ := github.FindReleases(context.Background(), "", githubRepo)
|
|
version = releases[0]
|
|
fmt.Println("latest release is ", version)
|
|
}
|
|
|
|
if utils.Version() == version && !force {
|
|
fmt.Println("latest version already installed. use --force to force upgrade")
|
|
return nil
|
|
}
|
|
|
|
flavor := utils.Flavor()
|
|
if flavor == "" {
|
|
return errors.New("no flavor detected")
|
|
}
|
|
|
|
registry, err := utils.OSRelease("IMAGE_REPO")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
img := fmt.Sprintf("%s:%s-%s", registry, flavor, version)
|
|
if image != "" {
|
|
img = image
|
|
}
|
|
|
|
args := []string{"upgrade", "--system.uri", fmt.Sprintf("docker:%s", img)}
|
|
cmd := exec.Command("elemental", args...)
|
|
cmd.Env = os.Environ()
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stdin = os.Stdin
|
|
cmd.Stderr = os.Stderr
|
|
return cmd.Run()
|
|
}
|