Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
stuggi committed Jul 11, 2024
1 parent 544a556 commit 7aba630
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions modules/common/webhook/rfc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright 2024 Red Hat
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package webhook

import (
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
)

// ValidateDNS1123Label - validates a list of strings are RFC 1123 label conform.
//
// example usage:
//
// ValidateDNS1123Label(<path>, {"foo", "bar"})
func ValidateDNS1123Label(basePath *field.Path, keys []string) field.ErrorList {
allErrs := field.ErrorList{}

for _, key := range keys {
msgs := validation.IsDNS1123Label(key)
for _, msg := range msgs {
allErrs = append(allErrs, field.Invalid(basePath.Key(key), key, msg))
}
}

return allErrs
}

0 comments on commit 7aba630

Please sign in to comment.