mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-25 12:17:52 +00:00
Merge pull request #77333 from sttts/sttts-structural-crd-pruning
apiextensions: implement structural schema CRD pruning
This commit is contained in:
@@ -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
|
||||
//
|
||||
|
Reference in New Issue
Block a user