@@ -610,6 +610,76 @@ func TestSplitGroupsAndResources(t *testing.T) {
610
610
},
611
611
expectedFailedGVs : map [schema.GroupVersion ]error {},
612
612
},
613
+ {
614
+ name : "Aggregated discovery with single subresource and parent empty GVK" ,
615
+ agg : apidiscovery.APIGroupDiscoveryList {
616
+ Items : []apidiscovery.APIGroupDiscovery {
617
+ {
618
+ ObjectMeta : metav1.ObjectMeta {
619
+ Name : "external.metrics.k8s.io" ,
620
+ },
621
+ Versions : []apidiscovery.APIVersionDiscovery {
622
+ {
623
+ Version : "v1beta1" ,
624
+ Resources : []apidiscovery.APIResourceDiscovery {
625
+ {
626
+ // resilient to empty GVK for parent
627
+ Resource : "*" ,
628
+ Scope : apidiscovery .ScopeNamespace ,
629
+ SingularResource : "" ,
630
+ ResponseKind : & metav1.GroupVersionKind {},
631
+ Subresources : []apidiscovery.APISubresourceDiscovery {
632
+ {
633
+ Subresource : "other-external-metric" ,
634
+ ResponseKind : & metav1.GroupVersionKind {
635
+ Kind : "MetricValueList" ,
636
+ },
637
+ Verbs : []string {"get" },
638
+ },
639
+ },
640
+ },
641
+ },
642
+ },
643
+ },
644
+ },
645
+ },
646
+ },
647
+ expectedGroups : metav1.APIGroupList {
648
+ Groups : []metav1.APIGroup {
649
+ {
650
+ Name : "external.metrics.k8s.io" ,
651
+ Versions : []metav1.GroupVersionForDiscovery {
652
+ {
653
+ GroupVersion : "external.metrics.k8s.io/v1beta1" ,
654
+ Version : "v1beta1" ,
655
+ },
656
+ },
657
+ PreferredVersion : metav1.GroupVersionForDiscovery {
658
+ GroupVersion : "external.metrics.k8s.io/v1beta1" ,
659
+ Version : "v1beta1" ,
660
+ },
661
+ },
662
+ },
663
+ },
664
+ expectedGVResources : map [schema.GroupVersion ]* metav1.APIResourceList {
665
+ {Group : "external.metrics.k8s.io" , Version : "v1beta1" }: {
666
+ GroupVersion : "external.metrics.k8s.io/v1beta1" ,
667
+ APIResources : []metav1.APIResource {
668
+ // Since parent GVK was nil, it is NOT returned--only the subresource.
669
+ {
670
+ Name : "*/other-external-metric" ,
671
+ SingularName : "" ,
672
+ Namespaced : true ,
673
+ Group : "" ,
674
+ Version : "" ,
675
+ Kind : "MetricValueList" ,
676
+ Verbs : []string {"get" },
677
+ },
678
+ },
679
+ },
680
+ },
681
+ expectedFailedGVs : map [schema.GroupVersion ]error {},
682
+ },
613
683
{
614
684
name : "Aggregated discovery with multiple subresources" ,
615
685
agg : apidiscovery.APIGroupDiscoveryList {
0 commit comments