Add default namespace labels to all namespaces for selectors (#96968)

* namespace by name default labelling

Co-authored-by: Jordan Liggitt <jordan@liggitt.net>
Co-authored-by: Abhishek Raut <rauta@vmware.com>

* Make some logic improvement into default namespace label

* Fix unit tests

* minor change to trigger the CI

* Correct some tests and validation behaviors

* Add Canonicalize normalization and improve validation

* Remove label validation that should be dealt by strategy

* Update defaults_test.go
add fuzzer
ns spec

* remove the finalizer thingy

* Fix integration test

* Add namespace canonicalize unit test

* Improve validation code and code comments

* move validation of labels to validateupdate

* spacex will save us all

* add comment to testget

* readablility of canonicalize

* Added namespace finalize and status update validation

* comment about ungenerated names

* correcting a missing line on storage_test

* Update the namespace validation unit test

* Add more missing unit test changes

* Let's just blast the value. Also documenting the workflow here

* Remove unnecessary validations

Co-authored-by: Jordan Liggitt <jordan@liggitt.net>
Co-authored-by: Abhishek Raut <rauta@vmware.com>
Co-authored-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com>
This commit is contained in:
jay vyas
2021-03-08 23:46:59 -05:00
committed by GitHub
parent 6d499e6768
commit c94ce8c507
10 changed files with 170 additions and 12 deletions

View File

@@ -472,6 +472,16 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
func(s *core.NamespaceSpec, c fuzz.Continue) {
s.Finalizers = []core.FinalizerName{core.FinalizerKubernetes}
},
func(s *core.Namespace, c fuzz.Continue) {
c.FuzzNoCustom(s) // fuzz self without calling this function again
// Match name --> label defaulting
if len(s.Name) > 0 {
if s.Labels == nil {
s.Labels = map[string]string{}
}
s.Labels["kubernetes.io/metadata.name"] = s.Name
}
},
func(s *core.NamespaceStatus, c fuzz.Continue) {
s.Phase = core.NamespaceActive
},