fix(): catch errors and increase verbosity
This commit is contained in:
		| @@ -18,11 +18,17 @@ func GetAllNodes(cfg *Config) ([]*hcloud.Server, error) { | ||||
| 		return nil, fmt.Errorf("error listing Hetzner Nodes: %s", err.Error()) | ||||
| 	} | ||||
|  | ||||
| 	if servers == nil { | ||||
| 	if len(servers) == 0 { | ||||
| 		return nil, fmt.Errorf("no Nodes found with label selector: %s", cfg.LabelSelector) | ||||
| 	} | ||||
| 	return servers, nil | ||||
|  | ||||
| 	for _, instance := range servers { | ||||
| 		log.WithFields(log.Fields{ | ||||
| 			"Caller": "GetAllNodes", | ||||
| 		}).Info(fmt.Sprintf("Found server: %s", instance.Name)) | ||||
| 	} | ||||
|  | ||||
| 	return servers, nil | ||||
| } | ||||
|  | ||||
| func GetAllIps(servers []*hcloud.Server) ([]string, error) { | ||||
| @@ -33,7 +39,7 @@ func GetAllIps(servers []*hcloud.Server) ([]string, error) { | ||||
| 		} | ||||
| 		log.WithFields(log.Fields{ | ||||
| 			"Caller": "GetAllIps", | ||||
| 		}).Info(fmt.Sprintf("Found IP: %s", instance.PrivateNet[0].IP.String())) | ||||
| 		}).Info(fmt.Sprintf("Found IP: %s", instance.PublicNet.IPv4.IP.String())) | ||||
| 		ips[i] = instance.PublicNet.IPv4.IP.String() | ||||
| 	} | ||||
| 	return ips, nil | ||||
|   | ||||
| @@ -49,6 +49,11 @@ type CrdConfig struct { | ||||
| } | ||||
|  | ||||
| func RecreateIPPoolCrd(cfg *Config, name string, ips []string) error { | ||||
|  | ||||
| 	if len(ips) == 0 { | ||||
| 		return fmt.Errorf("no IPs provided to create IP Pool CRD") | ||||
| 	} | ||||
|  | ||||
| 	routeclient, err := createRestClient() | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("error creating REST Client: %v", err.Error()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user