Skip to content

Commit

Permalink
fix: Fix name of isonet if network name contains underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
hrak committed Jul 12, 2024
1 parent 6bfff95 commit 216b538
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controllers/utils/isolated_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ package utils

import (
"fmt"
"regexp"
"strings"

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

var metaNameRegex = regexp.MustCompile(`[^a-z0-9-]+`)

func (r *ReconciliationRunner) IsoNetMetaName(name string) string {
return fmt.Sprintf("%s-%s", r.CSCluster.Name, strings.ToLower(name))
str := metaNameRegex.ReplaceAllString(fmt.Sprintf("%s-%s", r.CSCluster.Name, strings.ToLower(name)), "-")
return strings.TrimSuffix(str, "-")
}

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

0 comments on commit 216b538

Please sign in to comment.