-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed CatalogMetadata syncing issues related to metadata.name and etc…
…d size constraints Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
- Loading branch information
1 parent
8a5e079
commit 3df6119
Showing
3 changed files
with
57 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package k8sutil | ||
|
||
import ( | ||
"regexp" | ||
|
||
"k8s.io/apimachinery/pkg/util/validation" | ||
) | ||
|
||
var invalidDNSChars = regexp.MustCompile(`[^a-zA-Z0-9-]`) | ||
|
||
// MetadataName replaces all invalid DNS characters with a dash. If the result | ||
// is not a valid DNS subdomain, returns `result, false`. Otherwise, returns the | ||
// `result, true`. | ||
func MetadataName(name string) (string, bool) { | ||
result := invalidDNSChars.ReplaceAllString(name, "-") | ||
return result, validation.IsDNS1123Subdomain(result) == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters