github.com/helmwave/helmwave@v0.36.4-0.20240509190856-b35563eba4c6/pkg/release/validate.go (about) 1 package release 2 3 import "regexp" 4 5 var nsRegexp = regexp.MustCompile("[a-z0-9]([-a-z0-9]*[a-z0-9])?") 6 7 func (rel *config) Validate() error { 8 if rel.Name() == "" { 9 return ErrNameEmpty 10 } 11 12 if rel.Namespace() == "" { 13 rel.Logger().Warnf("namespace is empty. I will use the namespace of your k8s context.") 14 } 15 16 if !validateNS(rel.Namespace()) { 17 return NewInvalidNamespaceError(rel.Namespace()) 18 } 19 20 if err := rel.Uniq().Validate(); err != nil { 21 return err 22 } 23 24 return nil 25 } 26 27 func validateNS(ns string) bool { 28 return nsRegexp.MatchString(ns) 29 }