diff --git a/clustertool/pkg/talassist/ips.go b/clustertool/pkg/talassist/ips.go new file mode 100644 index 00000000000..019dfd531d8 --- /dev/null +++ b/clustertool/pkg/talassist/ips.go @@ -0,0 +1,37 @@ +package talassist + +import ( + "io/ioutil" + + "github.com/truecharts/public/clustertool/pkg/helper" + "gopkg.in/yaml.v3" +) + +// NodeIPConfig represents a simplified YAML structure to only parse node IP addresses +type NodeIPConfig struct { + Nodes []struct { + IPAddress string `yaml:"ipAddress"` + } `yaml:"nodes"` +} + +// LoadNodeIPs loads the list of IP addresses in nodes[].ipAddress from talconfig.yaml +func LoadNodeIPs() error { + // Read the YAML file + data, err := ioutil.ReadFile(helper.TalConfigFile) + if err != nil { + return err + } + + // Unmarshal only the IP addresses from the YAML + var config NodeIPConfig + if err := yaml.Unmarshal(data, &config); err != nil { + return err + } + + // Extract the IP addresses into a list + for _, node := range config.Nodes { + ipAddresses = append(ipAddresses, node.IPAddress) + } + + return nil +} diff --git a/clustertool/pkg/talassist/vars.go b/clustertool/pkg/talassist/vars.go new file mode 100644 index 00000000000..f277e3fd3fb --- /dev/null +++ b/clustertool/pkg/talassist/vars.go @@ -0,0 +1,5 @@ +package talassist + +var ( + ipAddresses = []string{} +)