mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-08-27 20:39:22 +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
47 lines
859 B
Go
47 lines
859 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io/ioutil"
|
|
|
|
nodepair "github.com/mudler/go-nodepair"
|
|
qr "github.com/mudler/go-nodepair/qrcode"
|
|
)
|
|
|
|
func register(loglevel, arg, configFile, device string, reboot, poweroff bool) error {
|
|
b, _ := ioutil.ReadFile(configFile)
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
// dmesg -D to suppress tty ev
|
|
fmt.Println("Sending registration payload, please wait")
|
|
|
|
config := map[string]string{
|
|
"device": device,
|
|
"cc": string(b),
|
|
}
|
|
|
|
if reboot {
|
|
config["reboot"] = ""
|
|
}
|
|
|
|
if poweroff {
|
|
config["poweroff"] = ""
|
|
}
|
|
|
|
err := nodepair.Send(
|
|
ctx,
|
|
config,
|
|
nodepair.WithReader(qr.Reader),
|
|
nodepair.WithToken(arg),
|
|
nodepair.WithLogLevel(loglevel),
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println("Payload sent, installation will start on the machine briefly")
|
|
return nil
|
|
}
|