Files
charts/clustertool/pkg/gencmd/apply.go
Kjeld Schouten 1c28a12789 chore: fix links
2025-09-07 14:26:19 +02:00

44 lines
1.4 KiB
Go

package gencmd
import (
"os"
"path/filepath"
"github.com/rs/zerolog/log"
"github.com/trueforge-org/truecharts/clustertool/embed"
"github.com/trueforge-org/truecharts/clustertool/pkg/helper"
"github.com/trueforge-org/truecharts/clustertool/pkg/talassist"
)
func GenApply(node string, extraArgs []string) []string {
commands := []string{}
talosPath := embed.GetTalosExec()
if node == "" {
for _, noderef := range talassist.TalConfig.Nodes {
filename := talassist.TalConfig.ClusterName + "-" + noderef.Hostname + ".yaml"
cmd := talosPath + " " + "apply machineconfig" + " -f " + filepath.Join(helper.TalosGenerated, filename) + " --talosconfig " + helper.TalosConfigFile + " -n " + noderef.IPAddress // + " " + strings.Join(extraArgs, " ")
commands = append(commands, cmd)
}
} else {
nodename := ""
for _, noderef := range talassist.TalConfig.Nodes {
if noderef.IPAddress == node {
nodename = noderef.Hostname
}
}
if nodename == "" {
log.Error().Msgf("Node IP %s, does not match any node in talconfig. Exiting...", node)
os.Exit(1)
}
filename := talassist.TalConfig.ClusterName + "-" + nodename + ".yaml"
cmd := talosPath + " " + "apply machineconfig" + " -f " + filepath.Join(helper.TalosGenerated, filename) + " --talosconfig " + helper.TalosConfigFile + " -n " + node // + " " + strings.Join(extraArgs, " ")
commands = append(commands, cmd)
}
log.Debug().Msgf("Apply Commands rendered: %s", commands)
return commands
}