Skip to content

Commit

Permalink
fix fabric8io#3294 fabric8io#3303 adding a get for a single api group
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Aug 31, 2021
1 parent 9cf5938 commit 7584c09
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
import io.fabric8.kubernetes.api.model.APIGroup;
import io.fabric8.kubernetes.api.model.APIGroupList;
import io.fabric8.kubernetes.api.model.APIResourceList;
import io.fabric8.kubernetes.api.model.RootPaths;
Expand Down Expand Up @@ -166,6 +167,11 @@ public APIGroupList getApiGroups() {
return newBaseOperation(httpClient, configuration).restCall(APIGroupList.class, APIS);
}

@Override
public APIGroup getApiGroup(String name) {
return newBaseOperation(httpClient, configuration).restCall(APIGroup.class, APIS, name);
}

@Override
public APIResourceList getApiResources(String groupVersion) {
return newBaseOperation(httpClient, configuration).restCall(APIResourceList.class, APIS, groupVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.fabric8.kubernetes.client;

import io.fabric8.kubernetes.api.model.APIGroup;
import io.fabric8.kubernetes.api.model.APIGroupList;
import io.fabric8.kubernetes.api.model.APIResourceList;
import io.fabric8.kubernetes.api.model.RootPaths;
Expand Down Expand Up @@ -59,6 +60,12 @@ public interface Client extends ConfigAware, Closeable {
*/
APIGroupList getApiGroups();

/**
* Return a single api group
* @return the {@link APIGroup} metadata
*/
APIGroup getApiGroup(String name);

/**
* Return the api resource metadata for the given groupVersion
* @param the groupVersion - group/version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.fabric8.kubernetes;

import io.fabric8.kubernetes.api.model.APIGroup;
import io.fabric8.kubernetes.api.model.APIGroupList;
import io.fabric8.kubernetes.api.model.APIResourceList;
import io.fabric8.kubernetes.client.KubernetesClient;
Expand All @@ -26,6 +27,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

@RunWith(ArquillianConditionalRunner.class)
Expand All @@ -45,6 +48,17 @@ public void testApiGroups() throws InterruptedException {
assertTrue(list.getGroups().stream().anyMatch(g -> "apps".equals(g.getName())));
}

@Test
public void testApiGroup() throws InterruptedException {
APIGroup group = client.getApiGroup("apps");

assertNotNull(group);

group = client.getApiGroup("apps-that-wont-exist");

assertNull(group);
}

@Test
public void testApiResources() throws InterruptedException {
APIResourceList list = client.getApiResources("apps/v1");
Expand Down

0 comments on commit 7584c09

Please sign in to comment.