feat(clustertool): introduce tracing of command-slice and dont process extraArgs for now
This commit is contained in:
@@ -3,7 +3,6 @@ package gencmd
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/truecharts/public/clustertool/embed"
|
"github.com/truecharts/public/clustertool/embed"
|
||||||
@@ -14,15 +13,13 @@ import (
|
|||||||
func GenApply(node string, extraArgs []string) []string {
|
func GenApply(node string, extraArgs []string) []string {
|
||||||
|
|
||||||
commands := []string{}
|
commands := []string{}
|
||||||
//extraFlags = append(extraFlags, "--preserve")
|
|
||||||
|
|
||||||
talosPath := embed.GetTalosExec()
|
talosPath := embed.GetTalosExec()
|
||||||
if node == "" {
|
if node == "" {
|
||||||
|
|
||||||
for _, noderef := range talassist.TalConfig.Nodes {
|
for _, noderef := range talassist.TalConfig.Nodes {
|
||||||
// TODO add extraFlags
|
|
||||||
filename := talassist.TalConfig.ClusterName + "-" + noderef.Hostname + ".yaml"
|
filename := talassist.TalConfig.ClusterName + "-" + noderef.Hostname + ".yaml"
|
||||||
cmd := talosPath + " " + "apply-config" + " --talosconfig " + helper.TalosConfigFile + " -n " + noderef.IPAddress + " -f " + filepath.Join(helper.TalosGenerated, filename) + " " + strings.Join(extraArgs, " ")
|
cmd := talosPath + " " + "apply-config" + " --talosconfig " + helper.TalosConfigFile + " -n " + noderef.IPAddress + " -f " + filepath.Join(helper.TalosGenerated, filename) // + " " + strings.Join(extraArgs, " ")
|
||||||
commands = append(commands, cmd)
|
commands = append(commands, cmd)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -38,7 +35,7 @@ func GenApply(node string, extraArgs []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
filename := talassist.TalConfig.ClusterName + "-" + nodename + ".yaml"
|
filename := talassist.TalConfig.ClusterName + "-" + nodename + ".yaml"
|
||||||
cmd := talosPath + " " + "apply-config" + " --talosconfig " + helper.TalosConfigFile + " -n " + node + " -f " + filepath.Join(helper.TalosGenerated, filename) + " " + strings.Join(extraArgs, " ")
|
cmd := talosPath + " " + "apply-config" + " --talosconfig " + helper.TalosConfigFile + " -n " + node + " -f " + filepath.Join(helper.TalosGenerated, filename) // + " " + strings.Join(extraArgs, " ")
|
||||||
commands = append(commands, cmd)
|
commands = append(commands, cmd)
|
||||||
}
|
}
|
||||||
log.Debug().Msgf("Apply Commands rendered: %s", commands)
|
log.Debug().Msgf("Apply Commands rendered: %s", commands)
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package gencmd
|
package gencmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"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"
|
||||||
@@ -17,12 +15,11 @@ func GenPlain(command string, node string, extraArgs []string) []string {
|
|||||||
if node == "" {
|
if node == "" {
|
||||||
|
|
||||||
for _, noderef := range talassist.TalConfig.Nodes {
|
for _, noderef := range talassist.TalConfig.Nodes {
|
||||||
// TODO add extraFlags
|
cmd := talosPath + " " + command + " --talosconfig " + helper.TalosConfigFile + " -n " + noderef.IPAddress // + " " + strings.Join(extraArgs, " ")
|
||||||
cmd := talosPath + " " + command + " --talosconfig " + helper.TalosConfigFile + " -n " + noderef.IPAddress + " " + strings.Join(extraArgs, " ")
|
|
||||||
commands = append(commands, cmd)
|
commands = append(commands, cmd)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmd := talosPath + " " + command + " --talosconfig " + helper.TalosConfigFile + " -n " + node + " " + strings.Join(extraArgs, " ")
|
cmd := talosPath + " " + command + " --talosconfig " + helper.TalosConfigFile + " -n " + node // + " " + strings.Join(extraArgs, " ")
|
||||||
commands = append(commands, cmd)
|
commands = append(commands, cmd)
|
||||||
}
|
}
|
||||||
log.Debug().Msgf("%s Command rendered: %s", command, commands)
|
log.Debug().Msgf("%s Command rendered: %s", command, commands)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type filteredWriter struct {
|
type filteredWriter struct {
|
||||||
@@ -33,6 +35,10 @@ func (fw *filteredWriter) Write(p []byte) (n int, err error) {
|
|||||||
|
|
||||||
func RunCommand(commandSlice []string, silent bool) (string, error) {
|
func RunCommand(commandSlice []string, silent bool) (string, error) {
|
||||||
filters := []string{"certificate signed by unknown authority", "bootstrap is not available yet"}
|
filters := []string{"certificate signed by unknown authority", "bootstrap is not available yet"}
|
||||||
|
log.Trace().Msg("Command slice structure:")
|
||||||
|
for i, s := range commandSlice {
|
||||||
|
log.Trace().Msgf("Index: %d, Value: %s\n", i, s)
|
||||||
|
}
|
||||||
cmd := exec.Command(commandSlice[0], commandSlice[1:]...)
|
cmd := exec.Command(commandSlice[0], commandSlice[1:]...)
|
||||||
|
|
||||||
var stdoutBuf, stderrBuf bytes.Buffer
|
var stdoutBuf, stderrBuf bytes.Buffer
|
||||||
|
|||||||
Reference in New Issue
Block a user