fix(): use publich ip addresses
All checks were successful
PR Build / Test (pull_request) Successful in 2m22s
PR Build / Build_Image (pull_request) Successful in 2m22s

This commit is contained in:
2025-10-06 11:16:00 +02:00
parent 25d9c004b0
commit d22a53fbb7
4 changed files with 15 additions and 18 deletions

View File

@@ -2,7 +2,6 @@ package internal
import (
"context"
"errors"
"fmt"
"github.com/hetznercloud/hcloud-go/hcloud"
@@ -16,11 +15,11 @@ func GetAllNodes(cfg *Config) ([]*hcloud.Server, error) {
LabelSelector: cfg.LabelSelector,
}})
if err != nil {
return nil, errors.New(fmt.Sprintf("Error listing Hetzner Nodes: %s", err.Error()))
return nil, fmt.Errorf("error listing Hetzner Nodes: %s", err.Error())
}
if servers == nil {
return nil, errors.New(fmt.Sprintf("No Nodes found with label selector: %s", cfg.LabelSelector))
return nil, fmt.Errorf("no Nodes found with label selector: %s", cfg.LabelSelector)
}
return servers, nil
@@ -29,13 +28,13 @@ func GetAllNodes(cfg *Config) ([]*hcloud.Server, error) {
func GetAllIps(servers []*hcloud.Server) ([]string, error) {
ips := make([]string, len(servers))
for i, instance := range servers {
if len(instance.PrivateNet) == 0 || instance.PrivateNet[0].IP == nil {
return []string{""}, errors.New(fmt.Sprintf("Instance %s has no attached IP", instance.Name))
if instance.PublicNet.IPv4.IP == nil {
return []string{""}, fmt.Errorf("instance %s has no public Addresses", instance.Name)
}
log.WithFields(log.Fields{
"Caller": "GetAllIps",
}).Info(fmt.Sprintf("Found IP: %s", instance.PrivateNet[0].IP.String()))
ips[i] = instance.PrivateNet[0].IP.String()
ips[i] = instance.PublicNet.IPv4.IP.String()
}
return ips, nil
}