Compare commits
1 Commits
17-create-
...
chore/form
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ec57323fe |
@@ -38,9 +38,9 @@ import (
|
|||||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||||
|
|
||||||
unifiv1beta1 "github.com/vegardengen/unifi-network-operator/api/v1beta1"
|
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/controller"
|
||||||
"github.com/vegardengen/unifi-network-operator/internal/unifi"
|
"github.com/vegardengen/unifi-network-operator/internal/unifi"
|
||||||
"github.com/vegardengen/unifi-network-operator/internal/config"
|
|
||||||
// +kubebuilder:scaffold:imports
|
// +kubebuilder:scaffold:imports
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -42,4 +42,3 @@ func (c *ConfigLoaderType) GetConfig(ctx context.Context, name string) (*corev1.
|
|||||||
|
|
||||||
return cm, err
|
return cm, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user