fix(clustertool): revert previous apply changes due to a mistake

This commit is contained in:
Kjeld Schouten
2024-11-05 23:45:36 +01:00
parent 61a01f3299
commit 45582c596b
+34 -15
View File
@@ -1,30 +1,49 @@
package gencmd package gencmd
import ( import (
"io"
"os"
"strings"
"github.com/rs/zerolog/log"
talhelperCfg "github.com/budimanjojo/talhelper/v3/pkg/config"
"github.com/budimanjojo/talhelper/v3/pkg/generate"
"github.com/truecharts/public/clustertool/embed" "github.com/truecharts/public/clustertool/embed"
"github.com/truecharts/public/clustertool/pkg/helper" "github.com/truecharts/public/clustertool/pkg/helper"
"github.com/truecharts/public/clustertool/pkg/talassist" "github.com/truecharts/public/clustertool/pkg/initfiles"
) )
func GenApply(node string, extraFlags []string) []string { func GenApply(node string, extraFlags []string) []string {
initfiles.LoadTalEnv(false)
cfg, err := talhelperCfg.LoadAndValidateFromFile(helper.TalConfigFile, []string{helper.ClusterEnvFile}, false)
if err != nil {
log.Fatal().Err(err).Msg("failed to parse talconfig or talenv file: %s")
}
commands := []string{} applyStdout := os.Stdout
//extraFlags = append(extraFlags, "--preserve") r, w, _ := os.Pipe()
os.Stdout = w
// replace this with self-made stuff, be aware we also need to use the configfile
err = generate.GenerateApplyCommand(cfg, helper.TalosGenerated, node, extraFlags)
w.Close()
out, _ := io.ReadAll(r)
os.Stdout = applyStdout
sliceOut := strings.Split(string(out), ";\n")
talosPath := embed.GetTalosExec() talosPath := embed.GetTalosExec()
if node == "" { var slice []string
for _, nodeRef := range talassist.IpAddresses { for _, str := range sliceOut {
talassist.LoadNodeIPs() if str != "" {
// TODO add extraFlags str = strings.ReplaceAll(str, "talosctl", talosPath)
slice = append(slice, str)
}
// TODO: add images Refs
// TODO: add schematic
cmd := talosPath + " apply --talosconfig " + helper.TalosConfigFile + " -n " + nodeRef + " "
commands = append(commands, cmd)
} }
} else {
cmd := talosPath + " apply --talosconfig " + helper.TalosConfigFile + " -n " + node + " " if err != nil {
commands = append(commands, cmd) log.Fatal().Err(err).Msg("failed to generate talosctl apply command: %s")
} }
return commands return slice
} }