resource, Client client) {
super(resource, client);
}
@Override
public ServiceBinding bind(String secretName) {
ServiceInstance item = get();
- return new ServiceBindingOperationsImpl(context.withItem(null))
- .create(new ServiceBindingBuilder()
+ return client.adapt(ServiceCatalogClient.class)
+ .serviceBindings().create(new ServiceBindingBuilder()
.withNewMetadata()
.withName(item.getMetadata().getName())
+ .withNamespace(item.getMetadata().getNamespace())
.endMetadata()
.withNewSpec()
.withSecretName(secretName)
diff --git a/extensions/service-catalog/client/src/main/java/io/fabric8/servicecatalog/client/util/ApiVersionUtil.java b/extensions/service-catalog/client/src/main/java/io/fabric8/servicecatalog/client/util/ApiVersionUtil.java
index 59bdc5b5a2f..e06b2bba8e0 100644
--- a/extensions/service-catalog/client/src/main/java/io/fabric8/servicecatalog/client/util/ApiVersionUtil.java
+++ b/extensions/service-catalog/client/src/main/java/io/fabric8/servicecatalog/client/util/ApiVersionUtil.java
@@ -19,14 +19,16 @@
import io.fabric8.kubernetes.client.utils.Utils;
/**
- * Borrowed from the client.
+ * @deprecated
+ * @see io.fabric8.kubernetes.client.utils.ApiVersionUtil
*/
+@Deprecated
public class ApiVersionUtil {
private ApiVersionUtil() {
throw new IllegalStateException("Utility class");
}
-
+
/**
* Extracts apiGroupName from apiGroupVersion when in resource for apiGroupName/apiGroupVersion combination
* @param item resource which is being used
diff --git a/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/util/ApiVersionUtil.java b/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/util/ApiVersionUtil.java
index bd1c03d063c..fed9b3527ab 100644
--- a/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/util/ApiVersionUtil.java
+++ b/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/util/ApiVersionUtil.java
@@ -19,10 +19,12 @@
import io.fabric8.kubernetes.client.utils.Utils;
/**
- * Borrowed from the client.
+ * @deprecated
+ * @see io.fabric8.kubernetes.client.utils.ApiVersionUtil
*/
+@Deprecated
public class ApiVersionUtil {
-
+
private ApiVersionUtil() {
throw new IllegalStateException("Utility class");
}
@@ -32,7 +34,7 @@ private ApiVersionUtil() {
* @param apiGroup apiGroupName present if any
* @return Just the apiGroupName part without apiGroupVersion
*/
-
+
public static String apiGroup(T item, String apiGroup) {
if (item instanceof HasMetadata && Utils.isNotNullOrEmpty(((HasMetadata) item).getApiVersion())) {
return trimGroupOrNull(((HasMetadata) item).getApiVersion());
diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java
index 0551e7d5dbb..514fe1e36d1 100644
--- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java
+++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java
@@ -19,7 +19,11 @@
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.HasMetadata;
+import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.api.model.RootPaths;
+import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.Resource;
import java.io.Closeable;
import java.net.URL;
@@ -73,4 +77,41 @@ public interface Client extends ClientContext, Closeable {
* @return the {@link APIResourceList} for the groupVersion
*/
APIResourceList getApiResources(String groupVersion);
+
+ /**
+ * Typed API for managing resources. Any properly annotated POJO can be utilized as a resource.
+ *
+ *
+ * Note: your resource POJO (T in this context) must implement
+ * {@link io.fabric8.kubernetes.api.model.Namespaced} if it is a namespace-scoped resource.
+ *
+ *
+ * @param resourceType Class for resource
+ * @param represents resource type. If it's a namespaced resource, it must implement
+ * {@link io.fabric8.kubernetes.api.model.Namespaced}
+ * @param represents resource list type
+ * @param represents the Resource operation type
+ * @return returns a MixedOperation object with which you can do basic resource operations. If the class is a known type the dsl operation logic will be used.
+ */
+ , R extends Resource> MixedOperation resources(
+ Class resourceType, Class listClass, Class resourceClass);
+
+ /**
+ * Typed API for managing resources. Any properly annotated POJO can be utilized as a resource.
+ *
+ *
+ * Note: your resource POJO (T in this context) must implement
+ * {@link io.fabric8.kubernetes.api.model.Namespaced} if it is a namespace-scoped resource.
+ *
+ *
+ * @param resourceType Class for resource
+ * @param represents resource type. If it's a namespaced resource, it must implement
+ * {@link io.fabric8.kubernetes.api.model.Namespaced}
+ * @param represents resource list type
+ * @return returns a MixedOperation object with which you can do basic resource operations. If the class is a known type the dsl operation logic will be used.
+ */
+ default > MixedOperation> resources(
+ Class resourceType, Class listClass) {
+ return resources(resourceType, listClass, Resource.class);
+ }
}
diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapter.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapter.java
index 4252336ace7..e1f32f056d5 100644
--- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapter.java
+++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapter.java
@@ -18,6 +18,7 @@
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.client.dsl.Resource;
+import io.fabric8.kubernetes.client.extension.ExtensibleResource;
import java.util.function.BiFunction;
@@ -29,7 +30,7 @@
public interface ExtensionAdapter {
public interface HandlerFactory {
- > void register(Class type, BiFunction, Client, R> target);
+ > void register(Class type, BiFunction, Client, R> target);
}
/**
diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapterSupport.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapterSupport.java
index 707e14f7d98..493e453ef0a 100644
--- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapterSupport.java
+++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ExtensionAdapterSupport.java
@@ -22,6 +22,7 @@
import java.util.concurrent.ConcurrentMap;
public abstract class ExtensionAdapterSupport {
+
protected Boolean isAdaptable(Client client, ConcurrentMap isApi, ConcurrentMap usesApiGroups, String apiGroup) {
URL masterUrl = client.getMasterUrl();
if (isApi.containsKey(masterUrl)) {
diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java
index 5277e9ea2c4..a27592cff5a 100644
--- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java
+++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NonNamespaceOperation.java
@@ -31,5 +31,7 @@ public interface NonNamespaceOperation extends
Replaceable,
StatusReplaceable,
Loadable {
+
+ R withItem(T item);
}
diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Operation.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Operation.java
index 07410c0a446..8a20679f415 100644
--- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Operation.java
+++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Operation.java
@@ -27,4 +27,6 @@ public interface Operation
Namespaceable>,
FilterWatchListMultiDeletable,
Loadable {
+
+ R withItem(T item);
}
diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ClientAdapter.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ClientAdapter.java
index c98df948e48..baa18547d86 100644
--- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ClientAdapter.java
+++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ClientAdapter.java
@@ -1,3 +1,19 @@
+/**
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.fabric8.kubernetes.client.extension;
import io.fabric8.kubernetes.api.model.APIGroup;
@@ -8,22 +24,31 @@
import io.fabric8.kubernetes.api.model.RootPaths;
import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.client.Config;
+import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.NamespacedKubernetesClient;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.http.HttpClient;
import java.net.URL;
-import java.util.function.Function;
-public abstract class ClientAdapter implements Client {
+/**
+ * To be used as the base class for creating extension clients
+ */
+public abstract class ClientAdapter implements Client {
protected Client client;
- private Function newInstance;
- public ClientAdapter(Client client, Function newInstance) {
+ public ClientAdapter() {
+ this(new KubernetesClientBuilder().build());
+ }
+
+ public ClientAdapter(Config configuration) {
+ this(new KubernetesClientBuilder().withConfig(configuration).build());
+ }
+
+ public ClientAdapter(Client client) {
this.client = client;
- this.newInstance = newInstance;
}
@Override
@@ -37,12 +62,12 @@ public Config getConfiguration() {
}
@Override
- public Boolean isAdaptable(Class type) {
+ public Boolean isAdaptable(Class type) {
return client.isAdaptable(type);
}
@Override
- public C adapt(Class type) {
+ public A adapt(Class type) {
return client.adapt(type);
}
@@ -91,20 +116,20 @@ public APIResourceList getApiResources(String groupVersion) {
return client.getApiResources(groupVersion);
}
+ @Override
public , R extends Resource> MixedOperation resources(
Class resourceType, Class listClass, Class resourceClass) {
+ return client.resources(resourceType, listClass, resourceClass);
}
- public > MixedOperation> resources(
- Class resourceType, Class listClass) {
- }
-
- public T inAnyNamespace() {
+ public C inAnyNamespace() {
return inNamespace(null);
}
- public T inNamespace(String namespace) {
- return newInstance.apply(client.adapt(NamespacedKubernetesClient.class).inNamespace(namespace));
+ public C inNamespace(String namespace) {
+ return newInstance(client.adapt(NamespacedKubernetesClient.class).inNamespace(namespace));
}
+ protected abstract C newInstance(Client client);
+
}
diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ExtensibleResource.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ExtensibleResource.java
new file mode 100644
index 00000000000..5b1a3705399
--- /dev/null
+++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ExtensibleResource.java
@@ -0,0 +1,63 @@
+/**
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fabric8.kubernetes.client.extension;
+
+import io.fabric8.kubernetes.api.model.DeletionPropagation;
+import io.fabric8.kubernetes.client.dsl.Resource;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+
+/**
+ * Provides an interface that is usable by the {@link ResourceAdapter} that returns
+ * a non-specialized value
+ */
+public interface ExtensibleResource extends Resource {
+
+ @Override
+ ExtensibleResource lockResourceVersion(String resourceVersion);
+
+ @Override
+ ExtensibleResource cascading(boolean enabled);
+
+ @Override
+ ExtensibleResource dryRun(boolean isDryRun);
+
+ @Override
+ ExtensibleResource withResourceVersion(String resourceVersion);
+
+ @Override
+ ExtensibleResource fromServer();
+
+ @Override
+ ExtensibleResource withGracePeriod(long gracePeriodSeconds);
+
+ @Override
+ ExtensibleResource withPropagationPolicy(DeletionPropagation propagationPolicy);
+
+ @Override
+ ExtensibleResource withWaitRetryBackoff(long initialBackoff, TimeUnit backoffUnit, double backoffMultiplier);
+
+ @Override
+ ExtensibleResource withIndexers(Map>> indexers);
+
+ @Override
+ ExtensibleResource withLimit(Long limit);
+
+}
diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ResourceAdapter.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ResourceAdapter.java
index 2a5cf3f50a6..8aa37c3d499 100644
--- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ResourceAdapter.java
+++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/ResourceAdapter.java
@@ -1,3 +1,19 @@
+/**
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.fabric8.kubernetes.client.extension;
import io.fabric8.kubernetes.api.builder.Visitor;
@@ -31,10 +47,10 @@
public class ResourceAdapter implements Resource {
- protected Resource resource;
+ protected ExtensibleResource resource;
protected Client client;
- public ResourceAdapter(Resource resource, Client client) {
+ public ResourceAdapter(ExtensibleResource resource, Client client) {
this.resource = resource;
this.client = client;
}
@@ -56,17 +72,12 @@ public T get() {
@Override
public ReplaceDeletable lockResourceVersion(String resourceVersion) {
- return resource.lockResourceVersion(resourceVersion);
+ return new ResourceAdapter<>(resource.lockResourceVersion(resourceVersion), client);
}
@Override
public EditReplacePatchDeletable cascading(boolean enabled) {
- return resource.cascading(enabled);
- }
-
- @Override
- public WritableOperation dryRun() {
- return resource.dryRun();
+ return new ResourceAdapter<>(resource.cascading(enabled), client);
}
@Override
@@ -81,12 +92,12 @@ public T updateStatus(T item) {
@Override
public WatchAndWaitable withResourceVersion(String resourceVersion) {
- return resource.withResourceVersion(resourceVersion);
+ return new ResourceAdapter<>(resource.withResourceVersion(resourceVersion), client);
}
@Override
public Gettable fromServer() {
- return resource.fromServer();
+ return new ResourceAdapter<>(resource.fromServer(), client);
}
@Override
@@ -101,7 +112,7 @@ public T create(T... item) {
@Override
public Deletable withGracePeriod(long gracePeriodSeconds) {
- return resource.withGracePeriod(gracePeriodSeconds);
+ return new ResourceAdapter<>(resource.withGracePeriod(gracePeriodSeconds), client);
}
@Override
@@ -126,7 +137,7 @@ public T require() throws ResourceNotFoundException {
@Override
public EditReplacePatchDeletable withPropagationPolicy(DeletionPropagation propagationPolicy) {
- return resource.withPropagationPolicy(propagationPolicy);
+ return new ResourceAdapter<>(resource.withPropagationPolicy(propagationPolicy), client);
}
@Override
@@ -166,17 +177,17 @@ public T waitUntilCondition(Predicate condition, long amount, TimeUnit timeUn
@Override
public Waitable withWaitRetryBackoff(long initialBackoff, TimeUnit backoffUnit, double backoffMultiplier) {
- return resource.withWaitRetryBackoff(initialBackoff, backoffUnit, backoffMultiplier);
+ return new ResourceAdapter<>(resource.withWaitRetryBackoff(initialBackoff, backoffUnit, backoffMultiplier), client);
}
@Override
public Informable withIndexers(Map>> indexers) {
- return resource.withIndexers(indexers);
+ return new ResourceAdapter<>(resource.withIndexers(indexers), client);
}
@Override
public WritableOperation dryRun(boolean isDryRun) {
- return resource.dryRun(isDryRun);
+ return new ResourceAdapter<>(resource.dryRun(isDryRun), client);
}
@Override
@@ -191,7 +202,7 @@ public T patch(PatchContext patchContext, T item) {
@Override
public Informable withLimit(Long limit) {
- return resource.withLimit(limit);
+ return new ResourceAdapter<>(resource.withLimit(limit), client);
}
@Override
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java
index 6d4dd7391db..c616734976c 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java
@@ -16,11 +16,15 @@
package io.fabric8.kubernetes.client;
+import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.base.OperationSupport;
import io.fabric8.kubernetes.client.http.HttpClient;
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.HasMetadata;
+import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.api.model.RootPaths;
import io.fabric8.kubernetes.client.utils.HttpClientUtils;
import io.fabric8.kubernetes.client.utils.Utils;
@@ -159,4 +163,12 @@ protected void adaptState() {
protected SimpleClientContext newState(Config updated) {
return new SimpleClientContext(updated, httpClient);
}
+
+ @Override
+ public , R extends Resource> MixedOperation resources(
+ Class resourceType, Class listClass, Class resourceClass) {
+ // TODO: make this more robust
+ return Handlers.getOperation(resourceType, listClass, this);
+ }
+
}
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ResourcedHasMetadataOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ResourcedHasMetadataOperation.java
index a8e66f9a9fe..08e65ff2a42 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ResourcedHasMetadataOperation.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/ResourcedHasMetadataOperation.java
@@ -1,23 +1,39 @@
+/**
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.fabric8.kubernetes.client;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.client.dsl.Resource;
-import io.fabric8.kubernetes.client.dsl.base.BaseOperation;
-import io.fabric8.kubernetes.client.dsl.base.HasMetadataOperation;
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
+import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext;
import io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperationsImpl;
+import io.fabric8.kubernetes.client.extension.ExtensibleResource;
import io.fabric8.kubernetes.client.utils.KubernetesResourceUtil;
import java.util.function.BiFunction;
class ResourcedHasMetadataOperation, R extends Resource>
- extends HasMetadataOperation {
+ extends HasMetadataOperationsImpl {
- private BiFunction, Client, R> adapter;
+ private BiFunction, Client, R> adapter;
- public ResourcedHasMetadataOperation(OperationContext ctx, Class type, Class listType, BiFunction, Client, R> adapter) {
- super(ctx, type, listType);
+ public ResourcedHasMetadataOperation(OperationContext ctx, ResourceDefinitionContext resourceDefinitionContext, Class type, Class listType, BiFunction, Client, R> adapter) {
+ super(ctx, resourceDefinitionContext, type, listType);
this.adapter = adapter;
}
@@ -25,16 +41,16 @@ public ResourcedHasMetadataOperation(OperationContext ctx, Class type, Class<
protected R newResource(OperationContext context) {
return adapter.apply(super.newInstance(context), new BaseClient(context));
}
-
+
@Override
- public BaseOperation newInstance(OperationContext context) {
- return new ResourcedHasMetadataOperation<>(context, type, listType, adapter);
+ public HasMetadataOperationsImpl newInstance(OperationContext context) {
+ return new ResourcedHasMetadataOperation<>(context, this.rdc, type, listType, adapter);
}
public static , R extends Resource> void register(
- Class type, BiFunction, Client, R> target) {
+ Class type, BiFunction, Client, R> target) {
Handlers.register(type, (c) -> {
- return new ResourcedHasMetadataOperation<>(HasMetadataOperationsImpl.defaultContext(c), type,
+ return new ResourcedHasMetadataOperation<>(HasMetadataOperationsImpl.defaultContext(c), ResourceDefinitionContext.fromResourceType(type), type,
KubernetesResourceUtil.inferListType(type), target);
});
}
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java
index b67d51c2eb4..ba5dfaea6cc 100755
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java
@@ -15,10 +15,6 @@
*/
package io.fabric8.kubernetes.client.dsl.base;
-import io.fabric8.kubernetes.api.model.ObjectReference;
-import io.fabric8.kubernetes.client.dsl.WritableOperation;
-import io.fabric8.kubernetes.client.utils.CreateOrReplaceHelper;
-import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.kubernetes.api.builder.TypedVisitor;
import io.fabric8.kubernetes.api.builder.Visitor;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
@@ -27,6 +23,7 @@
import io.fabric8.kubernetes.api.model.LabelSelector;
import io.fabric8.kubernetes.api.model.ListOptions;
import io.fabric8.kubernetes.api.model.ListOptionsBuilder;
+import io.fabric8.kubernetes.api.model.ObjectReference;
import io.fabric8.kubernetes.api.model.Status;
import io.fabric8.kubernetes.api.model.autoscaling.v1.Scale;
import io.fabric8.kubernetes.api.model.extensions.DeploymentRollback;
@@ -38,24 +35,23 @@
import io.fabric8.kubernetes.client.ResourceNotFoundException;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
-import io.fabric8.kubernetes.client.dsl.EditReplacePatchDeletable;
import io.fabric8.kubernetes.client.dsl.FilterNested;
import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
-import io.fabric8.kubernetes.client.dsl.Gettable;
-import io.fabric8.kubernetes.client.dsl.Informable;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
-import io.fabric8.kubernetes.client.dsl.ReplaceDeletable;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.internal.DefaultOperationInfo;
import io.fabric8.kubernetes.client.dsl.internal.WatchConnectionManager;
import io.fabric8.kubernetes.client.dsl.internal.WatchHTTPManager;
+import io.fabric8.kubernetes.client.extension.ExtensibleResource;
import io.fabric8.kubernetes.client.http.HttpRequest;
import io.fabric8.kubernetes.client.informers.ListerWatcher;
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
import io.fabric8.kubernetes.client.informers.impl.DefaultSharedIndexInformer;
import io.fabric8.kubernetes.client.readiness.Readiness;
+import io.fabric8.kubernetes.client.utils.CreateOrReplaceHelper;
+import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.kubernetes.client.utils.URLUtils;
import io.fabric8.kubernetes.client.utils.URLUtils.URLBuilder;
import io.fabric8.kubernetes.client.utils.Utils;
@@ -85,7 +81,7 @@ public class BaseOperation,
- Resource,
+ ExtensibleResource,
ListerWatcher {
private static final String WATCH = "watch";
@@ -239,7 +235,7 @@ public R withName(String name) {
}
@Override
- public ReplaceDeletable lockResourceVersion(String resourceVersion) {
+ public ExtensibleResource lockResourceVersion(String resourceVersion) {
return newInstance(context.withResourceVersion(resourceVersion));
}
@@ -256,7 +252,7 @@ public NonNamespaceOperation inAnyNamespace() {
@Override
- public EditReplacePatchDeletable cascading(boolean cascading) {
+ public ExtensibleResource cascading(boolean cascading) {
return newInstance(context.withCascading(cascading).withPropagationPolicy(null));
}
@@ -289,7 +285,7 @@ public R load(String path) {
}
@Override
- public Gettable fromServer() {
+ public ExtensibleResource fromServer() {
return newInstance(context.withReloadingFromServer(true));
}
@@ -520,8 +516,9 @@ public T patchStatus(T item) {
throw new KubernetesClientException(READ_ONLY_UPDATE_EXCEPTION_MESSAGE);
}
- public BaseOperation withItem(T item) {
- return newInstance(context.withItem(item));
+ @Override
+ public R withItem(T item) {
+ return newResource(context.withItem(item));
}
void deleteThis() {
@@ -778,12 +775,12 @@ public OperationInfo forOperationType(String type) {
}
@Override
- public FilterWatchListDeletable withGracePeriod(long gracePeriodSeconds) {
+ public ExtensibleResource withGracePeriod(long gracePeriodSeconds) {
return newInstance(context.withGracePeriodSeconds(gracePeriodSeconds));
}
@Override
- public EditReplacePatchDeletable withPropagationPolicy(DeletionPropagation propagationPolicy) {
+ public ExtensibleResource withPropagationPolicy(DeletionPropagation propagationPolicy) {
return newInstance(context.withPropagationPolicy(propagationPolicy));
}
@@ -928,12 +925,12 @@ public void setNamespace(String namespace) {
}
@Override
- public WritableOperation dryRun(boolean isDryRun) {
+ public ExtensibleResource dryRun(boolean isDryRun) {
return newInstance(context.withDryRun(isDryRun));
}
@Override
- public Informable withIndexers(Map>> indexers) {
+ public ExtensibleResource withIndexers(Map>> indexers) {
BaseOperation result = newInstance(context);
result.indexers = indexers;
result.limit = this.limit;
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/HasMetadataOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/HasMetadataOperation.java
index 36cb1eae1a2..e269bf625de 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/HasMetadataOperation.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/HasMetadataOperation.java
@@ -117,16 +117,16 @@ protected T requireFromServer() {
protected T requireFromServer(ObjectMeta metadata) {
try {
if (Utils.isNotNullOrEmpty(getName())) {
- return withItem(null).require();
+ return newInstance(context.withItem(null)).require();
}
if (getItem() != null) {
String name = KubernetesResourceUtil.getName(getItem());
if (Utils.isNotNullOrEmpty(name)) {
- return withItem(null).withName(name).require();
+ return newInstance(context.withItem(null)).withName(name).require();
}
}
if (metadata != null && Utils.isNotNullOrEmpty(metadata.getName())) {
- return withItem(null).withName(metadata.getName()).require();
+ return newInstance(context.withItem(null)).withName(metadata.getName()).require();
}
} catch (ResourceNotFoundException e) {
if (e.getCause() instanceof KubernetesClientException) {
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperationsImpl.java
index 7db57dd9973..5cdcab09523 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperationsImpl.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperationsImpl.java
@@ -32,7 +32,7 @@
public class HasMetadataOperationsImpl> extends HasMetadataOperation> implements MixedOperation> {
- private final ResourceDefinitionContext rdc;
+ protected final ResourceDefinitionContext rdc;
public HasMetadataOperationsImpl(ClientContext clientContext, ResourceDefinitionContext rdc, Class type, Class listType) {
this(defaultContext(clientContext), rdc, type, listType);
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/batch/v1/JobOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/batch/v1/JobOperationsImpl.java
index 67e63daf427..9d48bd31c70 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/batch/v1/JobOperationsImpl.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/batch/v1/JobOperationsImpl.java
@@ -80,11 +80,6 @@ public ScalableResource load(InputStream is) {
}
}
- @Override
- public ScalableResource fromServer() {
- return newInstance(context.withReloadingFromServer(true));
- }
-
@Override
public Job scale(int count) {
return scale(count, false);
diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodOperationUtilTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodOperationUtilTest.java
index 861651edf4e..1f9f2022d89 100644
--- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodOperationUtilTest.java
+++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/utils/PodOperationUtilTest.java
@@ -20,11 +20,11 @@
import io.fabric8.kubernetes.api.model.PodList;
import io.fabric8.kubernetes.api.model.PodListBuilder;
import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
-import io.fabric8.kubernetes.client.dsl.Gettable;
import io.fabric8.kubernetes.client.dsl.LogWatch;
import io.fabric8.kubernetes.client.dsl.PodResource;
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
import io.fabric8.kubernetes.client.dsl.internal.core.v1.PodOperationsImpl;
+import io.fabric8.kubernetes.client.extension.ExtensibleResource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -91,7 +91,8 @@ void testWaitUntilReadyBeforeFetchingLogs() throws InterruptedException {
.withNewMetadata().withName("foo").endMetadata()
.withNewStatus().withPhase("Pending").endStatus()
.build();
- Gettable gettablePod = () -> pod;
+ ExtensibleResource gettablePod = Mockito.mock(ExtensibleResource.class);
+ when(gettablePod.get()).thenReturn(pod);
when(podOperations.fromServer()).thenReturn(gettablePod);
when(podOperations.waitUntilReady(5, TimeUnit.SECONDS)).thenReturn(pod);