pods() {
return new PodOperationsImpl(this);
}
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/NamespaceableResourceAdapter.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/NamespaceableResourceAdapter.java
index 07ecbf7b89b..d6bb2bc3518 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/NamespaceableResourceAdapter.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/NamespaceableResourceAdapter.java
@@ -29,27 +29,30 @@
* {@link NamespaceableResource} is not {@link Namespaceable} to allow for future versions of the logic
* to be consolidated.
*
- * With generic typed interface design Namespacable<X> and Namespaceable<Y> are considered incompatible no matter the types for X and Y,
- * but NamespaceableX and NamespaceableY can be polymorphic. As long as there is no usage expectation
+ * With generic typed interface design Namespacable<X> and Namespaceable<Y> are considered incompatible no matter
+ * the types for X and Y,
+ * but NamespaceableX and NamespaceableY can be polymorphic. As long as there is no usage expectation
* like instanceof Namespaceable - then it would be fine to have the non-generic versions.
*
- * The constructor and the inNamespace method determine the namespacing rules:
- * - if the item is namespaced, the resource context will use that namespace as that is not currently the default behavior of withItem
+ * The constructor and the inNamespace method determine the namespacing rules:
+ * - if the item is namespaced, the resource context will use that namespace as that is not currently the default behavior of
+ * withItem
*/
-public class NamespaceableResourceAdapter extends ResourceAdapter implements NamespaceableResource {
-
+public class NamespaceableResourceAdapter extends ResourceAdapter
+ implements NamespaceableResource {
+
protected final T item;
protected final HasMetadataOperation operation;
-
+
public NamespaceableResourceAdapter(T item, HasMetadataOperation op) {
- super(op.withItem(item));
+ super(op.resource(item));
this.operation = op;
this.item = item;
}
@Override
public Resource inNamespace(String name) {
- return operation.inNamespace(name).withItem(item);
+ return operation.inNamespace(name).resource(item);
}
-
+
}
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/BaseOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/BaseOperation.java
index 117d53d1b5a..cca0ddfbf52 100755
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/BaseOperation.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/BaseOperation.java
@@ -73,6 +73,7 @@
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
+import java.util.stream.Stream;
public class BaseOperation, R extends Resource>
extends CreateOnlyResourceOperation
@@ -257,7 +258,7 @@ public ExtensibleResource cascading(boolean cascading) {
@Override
public R load(InputStream is) {
- return withItem(unmarshal(is, type));
+ return resource(unmarshal(is, type));
}
@Override
@@ -297,7 +298,7 @@ public final T createOrReplace(T... items) {
throw new IllegalArgumentException("Too many items to create.");
} else if (items.length == 1) {
itemToCreateOrReplace = items[0];
- resource = withItem(itemToCreateOrReplace);
+ resource = resource(itemToCreateOrReplace);
} else {
itemToCreateOrReplace = getItem();
resource = this;
@@ -317,57 +318,57 @@ public final T createOrReplace(T... items) {
}
@Override
- public FilterWatchListDeletable withLabels(Map labels) {
+ public FilterWatchListDeletable withLabels(Map labels) {
return withNewFilter().withLabels(labels).endFilter();
}
@Override
- public FilterWatchListDeletable withLabelSelector(LabelSelector selector) {
+ public FilterWatchListDeletable withLabelSelector(LabelSelector selector) {
return withNewFilter().withLabelSelector(selector).endFilter();
}
@Override
- public FilterWatchListDeletable withoutLabels(Map labels) {
+ public FilterWatchListDeletable withoutLabels(Map labels) {
return withNewFilter().withoutLabels(labels).endFilter();
}
@Override
- public FilterWatchListDeletable withLabelIn(String key, String... values) {
+ public FilterWatchListDeletable withLabelIn(String key, String... values) {
return withNewFilter().withLabelIn(key, values).endFilter();
}
@Override
- public FilterWatchListDeletable withLabelNotIn(String key, String... values) {
+ public FilterWatchListDeletable withLabelNotIn(String key, String... values) {
return withNewFilter().withLabelNotIn(key, values).endFilter();
}
@Override
- public FilterWatchListDeletable withLabel(String key, String value) {
+ public FilterWatchListDeletable withLabel(String key, String value) {
return withNewFilter().withLabel(key, value).endFilter();
}
@Override
- public FilterWatchListDeletable withoutLabel(String key, String value) {
+ public FilterWatchListDeletable withoutLabel(String key, String value) {
return withNewFilter().withoutLabel(key, value).endFilter();
}
@Override
- public FilterWatchListDeletable withLabelSelector(String selectorAsString) {
+ public FilterWatchListDeletable withLabelSelector(String selectorAsString) {
return withNewFilter().withLabelSelector(selectorAsString).endFilter();
}
@Override
- public FilterWatchListDeletable withFields(Map fields) {
+ public FilterWatchListDeletable withFields(Map fields) {
return withNewFilter().withFields(fields).endFilter();
}
@Override
- public FilterWatchListDeletable withField(String key, String value) {
+ public FilterWatchListDeletable withField(String key, String value) {
return withNewFilter().withField(key, value).endFilter();
}
@Override
- public FilterWatchListDeletable withInvolvedObject(ObjectReference objectReference) {
+ public FilterWatchListDeletable withInvolvedObject(ObjectReference objectReference) {
if (objectReference != null) {
return withNewFilter().withInvolvedObject(objectReference).endFilter();
}
@@ -375,17 +376,17 @@ public FilterWatchListDeletable withInvolvedObject(ObjectReference objectR
}
@Override
- public FilterNested> withNewFilter() {
+ public FilterNested> withNewFilter() {
return new FilterNestedImpl<>(this);
}
@Override
- public FilterWatchListDeletable withoutFields(Map fields) {
+ public FilterWatchListDeletable withoutFields(Map fields) {
return withNewFilter().withoutFields(fields).endFilter();
}
@Override
- public FilterWatchListDeletable withoutField(String key, String value) {
+ public FilterWatchListDeletable withoutField(String key, String value) {
return withNewFilter().withoutField(key, value).endFilter();
}
@@ -478,7 +479,7 @@ public boolean delete(List items) {
updateApiVersion(toDelete);
try {
- deleted &= withItem(toDelete).delete();
+ deleted &= resource(toDelete).delete();
} catch (KubernetesClientException e) {
if (e.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
throw e;
@@ -509,7 +510,7 @@ public T patchStatus(T item) {
}
@Override
- public R withItem(T item) {
+ public R resource(T item) {
// set the name, namespace, and item - not all operations are looking at the item for the name
// things like configMaps().load(...).watch(...) for example
item = correctNamespace(item);
@@ -1011,4 +1012,9 @@ public static URL appendListOptionParams(URL base, ListOptions listOptions) {
return urlBuilder.build();
}
+ @Override
+ public Stream resources() {
+ return list().getItems().stream().map(this::resource);
+ }
+
}
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/CreateOnlyResourceOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/CreateOnlyResourceOperation.java
index d8a5c834ee7..746b53227aa 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/CreateOnlyResourceOperation.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/CreateOnlyResourceOperation.java
@@ -23,7 +23,7 @@
public class CreateOnlyResourceOperation extends OperationSupport implements InOutCreateable {
protected Class type;
-
+
protected CreateOnlyResourceOperation(OperationContext ctx) {
super(ctx);
}
@@ -31,7 +31,7 @@ protected CreateOnlyResourceOperation(OperationContext ctx) {
public Class getType() {
return type;
}
-
+
protected O handleCreate(I resource) throws ExecutionException, InterruptedException, IOException {
return handleCreate(resource, getType());
}
@@ -39,19 +39,12 @@ protected O handleCreate(I resource) throws ExecutionException, InterruptedExcep
@SafeVarargs
@Override
public final O create(I... resources) {
- try {
- if (resources.length > 1) {
- throw new IllegalArgumentException("Too many items to create.");
- } else if (resources.length == 1) {
- return handleCreate(resources[0]);
- } else {
- return handleCreate(getItem());
- }
- } catch (ExecutionException | IOException e) {
- throw KubernetesClientException.launderThrowable(e);
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- throw KubernetesClientException.launderThrowable(ie);
+ if (resources.length > 1) {
+ throw new IllegalArgumentException("Too many items to create.");
+ } else if (resources.length == 1) {
+ return create(resources[0]);
+ } else {
+ return create(getItem());
}
}
@@ -70,5 +63,5 @@ public O create(I item) {
public I getItem() {
return (I) context.getItem();
}
-
+
}
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/FilterNestedImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/FilterNestedImpl.java
index 7f9e1c8376e..61ca7c9bbf6 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/FilterNestedImpl.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/FilterNestedImpl.java
@@ -31,8 +31,9 @@
import java.util.List;
import java.util.Map;
-final class FilterNestedImpl, R extends Resource> implements FilterNested> {
-
+final class FilterNestedImpl, R extends Resource>
+ implements FilterNested> {
+
private static final String INVOLVED_OBJECT_NAME = "involvedObject.name";
private static final String INVOLVED_OBJECT_NAMESPACE = "involvedObject.namespace";
private static final String INVOLVED_OBJECT_KIND = "involvedObject.kind";
@@ -40,7 +41,7 @@ final class FilterNestedImpl baseOperation;
private OperationContext context;
@@ -61,39 +62,39 @@ final class FilterNestedImpl> withLabels(Map labels) {
+ public FilterNested> withLabels(Map labels) {
this.context.labels.putAll(labels);
return this;
}
@Override
- public FilterNested> withoutLabels(Map labels) {
+ public FilterNested> withoutLabels(Map labels) {
// Re-use "withoutLabel" to convert values from String to String[]
labels.forEach(this::withoutLabel);
return this;
}
@Override
- public FilterNested> withLabelIn(String key, String... values) {
+ public FilterNested> withLabelIn(String key, String... values) {
context.labelsIn.put(key, values);
return this;
}
@Override
- public FilterNested> withLabelNotIn(String key, String... values) {
+ public FilterNested> withLabelNotIn(String key, String... values) {
context.labelsNotIn.put(key, values);
return this;
}
@Override
- public FilterNested> withLabel(String key, String value) {
+ public FilterNested> withLabel(String key, String value) {
context.labels.put(key, value);
return this;
}
@Override
- public FilterNested> withoutLabel(String key, String value) {
- context.labelsNot.merge(key, new String[]{value}, (oldList, newList) -> {
+ public FilterNested> withoutLabel(String key, String value) {
+ context.labelsNot.merge(key, new String[] { value }, (oldList, newList) -> {
final String[] concatList = (String[]) Array.newInstance(String.class, oldList.length + newList.length);
System.arraycopy(oldList, 0, concatList, 0, oldList.length);
System.arraycopy(newList, 0, concatList, oldList.length, newList.length);
@@ -103,27 +104,27 @@ public FilterNested> withoutLabel(String key, Str
}
@Override
- public FilterNested> withFields(Map fields) {
+ public FilterNested> withFields(Map fields) {
this.context.fields.putAll(fields);
return this;
}
@Override
- public FilterNested> withField(String key, String value) {
+ public FilterNested> withField(String key, String value) {
this.context.fields.put(key, value);
return this;
}
@Override
- public FilterNested> withoutFields(Map fields) {
+ public FilterNested> withoutFields(Map fields) {
// Re-use "withoutField" to convert values from String to String[]
fields.forEach(this::withoutField);
return this;
}
@Override
- public FilterNested> withoutField(String key, String value) {
- context.fieldsNot.merge(key, new String[]{value}, (oldList, newList) -> {
+ public FilterNested> withoutField(String key, String value) {
+ context.fieldsNot.merge(key, new String[] { value }, (oldList, newList) -> {
if (Utils.isNotNullOrEmpty(newList[0])) { // Only add new values when not null
final String[] concatList = (String[]) Array.newInstance(String.class, oldList.length + newList.length);
System.arraycopy(oldList, 0, concatList, 0, oldList.length);
@@ -137,7 +138,7 @@ public FilterNested> withoutField(String key, Str
}
@Override
- public FilterNested> withLabelSelector(LabelSelector selector) {
+ public FilterNested> withLabelSelector(LabelSelector selector) {
Map matchLabels = selector.getMatchLabels();
if (matchLabels != null) {
withLabels(matchLabels);
@@ -149,10 +150,10 @@ public FilterNested> withLabelSelector(LabelSelec
String key = req.getKey();
switch (operator) {
case "In":
- withLabelIn(key, req.getValues().toArray(new String[]{}));
+ withLabelIn(key, req.getValues().toArray(new String[] {}));
break;
case "NotIn":
- withLabelNotIn(key, req.getValues().toArray(new String[]{}));
+ withLabelNotIn(key, req.getValues().toArray(new String[] {}));
break;
case "DoesNotExist":
withoutLabel(key);
@@ -169,7 +170,7 @@ public FilterNested> withLabelSelector(LabelSelec
}
@Override
- public FilterNested> withInvolvedObject(ObjectReference objectReference) {
+ public FilterNested> withInvolvedObject(ObjectReference objectReference) {
if (objectReference.getName() != null) {
context.fields.put(INVOLVED_OBJECT_NAME, objectReference.getName());
}
@@ -195,13 +196,12 @@ public FilterNested> withInvolvedObject(ObjectRef
}
@Override
- public FilterWatchListDeletable and() {
+ public FilterWatchListDeletable and() {
return this.baseOperation.newInstance(context);
}
-
@Override
- public FilterNested> withLabelSelector(String selectorAsString) {
+ public FilterNested> withLabelSelector(String selectorAsString) {
this.context.selectorAsString = selectorAsString;
return this;
}
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java
index 8be8bf1f81a..3df16f551d0 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java
@@ -63,6 +63,7 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl
implements ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable,
@@ -120,10 +121,13 @@ List getItems() {
}
@Override
- public List> getResources() {
+ public Stream> resources() {
return getItems().stream()
- .map(this::getResource)
- .collect(Collectors.toList());
+ .map(this::getResource);
+ }
+
+ public List> getResources() {
+ return resources().collect(Collectors.toList());
}
/**
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/DeploymentRollingUpdater.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/DeploymentRollingUpdater.java
index 235c56cab68..17cc9b33d9a 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/DeploymentRollingUpdater.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/DeploymentRollingUpdater.java
@@ -22,6 +22,7 @@
import io.fabric8.kubernetes.api.model.apps.DeploymentList;
import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.client.dsl.Operation;
+import io.fabric8.kubernetes.client.dsl.PodResource;
import io.fabric8.kubernetes.client.dsl.RollableScalableResource;
import io.fabric8.kubernetes.client.dsl.WatchListDeletable;
@@ -51,7 +52,7 @@ protected Deployment createClone(Deployment obj, String newName, String newDeplo
}
@Override
- protected WatchListDeletable selectedPodLister(Deployment obj) {
+ protected WatchListDeletable selectedPodLister(Deployment obj) {
return selectedPodLister(obj.getSpec().getSelector());
}
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetOperationsImpl.java
index 8746c5acc27..62295b23a3d 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetOperationsImpl.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetOperationsImpl.java
@@ -159,7 +159,7 @@ public String getLog(boolean isPretty) {
return PodOperationUtil.getLog(doGetLog(isPretty), isPretty);
}
- private List> doGetLog(boolean isPretty) {
+ private List doGetLog(boolean isPretty) {
ReplicaSet replicaSet = requireFromServer();
return PodOperationUtil.getPodOperationsForController(context, replicaSet.getMetadata().getUid(),
getReplicaSetSelectorLabels(replicaSet), isPretty, rollingOperationContext.getLogWaitTimeout(),
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetRollingUpdater.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetRollingUpdater.java
index d81d4039d9e..18f6a6df8d4 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetRollingUpdater.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/ReplicaSetRollingUpdater.java
@@ -22,6 +22,7 @@
import io.fabric8.kubernetes.api.model.apps.ReplicaSetList;
import io.fabric8.kubernetes.client.Client;
import io.fabric8.kubernetes.client.dsl.Operation;
+import io.fabric8.kubernetes.client.dsl.PodResource;
import io.fabric8.kubernetes.client.dsl.RollableScalableResource;
import io.fabric8.kubernetes.client.dsl.WatchListDeletable;
@@ -51,7 +52,7 @@ protected ReplicaSet createClone(ReplicaSet obj, String newName, String newDeplo
}
@Override
- protected WatchListDeletable selectedPodLister(ReplicaSet obj) {
+ protected WatchListDeletable selectedPodLister(ReplicaSet obj) {
return selectedPodLister(obj.getSpec().getSelector());
}
diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/RollingUpdater.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/RollingUpdater.java
index 6401d368ed2..e1998ea006d 100644
--- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/RollingUpdater.java
+++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/RollingUpdater.java
@@ -79,7 +79,7 @@ protected RollingUpdater(Client client, String namespace, long rollingTimeoutMil
protected abstract T createClone(T obj, String newName, String newDeploymentHash);
- protected abstract WatchListDeletable selectedPodLister(T obj);
+ protected abstract WatchListDeletable selectedPodLister(T obj);
protected abstract T updateDeploymentKey(String name, String hash);
@@ -264,11 +264,11 @@ private String md5sum(HasMetadata obj) throws NoSuchAlgorithmException, JsonProc
protected abstract Operation> resources();
- protected Operation> pods() {
+ protected Operation