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

@@ -3,7 +3,6 @@ package internal
import (
"bytes"
"context"
"errors"
"fmt"
"html/template"
@@ -45,20 +44,20 @@ func RecreateIPPoolCrd(cfg *Config, name string, ips []string) error {
routeclient, err := createRestClient()
if err != nil {
return errors.New(fmt.Sprintf("Error creating REST Client: %v", err.Error()))
return fmt.Errorf("error creating REST Client: %v", err.Error())
}
body, err := generateIpPool(name, ips)
if err != nil {
return errors.New(fmt.Sprintf("Error generating CRD: %v", err.Error()))
return fmt.Errorf("error generating CRD: %v", err.Error())
}
decode := scheme.Codecs.UniversalDeserializer().Decode
obj, _, err := decode([]byte(body), nil, nil)
if err != nil {
return errors.New(fmt.Sprintf("Could not deserialize CRD: %v", err.Error()))
return fmt.Errorf("could not deserialize CRD: %v", err.Error())
}
res := routeclient.Post().
@@ -70,7 +69,7 @@ func RecreateIPPoolCrd(cfg *Config, name string, ips []string) error {
res.StatusCode(&status)
if status >= 200 && status <= 400 {
return errors.New(fmt.Sprintf("Failed to post CRD to kube api: %v", res.Error().Error()))
return fmt.Errorf("failed to post CRD to kube api: %v", res.Error().Error())
}
return nil
@@ -79,7 +78,7 @@ func RecreateIPPoolCrd(cfg *Config, name string, ips []string) error {
func createRestClient() (*rest.RESTClient, error) {
k8s_config, err := rest.InClusterConfig()
if err != nil {
return nil, errors.New(fmt.Sprintf("Could not create in cluster k8s config: %v", err))
return nil, fmt.Errorf("could not create in cluster k8s config: %v", err)
}
k8s_config.APIPath = "/apis"
@@ -88,7 +87,7 @@ func createRestClient() (*rest.RESTClient, error) {
routeclient, err := rest.RESTClientFor(k8s_config)
if err != nil {
return nil, errors.New(fmt.Sprintf("Could not create k8s client: %v", err))
return nil, fmt.Errorf("could not create k8s client: %v", err)
}
return routeclient, nil
@@ -101,12 +100,12 @@ func generateIpPool(name string, ips []string) (string, error) {
}
tmpl, err := template.New("ippool").Parse(IP_POOL_TEMPLATE)
if err != nil {
return "", errors.New(fmt.Sprintf("Errors in ippool template: %s", err.Error()))
return "", fmt.Errorf("errors in ippool template: %s", err.Error())
}
var buf bytes.Buffer
err = tmpl.Execute(&buf, &config)
if err != nil {
return "", errors.New(fmt.Sprintf("Could not render ippool template: %s", err.Error()))
return "", fmt.Errorf("could not render ippool template: %s", err.Error())
}
return buf.String(), nil
}