1
0
mirror of https://codeberg.org/crowci/crow.git synced 2025-08-06 09:22:46 +03:00

Use UUID as podName and cleanup arguments for Kubernetes backend (#3135)

to much args are just horrible to maintain. And we already have it nice
structured stored as step.
This commit is contained in:
6543
2024-01-11 16:32:37 +01:00
committed by GitHub
parent 7756c60a33
commit d1fe86b7be
7 changed files with 201 additions and 108 deletions

View File

@@ -27,12 +27,15 @@ import (
)
var (
dnsPattern = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
dnsPattern = regexp.MustCompile(`^[a-z0-9]` + // must start with
`([-a-z0-9]*[a-z0-9])?` + // inside can als contain -
`(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`, // allow the same pattern as before with dots in between but only one dot
)
ErrDNSPatternInvalid = errors.New("name is not a valid kubernetes DNS name")
)
func dnsName(i string) (string, error) {
res := strings.ReplaceAll(i, "_", "-")
res := strings.ToLower(strings.ReplaceAll(i, "_", "-"))
if found := dnsPattern.FindStringIndex(res); found == nil {
return "", ErrDNSPatternInvalid