mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-08-18 16:27:02 +00:00
Now there is a `install` section in the config that has the fields that previously where in `c3os` but were actually only used during install phase. Also the k3s and c3os config were moved to the provider instead that in the global config.
36 lines
802 B
Go
36 lines
802 B
Go
package provider
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/c3os-io/c3os/pkg/bus"
|
|
"github.com/mudler/go-nodepair"
|
|
"github.com/mudler/go-pluggable"
|
|
)
|
|
|
|
func Install(e *pluggable.Event) pluggable.EventResponse {
|
|
cfg := &bus.InstallPayload{}
|
|
err := json.Unmarshal([]byte(e.Data), cfg)
|
|
if err != nil {
|
|
return ErrorEvent("Failed reading JSON input: %s", err.Error())
|
|
}
|
|
|
|
r := map[string]string{}
|
|
ctx := context.Background()
|
|
if err := nodepair.Receive(ctx, &r, nodepair.WithToken(cfg.Token)); err != nil {
|
|
return ErrorEvent("Failed reading JSON input: %s", err.Error())
|
|
}
|
|
|
|
payload, err := json.Marshal(r)
|
|
if err != nil {
|
|
return ErrorEvent("Failed marshalling JSON input: %s", err.Error())
|
|
}
|
|
|
|
return pluggable.EventResponse{
|
|
State: "",
|
|
Data: string(payload),
|
|
Error: "",
|
|
}
|
|
}
|