Validation allows empty string namespace
Signed-off-by: F. Gold <fgold@vmware.com>pull/4250/head
parent
54fa63939a
commit
51307130a2
|
@ -180,6 +180,12 @@ func ValidateNamespaceIncludesExcludes(includesList, excludesList []string) []er
|
|||
func validateNamespaceName(ns string) []error {
|
||||
var errs []error
|
||||
|
||||
// Velero interprets empty string as "no namespace", so allow it even though
|
||||
// it is not a valid Kubernetes name.
|
||||
if ns == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Kubernetes does not allow asterisks in namespaces but Velero uses them as
|
||||
// wildcards. Replace asterisks with an arbitrary letter to pass Kubernetes
|
||||
// validation.
|
||||
|
|
|
@ -207,11 +207,6 @@ func TestValidateNamespaceIncludesExcludes(t *testing.T) {
|
|||
includes: []string{},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "empty string is invalid",
|
||||
includes: []string{""},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "asterisk by itself is valid",
|
||||
includes: []string{"*"},
|
||||
|
@ -240,6 +235,16 @@ func TestValidateNamespaceIncludesExcludes(t *testing.T) {
|
|||
includes: []string{},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "empty string includes is valid (includes nothing)",
|
||||
includes: []string{""},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "empty string excludes is valid (excludes nothing)",
|
||||
excludes: []string{""},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "include everything using asterisk is valid",
|
||||
includes: []string{"*"},
|
||||
|
|
Loading…
Reference in New Issue