Skip to content

Commit 2b861c1

Browse files
committed
fix: Fix name of isonet if network name contains underscore
Upstream PR kubernetes-sigs#361
1 parent daedeb4 commit 2b861c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

controllers/utils/isolated_network.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ package utils
1818

1919
import (
2020
"fmt"
21+
"regexp"
2122
"strings"
2223

2324
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
2425
ctrl "sigs.k8s.io/controller-runtime"
2526
)
2627

28+
var metaNameRegex = regexp.MustCompile(`[^a-z0-9-]+`)
29+
2730
func (r *ReconciliationRunner) IsoNetMetaName(name string) string {
28-
return fmt.Sprintf("%s-%s", r.CSCluster.Name, strings.ToLower(name))
31+
str := metaNameRegex.ReplaceAllString(fmt.Sprintf("%s-%s", r.CSCluster.Name, strings.ToLower(name)), "-")
32+
return strings.TrimSuffix(str, "-")
2933
}
3034

3135
// GenerateIsolatedNetwork of the passed name that's owned by the ReconciliationSubject.

0 commit comments

Comments
 (0)