@@ -1567,6 +1567,71 @@ func TestValidateCustomResourceDefinition(t *testing.T) {
1567
1567
required ("spec" , "validation" , "openAPIV3Schema" , "type" ),
1568
1568
},
1569
1569
},
1570
+ {
1571
+ name : "x-kubernetes-embedded-resource inside resource meta" ,
1572
+ resource : & apiextensions.CustomResourceDefinition {
1573
+ ObjectMeta : metav1.ObjectMeta {Name : "plural.group.com" },
1574
+ Spec : apiextensions.CustomResourceDefinitionSpec {
1575
+ Group : "group.com" ,
1576
+ Version : "version" ,
1577
+ Versions : singleVersionList ,
1578
+ Scope : apiextensions .NamespaceScoped ,
1579
+ Names : apiextensions.CustomResourceDefinitionNames {
1580
+ Plural : "plural" ,
1581
+ Singular : "singular" ,
1582
+ Kind : "Plural" ,
1583
+ ListKind : "PluralList" ,
1584
+ },
1585
+ Validation : & apiextensions.CustomResourceValidation {
1586
+ OpenAPIV3Schema : & apiextensions.JSONSchemaProps {
1587
+ Type : "object" ,
1588
+ Properties : map [string ]apiextensions.JSONSchemaProps {
1589
+ "embedded" : {
1590
+ Type : "object" ,
1591
+ XEmbeddedResource : true ,
1592
+ Properties : map [string ]apiextensions.JSONSchemaProps {
1593
+ "metadata" : {
1594
+ Type : "object" ,
1595
+ XEmbeddedResource : true ,
1596
+ XPreserveUnknownFields : pointer .BoolPtr (true ),
1597
+ },
1598
+ "apiVersion" : {
1599
+ Type : "string" ,
1600
+ Properties : map [string ]apiextensions.JSONSchemaProps {
1601
+ "foo" : {
1602
+ Type : "object" ,
1603
+ XEmbeddedResource : true ,
1604
+ XPreserveUnknownFields : pointer .BoolPtr (true ),
1605
+ },
1606
+ },
1607
+ },
1608
+ "kind" : {
1609
+ Type : "string" ,
1610
+ Properties : map [string ]apiextensions.JSONSchemaProps {
1611
+ "foo" : {
1612
+ Type : "object" ,
1613
+ XEmbeddedResource : true ,
1614
+ XPreserveUnknownFields : pointer .BoolPtr (true ),
1615
+ },
1616
+ },
1617
+ },
1618
+ },
1619
+ },
1620
+ },
1621
+ },
1622
+ },
1623
+ PreserveUnknownFields : pointer .BoolPtr (true ),
1624
+ },
1625
+ Status : apiextensions.CustomResourceDefinitionStatus {
1626
+ StoredVersions : []string {"version" },
1627
+ },
1628
+ },
1629
+ errors : []validationMatch {
1630
+ forbidden ("spec" , "validation" , "openAPIV3Schema" , "properties[embedded]" , "properties[metadata]" , "x-kubernetes-embedded-resource" ),
1631
+ forbidden ("spec" , "validation" , "openAPIV3Schema" , "properties[embedded]" , "properties[apiVersion]" , "properties[foo]" , "x-kubernetes-embedded-resource" ),
1632
+ forbidden ("spec" , "validation" , "openAPIV3Schema" , "properties[embedded]" , "properties[kind]" , "properties[foo]" , "x-kubernetes-embedded-resource" ),
1633
+ },
1634
+ },
1570
1635
{
1571
1636
name : "defaults with enabled feature gate, unstructural schema" ,
1572
1637
resource : & apiextensions.CustomResourceDefinition {
0 commit comments