fix(clustertool): revert previous apply changes due to a mistake
This commit is contained in:
@@ -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)
|
||||||
commands := []string{}
|
cfg, err := talhelperCfg.LoadAndValidateFromFile(helper.TalConfigFile, []string{helper.ClusterEnvFile}, false)
|
||||||
//extraFlags = append(extraFlags, "--preserve")
|
if err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("failed to parse talconfig or talenv file: %s")
|
||||||
talosPath := embed.GetTalosExec()
|
|
||||||
if node == "" {
|
|
||||||
for _, nodeRef := range talassist.IpAddresses {
|
|
||||||
talassist.LoadNodeIPs()
|
|
||||||
// TODO add extraFlags
|
|
||||||
|
|
||||||
// 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 + " "
|
|
||||||
commands = append(commands, cmd)
|
|
||||||
}
|
}
|
||||||
return commands
|
|
||||||
|
applyStdout := os.Stdout
|
||||||
|
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()
|
||||||
|
var slice []string
|
||||||
|
for _, str := range sliceOut {
|
||||||
|
if str != "" {
|
||||||
|
str = strings.ReplaceAll(str, "talosctl", talosPath)
|
||||||
|
slice = append(slice, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("failed to generate talosctl apply command: %s")
|
||||||
|
}
|
||||||
|
return slice
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user