mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-02 17:45:10 +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.
41 lines
902 B
Go
41 lines
902 B
Go
package main
|
|
|
|
import (
|
|
machine "github.com/c3os-io/c3os/internal/machine"
|
|
"github.com/c3os-io/c3os/internal/provider"
|
|
providerConfig "github.com/c3os-io/c3os/internal/provider/config"
|
|
config "github.com/c3os-io/c3os/pkg/config"
|
|
)
|
|
|
|
func rotate(configDir []string, newToken, apiAddress, rootDir string, restart bool) error {
|
|
if err := config.ReplaceToken(configDir, newToken); err != nil {
|
|
return err
|
|
}
|
|
|
|
c, err := config.Scan(config.Directories(configDir...))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
providerCfg := &providerConfig.Config{}
|
|
err = c.Unmarshal(providerCfg)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = provider.SetupVPN(machine.EdgeVPNDefaultInstance, apiAddress, rootDir, false, providerCfg)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if restart {
|
|
svc, err := machine.EdgeVPN(machine.EdgeVPNDefaultInstance, rootDir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return svc.Restart()
|
|
}
|
|
return nil
|
|
}
|