File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed
util/src/main/java/io/kubernetes/client/util Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -340,20 +340,15 @@ public static GroupVersionKind groupVersionKindFromApiVersionAndKind(
340340 }
341341
342342 public static Discovery .APIResource findApiResourceByGroupVersionKind (GroupVersionKind gvk ) {
343- // TODO: Create another hash map to make this lookup fast? For now I don't think it matters, but
344- // it's definitely slow.
343+ Map <String , Discovery .APIResource > apiResourcesByKey = new HashMap <>();
345344 for (Discovery .APIResource apiResource : lastAPIDiscovery ) {
346- if (!apiResource .getGroup ().equals (gvk .getGroup ())
347- || !apiResource .getKind ().equals (gvk .getKind ())) {
348- continue ;
349- }
350345 for (String version : apiResource .getVersions ()) {
351- if (version .equals (gvk .getVersion ())) {
352- return apiResource ;
353- }
346+ String key = apiResource .getKind () + "/" + apiResource .getGroup () + "/" + version ;
347+ apiResourcesByKey .put (key , apiResource );
354348 }
355349 }
356- return null ;
350+ String key = gvk .getKind () + "/" + gvk .getGroup () + "/" + gvk .getVersion ();
351+ return apiResourcesByKey .get (key );
357352 }
358353
359354 private static void initApiGroupMap () {
You can’t perform that action at this time.
0 commit comments