Merge pull request #77333 from sttts/sttts-structural-crd-pruning

apiextensions: implement structural schema CRD pruning
This commit is contained in:
Kubernetes Prow Robot
2019-05-17 05:38:05 -07:00
committed by GitHub
27 changed files with 1869 additions and 238 deletions

View File

@@ -113,6 +113,9 @@ var (
gvr("", "v1", "nodes/proxy"): {"*": testSubresourceProxy},
gvr("", "v1", "pods/proxy"): {"*": testSubresourceProxy},
gvr("", "v1", "services/proxy"): {"*": testSubresourceProxy},
gvr("random.numbers.com", "v1", "integers"): {"create": testPruningRandomNumbers},
gvr("custom.fancy.com", "v2", "pants"): {"create": testNoPruningCustomFancy},
}
// admissionExemptResources lists objects which are exempt from admission validation/mutation,
@@ -921,6 +924,46 @@ func testSubresourceProxy(c *testContext) {
}
}
func testPruningRandomNumbers(c *testContext) {
testResourceCreate(c)
cr2pant, err := c.client.Resource(c.gvr).Get("fortytwo", metav1.GetOptions{})
if err != nil {
c.t.Error(err)
return
}
foo, found, err := unstructured.NestedString(cr2pant.Object, "foo")
if err != nil {
c.t.Error(err)
return
}
if found {
c.t.Errorf("expected .foo to be pruned, but got: %s", foo)
}
}
func testNoPruningCustomFancy(c *testContext) {
testResourceCreate(c)
cr2pant, err := c.client.Resource(c.gvr).Get("cr2pant", metav1.GetOptions{})
if err != nil {
c.t.Error(err)
return
}
foo, _, err := unstructured.NestedString(cr2pant.Object, "foo")
if err != nil {
c.t.Error(err)
return
}
// check that no pruning took place
if expected, got := "test", foo; expected != got {
c.t.Errorf("expected /foo to be %q, got: %q", expected, got)
}
}
//
// utility methods
//