@@ -98,17 +98,18 @@ func createCRDs(ctx context.Context, config *rest.Config, crds []*apiextensionsv
98
98
}
99
99
100
100
func waitForDiscovery (ctx context.Context , config * rest.Config , crds []* apiextensionsv1.CustomResourceDefinition ) error {
101
- gvrs := map [schema. GroupVersionResource ] struct {}{}
101
+ resourcesByGV := make ( map [string ] map [ string ] struct {}, 0 )
102
102
for _ , crd := range crds {
103
103
for _ , version := range crd .Spec .Versions {
104
104
if ! version .Served {
105
105
continue
106
106
}
107
- gvrs [schema.GroupVersionResource {
108
- Group : crd .Spec .Group ,
109
- Version : version .Name ,
110
- Resource : crd .Spec .Names .Plural ,
111
- }] = struct {}{}
107
+ gv := schema.GroupVersion {Version : version .Name , Group : crd .Spec .Group }.String ()
108
+ _ , ok := resourcesByGV [gv ]
109
+ if ! ok {
110
+ resourcesByGV [gv ] = make (map [string ]struct {}, 0 )
111
+ }
112
+ resourcesByGV [gv ][crd .Spec .Names .Plural ] = struct {}{}
112
113
}
113
114
}
114
115
discoveryClient , err := discovery .NewDiscoveryClientForConfig (config )
@@ -123,15 +124,17 @@ func waitForDiscovery(ctx context.Context, config *rest.Config, crds []*apiexten
123
124
}
124
125
125
126
for _ , gv := range serverGVRs {
127
+ if _ , ok := resourcesByGV [gv .GroupVersion ]; ! ok {
128
+ continue
129
+ }
126
130
for _ , r := range gv .APIResources {
127
- delete (gvrs , schema.GroupVersionResource {
128
- Group : r .Group ,
129
- Version : r .Version ,
130
- Resource : r .Name ,
131
- })
131
+ delete (resourcesByGV [gv .GroupVersion ], r .Name )
132
+ }
133
+ if len (resourcesByGV [gv .GroupVersion ]) == 0 {
134
+ delete (resourcesByGV , gv .GroupVersion )
132
135
}
133
136
}
134
137
135
- return len (gvrs ) == 0 , nil
138
+ return len (resourcesByGV ) == 0 , nil
136
139
})
137
140
}
0 commit comments