Compare commits

...

1 Commits

Author SHA1 Message Date
8ec57323fe go fmt 2025-04-14 19:35:35 +02:00
6 changed files with 84 additions and 52 deletions

View File

@@ -38,9 +38,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"
unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
"github.com/vegardengen/unifi-network-operator/internal/config"
"github.com/vegardengen/unifi-network-operator/internal/controller"
"github.com/vegardengen/unifi-network-operator/internal/unifi"
"github.com/vegardengen/unifi-network-operator/internal/config"
// +kubebuilder:scaffold:imports
)

View File

@@ -42,4 +42,3 @@ func (c *ConfigLoaderType) GetConfig(ctx context.Context, name string) (*corev1.
return cm, err
}

View File

@@ -0,0 +1,33 @@
/* https://github.com/clbx/kube-port-forward-controller */
package unifi_network_operator_utils
import (
"regexp"
"strings"
)
func isIPv6(ip string) bool {
return strings.Contains(ip, ":")
}
func toKubeName(input string) string {
// Lowercase the input
name := strings.ToLower(input)
// Replace any non-alphanumeric characters with dashes
re := regexp.MustCompile(`[^a-z0-9\-\.]+`)
name = re.ReplaceAllString(name, "-")
// Trim leading and trailing non-alphanumerics
name = strings.Trim(name, "-.")
// Ensure it's not empty and doesn't exceed 253 characters
if len(name) == 0 {
name = "default"
} else if len(name) > 253 {
name = name[:253]
}
return name
}