mirror of
https://github.com/truecharts/charts.git
synced 2026-07-07 16:06:44 -03:00
44 lines
1.4 KiB
Go
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
|
|
}
|