mirror of
https://codeberg.org/crowci/crow.git
synced 2025-08-09 07:42:52 +03:00
@@ -31,7 +31,8 @@ var (
|
||||
`([-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")
|
||||
dnsDisallowedCharacters = regexp.MustCompile(`[^-^.a-z0-9]+`)
|
||||
ErrDNSPatternInvalid = errors.New("name is not a valid kubernetes DNS name")
|
||||
)
|
||||
|
||||
func dnsName(i string) (string, error) {
|
||||
@@ -44,6 +45,14 @@ func dnsName(i string) (string, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func toDNSName(in string) (string, error) {
|
||||
lower := strings.ToLower(in)
|
||||
withoutUnderscores := strings.ReplaceAll(lower, "_", "-")
|
||||
withoutSpaces := strings.ReplaceAll(withoutUnderscores, " ", "-")
|
||||
almostDNS := dnsDisallowedCharacters.ReplaceAllString(withoutSpaces, "")
|
||||
return dnsName(almostDNS)
|
||||
}
|
||||
|
||||
func isImagePullBackOffState(pod *v1.Pod) bool {
|
||||
for _, containerState := range pod.Status.ContainerStatuses {
|
||||
if containerState.State.Waiting != nil {
|
||||
|
Reference in New Issue
Block a user