fix(): use publich ip addresses
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user