Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rootpaths #27

Merged
merged 2 commits into from
Jul 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import com.ning.http.client.filter.FilterException;
import com.ning.http.client.filter.RequestFilter;
import io.fabric8.kubernetes.api.model.*;
import io.fabric8.kubernetes.api.root.RootPaths;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Operation;
import io.fabric8.kubernetes.client.dsl.ProcessableResource;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.ScaleableResource;
import io.fabric8.kubernetes.client.dsl.internal.BaseOperation;
import io.fabric8.kubernetes.client.dsl.internal.BuildConfigOperationsImpl;
import io.fabric8.kubernetes.client.dsl.internal.BuildOperationsImpl;
import io.fabric8.kubernetes.client.dsl.internal.DeploymentConfigOperationsImpl;
Expand Down Expand Up @@ -249,6 +251,11 @@ public Operation<Template, TemplateList, DoneableTemplate, ProcessableResource<T
return new TemplateOperationsImpl(httpClient, openShiftUrl);
}

@Override
public RootPaths rootPaths() {
return (RootPaths) new BaseOperation(httpClient, masterUrl, "", null, null,RootPaths.class,null,null){}.get();
}

@Override
public Operation<Build, BuildList, DoneableBuild, Resource<Build, DoneableBuild>> builds() {
return new BuildOperationsImpl(httpClient, openShiftUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import io.fabric8.kubernetes.api.model.ServiceAccount;
import io.fabric8.kubernetes.api.model.ServiceAccountList;
import io.fabric8.kubernetes.api.model.ServiceList;
import io.fabric8.kubernetes.api.root.RootPaths;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Operation;
import io.fabric8.kubernetes.client.dsl.ProcessableResource;
Expand Down Expand Up @@ -91,4 +92,6 @@ public interface KubernetesClient extends AutoCloseable {

Operation<Template, TemplateList, DoneableTemplate, ProcessableResource<Template, DoneableTemplate>> templates();

RootPaths rootPaths();

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import static io.fabric8.kubernetes.client.internal.Utils.join;

public class BaseOperation<T extends HasMetadata, L extends KubernetesResourceList, D extends Doneable<T>, R extends Resource<T, D>>
public class BaseOperation<T, L extends KubernetesResourceList, D extends Doneable<T>, R extends Resource<T, D>>
implements Operation<T, L, D, R>,
NonNamespaceOperation<T, L, D, R>,
CreateWatchListDeleteable<T, L, D>,
Expand Down Expand Up @@ -102,8 +102,10 @@ protected BaseOperation(AsyncHttpClient httpClient, URL rootUrl, String resource
public T get() throws KubernetesClientException {
try {
URL requestUrl = getNamespacedUrl();
URL resourceUrl = new URL(requestUrl, name);
return handleGet(resourceUrl);
if (name != null) {
requestUrl = new URL(requestUrl, name);
}
return handleGet(requestUrl);
} catch (InterruptedException | ExecutionException | IOException e) {
throw KubernetesClientException.launderThrowable(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import io.fabric8.kubernetes.api.model.Doneable;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.client.dsl.Processable;
import io.fabric8.kubernetes.client.dsl.ProcessableResource;
import io.fabric8.kubernetes.client.dsl.Resource;

import java.net.URL;

public abstract class BaseProcessableOperation<T extends HasMetadata, L extends KubernetesResourceList, D extends Doneable<T>, R extends Resource<T, D>>
extends BaseOperation<T, L, D, R> implements Processable<T> {
extends BaseOperation<T, L, D, R> implements ProcessableResource<T,D> {

protected BaseProcessableOperation(AsyncHttpClient httpClient, URL rootUrl, String resourceT, String namespace, String name) {
super(httpClient, rootUrl, resourceT, namespace, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
import io.fabric8.kubernetes.client.dsl.Processable;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.Scaleable;
import io.fabric8.kubernetes.client.dsl.ScaleableResource;

import java.net.URL;

public abstract class BaseScaleableOperation<T extends HasMetadata, L extends KubernetesResourceList, D extends Doneable<T>, R extends Resource<T, D>>
extends BaseOperation<T, L, D, R> implements Scaleable {
extends BaseOperation<T, L, D, R> implements ScaleableResource<T,D> {

protected BaseScaleableOperation(AsyncHttpClient httpClient, URL rootUrl, String resourceT, String namespace, String name) {
super(httpClient, rootUrl, resourceT, namespace, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,15 @@ public void eventReceived(Action action, ReplicationController resource) {
client.replicationControllers().inNamespace("thisisatest").withField("metadata.name", "nginx-controller").delete();
log("Deleted RC by field");

log("Root paths:", client.rootPaths());

} finally {
// And finally clean up the namespace
client.namespaces().withName("thisisatest").delete();
log("Deleted namespace");
}
} catch (KubernetesClientException e) {
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);

Throwable[] suppressed = e.getSuppressed();
Expand Down