File tree 1 file changed +6
-2
lines changed 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -18,21 +18,25 @@ package utils
18
18
19
19
import (
20
20
"fmt"
21
+ "regexp"
21
22
"strings"
22
23
23
24
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
24
25
ctrl "sigs.k8s.io/controller-runtime"
25
26
)
26
27
27
28
func (r * ReconciliationRunner ) IsoNetMetaName (name string ) string {
28
- return fmt .Sprintf ("%s-%s" , r .CSCluster .Name , strings .ToLower (name ))
29
+ str := fmt .Sprintf ("%s-%s" , r .CSCluster .Name , strings .ToLower (name ))
30
+ reg , _ := regexp .Compile (`[^a-z0-9-]+` )
31
+ str = reg .ReplaceAllString (str , "-" )
32
+ return strings .TrimSuffix (str , "-" )
29
33
}
30
34
31
35
// GenerateIsolatedNetwork of the passed name that's owned by the ReconciliationSubject.
32
36
func (r * ReconciliationRunner ) GenerateIsolatedNetwork (name string , fdNameFunc func () string ) CloudStackReconcilerMethod {
33
37
return func () (ctrl.Result , error ) {
34
38
lowerName := strings .ToLower (name )
35
- metaName := fmt . Sprintf ( "%s-%s" , r . CSCluster . Name , lowerName )
39
+ metaName := r . IsoNetMetaName ( lowerName )
36
40
csIsoNet := & infrav1.CloudStackIsolatedNetwork {}
37
41
csIsoNet .ObjectMeta = r .NewChildObjectMeta (metaName )
38
42
csIsoNet .Spec .Name = lowerName
You can’t perform that action at this time.
0 commit comments