From 2ea66c896f420fc2702845ec8d0eed6bd56bb187 Mon Sep 17 00:00:00 2001 From: Steve Hawkins Date: Thu, 24 Nov 2022 07:35:32 -0500 Subject: [PATCH] fix #4574 changing the behavior of get --- CHANGELOG.md | 1 + .../camelk/test/KameletBindingTest.java | 2 +- .../kubernetes/client/FromServerGettable.java | 6 ++ .../kubernetes/client/dsl/Gettable.java | 4 ++ ...ServerGetDeleteRecreateWaitApplicable.java | 8 +++ .../kubernetes/client/dsl/Resource.java | 10 +++ .../client/extension/ResourceAdapter.java | 5 ++ .../client/dsl/internal/BaseOperation.java | 64 +++++++++--------- .../dsl/internal/HasMetadataOperation.java | 65 +++++++++---------- ...hDeleteRecreateWaitApplicableListImpl.java | 9 ++- .../client/dsl/internal/OperationContext.java | 21 +----- .../apps/v1/DeploymentOperationsImpl.java | 2 +- .../v1/RollableScalableResourceOperation.java | 6 +- .../internal/batch/v1/JobOperationsImpl.java | 2 +- ...rtificateSigningRequestOperationsImpl.java | 2 +- ...rtificateSigningRequestOperationsImpl.java | 2 +- .../internal/core/v1/PodOperationsImpl.java | 2 +- .../core/v1/ServiceOperationsImpl.java | 6 +- .../v1beta1/DeploymentOperationsImpl.java | 2 +- .../dsl/internal/OperationContextTest.java | 3 - .../internal/uploadable/PodUploadTest.java | 12 ++-- .../client/impl/KubernetesClientImplTest.java | 14 ++-- .../examples/CustomResourceV1Example.java | 2 +- .../examples/ImageStreamExample.java | 2 +- .../examples/ImageStreamTagExample.java | 2 +- .../openshift/examples/LoadExample.java | 2 +- .../kubernetes/ClusterRoleBindingIT.java | 2 +- .../io/fabric8/kubernetes/ClusterRoleIT.java | 2 +- .../io/fabric8/kubernetes/ConfigMapIT.java | 2 +- .../java/io/fabric8/kubernetes/CronJobIT.java | 2 +- .../CustomResourceDefinitionIT.java | 2 +- .../io/fabric8/kubernetes/DeploymentIT.java | 4 +- .../java/io/fabric8/kubernetes/IngressIT.java | 2 +- .../io/fabric8/kubernetes/NamespaceIT.java | 2 +- .../fabric8/kubernetes/NetworkPolicyIT.java | 2 +- .../io/fabric8/kubernetes/PodEvictIT.java | 2 +- .../java/io/fabric8/kubernetes/PodIT.java | 4 +- .../kubernetes/PodSecurityPolicyIT.java | 2 +- .../io/fabric8/kubernetes/ReplicaSetIT.java | 2 +- .../kubernetes/ReplicationControllerIT.java | 2 +- .../io/fabric8/kubernetes/RoleBindingIT.java | 2 +- .../java/io/fabric8/kubernetes/RoleIT.java | 2 +- .../java/io/fabric8/kubernetes/SecretIT.java | 2 +- .../fabric8/kubernetes/ServiceAccountIT.java | 2 +- .../java/io/fabric8/kubernetes/ServiceIT.java | 2 +- .../io/fabric8/kubernetes/StatefulSetIT.java | 2 +- .../io/fabric8/kubernetes/StorageClassIT.java | 2 +- .../io/fabric8/openshift/BuildConfigIT.java | 2 +- .../fabric8/openshift/DeploymentConfigIT.java | 2 +- .../io/fabric8/openshift/ImageStreamIT.java | 2 +- .../fabric8/openshift/ImageStreamTagIT.java | 2 +- .../java/io/fabric8/openshift/RouteIT.java | 2 +- .../SecurityContextConstraintsIT.java | 2 +- .../io/fabric8/openshift/ServiceToURLIT.java | 2 +- .../java/io/fabric8/openshift/TemplateIT.java | 2 +- .../client/mock/APIServiceTest.java | 2 +- .../kubernetes/client/mock/CSIDriverTest.java | 3 +- .../kubernetes/client/mock/CSINodeTest.java | 2 +- .../client/mock/CSIStorageCapacityTest.java | 2 +- .../mock/CertificateSigningRequestTest.java | 2 +- .../client/mock/ClusterRoleCrudTest.java | 2 +- .../client/mock/ClusterRoleTest.java | 15 ++--- .../kubernetes/client/mock/ConfigMapTest.java | 4 +- .../client/mock/ControllerRevisionTest.java | 3 +- .../kubernetes/client/mock/CronJobTest.java | 4 +- .../client/mock/CustomResourceCrudTest.java | 2 +- .../mock/CustomResourceDefinitionTest.java | 2 +- .../client/mock/CustomResourceTest.java | 2 +- .../client/mock/DeploymentTest.java | 2 +- .../client/mock/EndpointSliceTest.java | 2 +- .../kubernetes/client/mock/EndpointsTest.java | 2 +- .../client/mock/FlowSchemaTest.java | 3 +- .../client/mock/LimitRangeLoadTest.java | 2 +- .../kubernetes/client/mock/LoadTest.java | 4 +- .../kubernetes/client/mock/NamespaceTest.java | 2 +- .../client/mock/NetworkingV1IngressTest.java | 2 +- .../mock/NetworkingV1beta1IngressTest.java | 2 +- .../mock/PersistentVolumeClaimTest.java | 2 +- .../client/mock/PersistentVolumeTest.java | 2 +- .../client/mock/PodDisruptionBudgetTest.java | 2 +- .../client/mock/PodTemplateTest.java | 2 +- .../kubernetes/client/mock/PodTest.java | 4 +- .../client/mock/PriorityClassTest.java | 2 +- .../mock/PriorityLevelConfigurationTest.java | 2 +- .../client/mock/ResourceQuotaTest.java | 4 +- .../kubernetes/client/mock/ResourceTest.java | 2 +- .../client/mock/RuntimeClassTest.java | 2 +- .../kubernetes/client/mock/ServiceTest.java | 2 +- .../client/mock/StatefulSetTest.java | 2 +- .../mock/V1CertificateSigningRequestTest.java | 2 +- .../kubernetes/client/mock/V1CronJobTest.java | 4 +- .../client/mock/V1EndpointSliceTest.java | 2 +- .../mock/V1HorizontalPodAutoscalerTest.java | 4 +- .../client/mock/V1IngressClassTest.java | 2 +- .../mock/V1PodDisruptionBudgetTest.java | 2 +- .../client/mock/V1PriorityClassTest.java | 3 +- .../V1ValidatingWebhookConfigurationTest.java | 2 +- ...ta1ValidatingWebhookConfigurationTest.java | 2 +- .../client/mock/V1beta2FlowSchemaTest.java | 2 +- ...V1beta2PriorityLevelConfigurationTest.java | 2 +- .../mock/V2HorizontalPodAutoscalerTest.java | 5 +- .../V2beta1HorizontalPodAutoscalerTest.java | 2 +- .../V2beta2HorizontalPodAutoscalerTest.java | 4 +- .../client/mock/VolumeAttachmentTest.java | 3 +- .../mock/ClusterServiceVersionTest.java | 2 +- .../client/server/mock/IngressTest.java | 2 +- .../client/server/mock/OpenShiftLoadTest.java | 6 +- .../server/mock/PrometheusRuleTest.java | 2 +- .../client/server/mock/PrometheusTest.java | 14 +++- .../server/mock/ServiceMonitorTest.java | 2 +- .../client/server/mock/TemplateTest.java | 6 +- .../client/mock/ServiceCatalogCrudTest.java | 2 +- .../apps/DeploymentConfigOperationsImpl.java | 8 +-- .../internal/build/BuildOperationsImpl.java | 2 +- .../internal/core/TemplateOperationsImpl.java | 6 +- .../itests/KubernetesDeserializerTest.java | 4 +- 116 files changed, 272 insertions(+), 237 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f26b86096d..f14f0ab06a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ * Fix #4582: updated [client.secrets] createOrReplace document #### _**Note**_: Breaking changes +* Fix #4574: fromServer has been deprecated - it no longer needs to be called. All get() operations will fetch the resource(s) from the api server. If you need the context item that was passed in from a resource, load, or resourceList methods, use the item or items method. * Fix #4515: files located at the root of jars named model.properties, e.g. core.properties, have been removed * Fix #3923: removed KubernetesResourceMappingProvider - a META-INF/services/io.fabric8.kubernetes.api.model.KubernetesResource list of resources is used instead. * Fix #4597: remove the deprecated support for `javax.validation.constraints.NotNull` in the `crd-generator`, to mark a property as `required` it needs to be annotated with `io.fabric8.generator.annotation.Required` diff --git a/extensions/camel-k/tests/src/test/java/io/fabric8/camelk/test/KameletBindingTest.java b/extensions/camel-k/tests/src/test/java/io/fabric8/camelk/test/KameletBindingTest.java index d066d0eab67..c96596c503b 100644 --- a/extensions/camel-k/tests/src/test/java/io/fabric8/camelk/test/KameletBindingTest.java +++ b/extensions/camel-k/tests/src/test/java/io/fabric8/camelk/test/KameletBindingTest.java @@ -39,7 +39,7 @@ void load() { // Given + When KameletBinding kameletBinding = client.v1alpha1().kameletBindings() .load(getClass().getResourceAsStream("/test-kameletbinding.yml")) - .get(); + .item(); // Then assertThat(kameletBinding) diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/FromServerGettable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/FromServerGettable.java index 002f13f571b..e1488b43624 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/FromServerGettable.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/FromServerGettable.java @@ -20,5 +20,11 @@ public interface FromServerGettable extends Gettable { + /** + * @deprecated {@link #get()} will always return the latest resource from the server, there is no + * need to call fromServer. + */ + @Deprecated Gettable fromServer(); + } diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Gettable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Gettable.java index 5b40c8d6dc0..d26b9e4257b 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Gettable.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Gettable.java @@ -18,6 +18,10 @@ public interface Gettable { /** + * Get the current state from the api server. + * + * See also {@link Resource#item()} + * * @return the item or null if the item doesn't exist. * @throws io.fabric8.kubernetes.client.KubernetesClientException if an error occurs */ diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java index 5fc180ddcb5..e1ff0bfb6f3 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable.java @@ -16,6 +16,9 @@ package io.fabric8.kubernetes.client.dsl; +import io.fabric8.kubernetes.api.model.HasMetadata; + +import java.util.List; import java.util.stream.Stream; public interface NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable extends @@ -26,4 +29,9 @@ public interface NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable @Override Stream> resources(); + /** + * Return the items used to create this list context - these values are not from the server. + */ + List items(); + } diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java index fee986a51f6..a8fe4aa21f2 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Resource.java @@ -58,6 +58,8 @@ default GracePeriodConfigurable cascading(boolean enabled) boolean isReady(); /** + * Perform a {@link Gettable#get()}, but throws an exception if the server resource does not exist. + * * @return the item or throws an exception if the item doesn't exist. * @throws io.fabric8.kubernetes.client.KubernetesClientException if an error occurs * @throws io.fabric8.kubernetes.client.ResourceNotFoundException if resource is absent @@ -68,4 +70,12 @@ default GracePeriodConfigurable cascading(boolean enabled) ReplaceDeletable lockResourceVersion(String resourceVersion); + /** + * Get the item used to create the current operation context if available. + * + * @return the current item if provided via the load, resource, or resourceList method, or null if this resource was created + * just from a class. + */ + T item(); + } 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 cd80145363b..5706390685c 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 @@ -324,4 +324,9 @@ public T serverSideApply() { return resource.serverSideApply(); } + @Override + public T item() { + return 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 9c77ea8b3fd..8016221c114 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 @@ -101,7 +101,6 @@ public class BaseOperation + * Will always return non-null or throw an exception. + *
+ * Differs from {@link #require()} in that it does not throw a {@link ResourceNotFoundException} exception + * which for some reason is not a {@link KubernetesClientException} + */ + protected T requireFromServer() { + if (Utils.isNullOrEmpty(getName())) { + throw new KubernetesClientException("name not specified for an operation requiring one."); + } try { URL requestUrl = getCompleteResourceUrl(); return handleGet(requestUrl); @@ -278,7 +287,7 @@ public R load(String path) { @Override public BaseOperation fromServer() { - return newInstance(context.withReloadingFromServer(true)); + return this; } @Override @@ -523,19 +532,17 @@ public T patchStatus(T item) { @Override public T patchStatus() { - // fromServer shouldn't be necessary here as we're using a merge patch, but - // just in case that changes we want consistency with the other patch methods - return this.fromServer().patchStatus(getNonNullItem()); + throw new KubernetesClientException(READ_ONLY_UPDATE_EXCEPTION_MESSAGE); } @Override public T patch() { - return this.fromServer().patch(getNonNullItem()); + throw new KubernetesClientException(READ_ONLY_UPDATE_EXCEPTION_MESSAGE); } @Override public T patch(PatchContext patchContext) { - return this.fromServer().patch(patchContext, getNonNullItem()); + throw new KubernetesClientException(READ_ONLY_UPDATE_EXCEPTION_MESSAGE); } protected T getNonNullItem() { @@ -720,12 +727,15 @@ private URL getCompleteResourceUrl() throws MalformedURLException { URL requestUrl = getNamespacedUrl(checkNamespace(item)); if (name != null) { requestUrl = new URL(URLUtils.join(requestUrl.toString(), name)); - } else if (item != null && reloadingFromServer) { - requestUrl = new URL(URLUtils.join(requestUrl.toString(), checkName(item))); } return requestUrl; } + @Override + public T item() { + return getItem(); + } + @Override public final T getItem() { return item; @@ -735,10 +745,6 @@ public String getResourceVersion() { return resourceVersion; } - public Boolean isReloadingFromServer() { - return reloadingFromServer; - } - public Long getGracePeriodSeconds() { return gracePeriodSeconds; } @@ -832,7 +838,7 @@ public Readiness getReadiness() { @Override public final boolean isReady() { - T item = fromServer().get(); + T item = get(); if (item == null) { return false; } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperation.java index f8aaf83aa31..c53091ce74f 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperation.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/HasMetadataOperation.java @@ -22,13 +22,11 @@ import io.fabric8.kubernetes.api.model.KubernetesResourceList; import io.fabric8.kubernetes.api.model.ObjectMeta; import io.fabric8.kubernetes.client.KubernetesClientException; -import io.fabric8.kubernetes.client.ResourceNotFoundException; import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.dsl.base.PatchContext; import io.fabric8.kubernetes.client.dsl.base.PatchType; import io.fabric8.kubernetes.client.utils.KubernetesResourceUtil; import io.fabric8.kubernetes.client.utils.Serialization; -import io.fabric8.kubernetes.client.utils.Utils; import java.io.IOException; import java.util.concurrent.TimeUnit; @@ -53,7 +51,7 @@ public HasMetadataOperation(OperationContext ctx, Class type, Class listTy @Override public T edit(UnaryOperator function) { - T item = getMandatory(); + T item = getItemOrRequireFromServer(); T clone = clone(item); return patch(null, clone, function.apply(item), false); } @@ -64,14 +62,14 @@ private T clone(T item) { @Override public T editStatus(UnaryOperator function) { - T item = getMandatory(); + T item = getItemOrRequireFromServer(); T clone = clone(item); return patch(null, clone, function.apply(item), true); } @Override public T accept(Consumer consumer) { - T item = getMandatory(); + T item = getItemOrRequireFromServer(); T clone = clone(item); consumer.accept(item); return patch(null, clone, item, false); @@ -79,35 +77,11 @@ public T accept(Consumer consumer) { @Override public T edit(Visitor... visitors) { - T item = getMandatory(); + T item = getItemOrRequireFromServer(); T clone = clone(item); return patch(null, clone, context.getHandler(item).edit(item).accept(visitors).build(), false); } - /** - * Get the current item from the server - *
- * Will always return non-null or throw an exception. - */ - protected T requireFromServer() { - try { - if (Utils.isNotNullOrEmpty(getName())) { - return newInstance(context.withItem(null)).require(); - } - if (getItem() != null) { - String name = KubernetesResourceUtil.getName(getItem()); - if (Utils.isNotNullOrEmpty(name)) { - return newInstance(context.withItem(null)).withName(name).require(); - } - } - } catch (ResourceNotFoundException e) { - if (e.getCause() instanceof KubernetesClientException) { - throw (KubernetesClientException) e.getCause(); - } - } - throw new KubernetesClientException("name not specified for an operation requiring one."); - } - @Override public T replace() { return replace(getItem(), false); @@ -192,9 +166,15 @@ protected T replace(T item, boolean status) { throw KubernetesClientException.launderThrowable(forOperationType(REPLACE_OPERATION), caught); } + /** + * Perform a patch. If the base is not provided and one is required, it will + * be fetched from the server. + */ protected T patch(PatchContext context, T base, T item, boolean status) { - if (base == null && context != null && context.getPatchType() == PatchType.JSON) { - base = getMandatory(); + if (context == null || context.getPatchType() == PatchType.JSON) { + if (base == null) { + base = requireFromServer(); + } if (base.getMetadata() != null) { // prevent the resourceVersion from being modified in the patch if (item.getMetadata() == null) { @@ -220,20 +200,35 @@ protected T patch(PatchContext context, T base, T item, boolean status) { return visitor.apply(item); } + @Override + public T patchStatus() { + return patch(PatchContext.of(PatchType.JSON_MERGE), null, getNonNullItem(), true); + } + + @Override + public T patch() { + return patch(null, null, getNonNullItem(), false); + } + + @Override + public T patch(PatchContext patchContext) { + return patch(patchContext, null, getNonNullItem(), false); + } + @Override public T patchStatus(T item) { - return patch(PatchContext.of(PatchType.JSON_MERGE), null, clone(item), true); + return patch(PatchContext.of(PatchType.JSON_MERGE), getItem(), clone(item), true); } @Override public T patch(PatchContext patchContext, T item) { - return patch(patchContext, null, clone(item), false); + return patch(patchContext, getItem(), clone(item), false); } @Override public T patch(PatchContext patchContext, String patch) { try { - final T got = getMandatory(); + final T got = getItemOrRequireFromServer(); return handlePatch(patchContext, got, convertToJson(patch), getType(), false); } catch (InterruptedException interruptedException) { Thread.currentThread().interrupt(); 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 1e8303a013a..8b35f27a0bf 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 @@ -95,6 +95,11 @@ List getItems() { .collect(Collectors.toList()); } + @Override + public List items() { + return getItems(); + } + @Override public Stream> resources() { return getItems().stream() @@ -121,7 +126,7 @@ public List waitUntilCondition(Predicate condition, if (operations.isEmpty()) { return Collections.emptyList(); } - List items = operations.stream().map(Resource::get).collect(Collectors.toList()); + List items = operations.stream().map(Resource::item).collect(Collectors.toList()); final List>> futures = new ArrayList<>(items.size()); for (final Resource impl : operations) { CompletableFuture> futureCondition = impl.informOnCondition(l -> { @@ -220,7 +225,7 @@ public ListVisitFromServerGetDeleteRecreateWaitApplicable inNamespa @Override public Gettable> fromServer() { - return newInstance(context.withReloadingFromServer(true)); + return this; } @Override diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/OperationContext.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/OperationContext.java index 01c5c4e4298..d2b8d10e782 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/OperationContext.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/OperationContext.java @@ -48,7 +48,6 @@ public class OperationContext { protected String namespace; protected boolean defaultNamespace = true; protected String name; - protected boolean reloadingFromServer; protected boolean dryRun; protected FieldValidateable.Validation fieldValidation; protected String fieldManager; @@ -74,7 +73,7 @@ public OperationContext() { public OperationContext(OperationContext other) { this(other.client, other.plural, other.namespace, other.name, other.apiGroupName, other.apiGroupVersion, other.item, other.labels, other.labelsNot, other.labelsIn, other.labelsNotIn, other.fields, - other.fieldsNot, other.resourceVersion, other.reloadingFromServer, other.gracePeriodSeconds, other.propagationPolicy, + other.fieldsNot, other.resourceVersion, other.gracePeriodSeconds, other.propagationPolicy, other.dryRun, other.selectorAsString, other.defaultNamespace, other.fieldValidation, other.fieldManager, other.forceConflicts); } @@ -82,7 +81,7 @@ public OperationContext(OperationContext other) { public OperationContext(Client client, String plural, String namespace, String name, String apiGroupName, String apiGroupVersion, Object item, Map labels, Map labelsNot, Map labelsIn, Map labelsNotIn, - Map fields, Map fieldsNot, String resourceVersion, boolean reloadingFromServer, + Map fields, Map fieldsNot, String resourceVersion, long gracePeriodSeconds, DeletionPropagation propagationPolicy, boolean dryRun, String selectorAsString, boolean defaultNamespace, FieldValidateable.Validation fieldValidation, String fieldManager, Boolean forceConflicts) { @@ -100,7 +99,6 @@ public OperationContext(Client client, String plural, String namespace, String n setFields(fields); setFieldsNot(fieldsNot); this.resourceVersion = resourceVersion; - this.reloadingFromServer = reloadingFromServer; this.gracePeriodSeconds = gracePeriodSeconds; this.propagationPolicy = propagationPolicy; this.dryRun = dryRun; @@ -227,10 +225,6 @@ public String getResourceVersion() { return resourceVersion; } - public boolean isReloadingFromServer() { - return reloadingFromServer; - } - public long getGracePeriodSeconds() { return gracePeriodSeconds; } @@ -431,15 +425,6 @@ public OperationContext withResourceVersion(String resourceVersion) { return context; } - public OperationContext withReloadingFromServer(boolean reloadingFromServer) { - if (this.reloadingFromServer == reloadingFromServer) { - return this; - } - final OperationContext context = new OperationContext(this); - context.reloadingFromServer = reloadingFromServer; - return context; - } - public OperationContext withGracePeriodSeconds(long gracePeriodSeconds) { if (this.gracePeriodSeconds == gracePeriodSeconds) { return this; @@ -485,7 +470,7 @@ public C clientInWriteContext(Class clazz) { // operationcontext OperationContext newContext = HasMetadataOperationsImpl.defaultContext(client).withDryRun(getDryRun()) .withGracePeriodSeconds(getGracePeriodSeconds()).withPropagationPolicy(getPropagationPolicy()) - .withReloadingFromServer(isReloadingFromServer()).withFieldValidation(this.fieldValidation); + .withFieldValidation(this.fieldValidation); // check before setting to prevent flipping the default flag if (!Objects.equals(getNamespace(), newContext.getNamespace()) diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/DeploymentOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/DeploymentOperationsImpl.java index c9e7fb13c9a..9363144e911 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/DeploymentOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/DeploymentOperationsImpl.java @@ -89,7 +89,7 @@ public Deployment scale(int count, boolean wait) { Deployment res = accept(d -> d.getSpec().setReplicas(count)); if (wait) { waitUntilDeploymentIsScaled(count); - res = getMandatory(); + res = getItemOrRequireFromServer(); } return res; } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/RollableScalableResourceOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/RollableScalableResourceOperation.java index 0f424dcbc93..ff9996e9ebf 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/RollableScalableResourceOperation.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/apps/v1/RollableScalableResourceOperation.java @@ -147,7 +147,7 @@ public T edit(UnaryOperator function) { return super.edit(function); } try { - T oldObj = getMandatory(); + T oldObj = getItemOrRequireFromServer(); T newObj = function.apply(Serialization.clone(oldObj)); return getRollingUpdater(rollingTimeout, rollingTimeUnit).rollUpdate(oldObj, newObj); } catch (Exception e) { @@ -160,7 +160,7 @@ public T replace(T t) { if (!rolling) { return super.replace(t); } - return getRollingUpdater(rollingTimeout, rollingTimeUnit).rollUpdate(getMandatory(), t); + return getRollingUpdater(rollingTimeout, rollingTimeUnit).rollUpdate(getItemOrRequireFromServer(), t); } @Override @@ -168,7 +168,7 @@ public T patch(PatchContext patchContext, T item) { if (!rolling || patchContext == null || patchContext.getPatchType() != PatchType.JSON) { return super.patch(patchContext, item); } - return getRollingUpdater(rollingTimeout, rollingTimeUnit).rollUpdate(getMandatory(), item); + return getRollingUpdater(rollingTimeout, rollingTimeUnit).rollUpdate(getItemOrRequireFromServer(), item); } public abstract RollableScalableResourceOperation newInstance(RollingOperationContext context); 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 254e92a2ee2..3c843850053 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 @@ -88,7 +88,7 @@ public Job scale(int count, boolean wait) { Job res = accept(b -> b.getSpec().setParallelism(count)); if (wait) { waitUntilJobIsScaled(); - res = getMandatory(); + res = getItemOrRequireFromServer(); } return res; } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/certificates/v1/CertificateSigningRequestOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/certificates/v1/CertificateSigningRequestOperationsImpl.java index c30b7dc826b..d9a233a6cc3 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/certificates/v1/CertificateSigningRequestOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/certificates/v1/CertificateSigningRequestOperationsImpl.java @@ -61,7 +61,7 @@ public CertificateSigningRequest deny(CertificateSigningRequestCondition certifi private CertificateSigningRequest addStatusToCSRAndSubmit( CertificateSigningRequestCondition certificateSigningRequestCondition) { try { - CertificateSigningRequest fromServerCsr = fromServer().get(); + CertificateSigningRequest fromServerCsr = get(); fromServerCsr.setStatus(createCertificateSigningRequestStatus(certificateSigningRequestCondition)); return handleApproveOrDeny(fromServerCsr, CertificateSigningRequest.class); } catch (InterruptedException ie) { diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/certificates/v1beta1/CertificateSigningRequestOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/certificates/v1beta1/CertificateSigningRequestOperationsImpl.java index 65c8a6bea88..4836b654014 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/certificates/v1beta1/CertificateSigningRequestOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/certificates/v1beta1/CertificateSigningRequestOperationsImpl.java @@ -68,7 +68,7 @@ private CertificateSigningRequestStatus createCertificateSigningRequestStatus( private CertificateSigningRequest addStatusToCSRAndSubmit( CertificateSigningRequestCondition certificateSigningRequestCondition) { try { - CertificateSigningRequest fromServerCsr = fromServer().get(); + CertificateSigningRequest fromServerCsr = get(); fromServerCsr.setStatus(createCertificateSigningRequestStatus(certificateSigningRequestCondition)); return handleApproveOrDeny(fromServerCsr, CertificateSigningRequest.class); } catch (InterruptedException ie) { diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/PodOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/PodOperationsImpl.java index 0aadd08956e..0f08a8ef655 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/PodOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/PodOperationsImpl.java @@ -314,7 +314,7 @@ private URL getURL(String operation, String[] commands) throws MalformedURLExcep * If not specified, choose an appropriate default container id */ String validateOrDefaultContainerId(String name) { - Pod pod = this.require(); + Pod pod = this.requireFromServer(); // spec and container null-checks are not necessary for real k8s clusters, added them to simplify some tests running in the mockserver if (pod.getSpec() == null || pod.getSpec().getContainers() == null || pod.getSpec().getContainers().isEmpty()) { throw new KubernetesClientException("Pod has no containers!"); diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/ServiceOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/ServiceOperationsImpl.java index decc49c3c58..d7ce35746b5 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/ServiceOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/core/v1/ServiceOperationsImpl.java @@ -83,9 +83,9 @@ public Service waitUntilReady(long amount, TimeUnit timeUnit) { @Override public String getURL(String portName) { - String clusterIP = getMandatory().getSpec().getClusterIP(); + String clusterIP = getItemOrRequireFromServer().getSpec().getClusterIP(); if ("None".equals(clusterIP)) { - throw new IllegalStateException("Service: " + getMandatory().getMetadata().getName() + " in namespace " + throw new IllegalStateException("Service: " + getItemOrRequireFromServer().getMetadata().getName() + " in namespace " + namespace + " is head-less. Search for endpoints instead"); } return getUrlHelper(portName); @@ -104,7 +104,7 @@ private String getUrlHelper(String portName) { // Sort all loaded implementations according to priority Collections.sort(servicesList, new ServiceToUrlSortComparator()); for (ServiceToURLProvider serviceToURLProvider : servicesList) { - String url = serviceToURLProvider.getURL(getMandatory(), portName, namespace, + String url = serviceToURLProvider.getURL(getItemOrRequireFromServer(), portName, namespace, context.getClient().adapt(KubernetesClient.class)); if (url != null && URLUtils.isValidURL(url)) { return url; diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/extensions/v1beta1/DeploymentOperationsImpl.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/extensions/v1beta1/DeploymentOperationsImpl.java index deb226f691f..028c243c92c 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/extensions/v1beta1/DeploymentOperationsImpl.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/extensions/v1beta1/DeploymentOperationsImpl.java @@ -86,7 +86,7 @@ public Deployment scale(int count, boolean wait) { Deployment res = accept(d -> d.getSpec().setReplicas(count)); if (wait) { waitUntilDeploymentIsScaled(count); - res = getMandatory(); + res = getItemOrRequireFromServer(); } return res; } diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/OperationContextTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/OperationContextTest.java index 1e0f8a758e9..2c1fee1d303 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/OperationContextTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/OperationContextTest.java @@ -27,7 +27,6 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; @@ -76,7 +75,6 @@ void testCompleteOperationContext() { .withFields(Collections.singletonMap("test", "field")) .withFieldsNot(Collections.singletonMap("test", new String[] { "fieldsNot" })) .withResourceVersion("234343") - .withReloadingFromServer(false) .withGracePeriodSeconds(0) .withPropagationPolicy(DeletionPropagation.BACKGROUND); @@ -96,7 +94,6 @@ void testCompleteOperationContext() { assertEquals("field", operationContext.getFields().get("test")); assertArrayEquals(new String[] { "fieldsNot" }, operationContext.getFieldsNot().get("test")); assertEquals("234343", operationContext.getResourceVersion()); - assertFalse(operationContext.isReloadingFromServer()); assertEquals(0, operationContext.getGracePeriodSeconds()); assertEquals(DeletionPropagation.BACKGROUND, operationContext.getPropagationPolicy()); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/uploadable/PodUploadTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/uploadable/PodUploadTest.java index edda2222099..2dbfc798672 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/uploadable/PodUploadTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/dsl/internal/uploadable/PodUploadTest.java @@ -23,10 +23,12 @@ import io.fabric8.kubernetes.client.dsl.internal.PodOperationContext; import io.fabric8.kubernetes.client.dsl.internal.core.v1.PodOperationsImpl; import io.fabric8.kubernetes.client.http.HttpClient; +import io.fabric8.kubernetes.client.http.TestHttpResponse; import io.fabric8.kubernetes.client.http.WebSocket; import io.fabric8.kubernetes.client.impl.BaseClient; import io.fabric8.kubernetes.client.utils.CommonThreadPool; import io.fabric8.kubernetes.client.utils.InputStreamPumper; +import io.fabric8.kubernetes.client.utils.Serialization; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -87,8 +89,10 @@ void setUp() { .withNewMetadata().withName("pod").endMetadata() .withNewSpec().addNewContainer().withName("container").endContainer().endSpec() .build(); - this.operation = new PodOperationsImpl( - new PodOperationContext(), new OperationContext().withItem(item).withClient(client)); + this.operation = (PodOperationsImpl) new PodOperationsImpl( + new PodOperationContext(), new OperationContext().withClient(client)).resource(item); + when(mockClient.sendAsync(Mockito.any(), Mockito.eq(byte[].class))) + .thenReturn(CompletableFuture.completedFuture(TestHttpResponse.from(200, Serialization.asJson(item)))); } @Test @@ -193,7 +197,7 @@ void uploadFileAndVerify(PodUploadTester fileUploadMethodToTest) throws assertThat(result).isTrue(); verify(builder, times(1)).uri(argThat(request -> { assertThat(request).hasToString( - "https://openshift.com:8443/api/v1/namespaces/default/pods/exec?command=sh&command=-c&command=mkdir%20-p%20%27%2Fmock%2Fdir%27%20%26%26%20base64%20-d%20-%20%3E%20%27%2Fmock%2Fdir%2Ffile%27&container=container&stdin=true&stderr=true"); + "https://openshift.com:8443/api/v1/namespaces/default/pods/pod/exec?command=sh&command=-c&command=mkdir%20-p%20%27%2Fmock%2Fdir%27%20%26%26%20base64%20-d%20-%20%3E%20%27%2Fmock%2Fdir%2Ffile%27&container=container&stdin=true&stderr=true"); return true; })); verify(mockWebSocket, atLeast(1)).send(any(ByteBuffer.class)); @@ -222,7 +226,7 @@ private void uploadDirectoryAndVerify(PodUploadTester directoryUpload) assertThat(result).isTrue(); verify(builder, times(1)).uri(argThat(request -> { assertThat(request).hasToString( - "https://openshift.com:8443/api/v1/namespaces/default/pods/exec?command=sh&command=-c&command=mkdir%20-p%20%27%2Fmock%2Fdir%27%20%26%26%20base64%20-d%20-%20%7C%20tar%20-C%20%27%2Fmock%2Fdir%27%20-xzf%20-&container=container&stdin=true&stderr=true"); + "https://openshift.com:8443/api/v1/namespaces/default/pods/pod/exec?command=sh&command=-c&command=mkdir%20-p%20%27%2Fmock%2Fdir%27%20%26%26%20base64%20-d%20-%20%7C%20tar%20-C%20%27%2Fmock%2Fdir%27%20-xzf%20-&container=container&stdin=true&stderr=true"); return true; })); verify(mockWebSocket, atLeast(1)).send(any(ByteBuffer.class)); diff --git a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/impl/KubernetesClientImplTest.java b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/impl/KubernetesClientImplTest.java index 440ddc6eb33..c728602bee7 100644 --- a/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/impl/KubernetesClientImplTest.java +++ b/kubernetes-client/src/test/java/io/fabric8/kubernetes/client/impl/KubernetesClientImplTest.java @@ -108,7 +108,7 @@ void loadWithWindowsLineSeparatorsString() throws Exception { final String crlfFile = String.join(" \r\n", fileLines); // When final List result = new KubernetesClientImpl() - .load(new ByteArrayInputStream(crlfFile.getBytes(StandardCharsets.UTF_8))).get(); + .load(new ByteArrayInputStream(crlfFile.getBytes(StandardCharsets.UTF_8))).items(); // Then assertThat(result) .hasSize(2) @@ -161,9 +161,9 @@ void shouldPropagateImpersonateSettings() { } @Test - @DisplayName("resource(String).get with HasMetadata should deserialize") + @DisplayName("resource(String).item with HasMetadata should deserialize") void resourceFromStringWithHasMetadata() { - assertThat(new KubernetesClientImpl().resource("apiVersion: v1\nkind: Pod").get()) + assertThat(new KubernetesClientImpl().resource("apiVersion: v1\nkind: Pod").item()) .isInstanceOf(Pod.class); } @@ -177,11 +177,11 @@ void resourceFromStringWithInvalid() { } @Test - @DisplayName("resource(InputStream).get with HasMetadata should deserialize") + @DisplayName("resource(InputStream).item with HasMetadata should deserialize") void resourceFromInputStreamWithHasMetadata() throws IOException { final String podYaml = "apiVersion: v1\nkind: Pod"; try (InputStream is = new ByteArrayInputStream(podYaml.getBytes(StandardCharsets.UTF_8))) { - assertThat(new KubernetesClientImpl().resource(is).get()) + assertThat(new KubernetesClientImpl().resource(is).item()) .isInstanceOf(Pod.class); } } @@ -199,11 +199,11 @@ void resourceFromInputStreamWithInvalid() throws IOException { } @Test - @DisplayName("load(InputStream).get with HasMetadata should deserialize") + @DisplayName("load(InputStream).items with HasMetadata should deserialize") void loadFromInputStreamWithHasMetadata() throws IOException { final String podYaml = "apiVersion: v1\nkind: Pod"; try (InputStream is = new ByteArrayInputStream(podYaml.getBytes(StandardCharsets.UTF_8))) { - assertThat(new KubernetesClientImpl().load(is).get()) + assertThat(new KubernetesClientImpl().load(is).items()) .containsExactly(new Pod()); } } diff --git a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceV1Example.java b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceV1Example.java index f8c379d12f0..4805b87d4ea 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceV1Example.java +++ b/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CustomResourceV1Example.java @@ -62,7 +62,7 @@ public static void main(String... args) { System.out.println("Added three shows"); shows.list().getItems() .forEach(s -> System.out.printf(" - %s%n", s.getSpec().name)); - final Show theWire = shows.withName("the-wire").fromServer().get(); + final Show theWire = shows.withName("the-wire").get(); System.out.printf("The Wire Score is: %s%n", theWire.getSpec().score); } } diff --git a/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/ImageStreamExample.java b/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/ImageStreamExample.java index dd78c4f29bc..8477a9521fa 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/ImageStreamExample.java +++ b/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/ImageStreamExample.java @@ -59,7 +59,7 @@ public static void main(String[] args) { .endSpec() .build()); logger.info("Created ImageStream: {}/{}", project, imageStream.getMetadata().getName()); - final ImageStream isFromServer = client.imageStreams().inNamespace(project).withName(imageStreamName).fromServer().get(); + final ImageStream isFromServer = client.imageStreams().inNamespace(project).withName(imageStreamName).get(); logger.info("Tags in ImageStream are:"); logger.info(" - {}", isFromServer.getSpec().getTags().get(0).getName()); logger.info(" - {}", isFromServer.getSpec().getTags().get(1).getName()); diff --git a/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/ImageStreamTagExample.java b/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/ImageStreamTagExample.java index 5edf378791c..f81f7e97ea8 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/ImageStreamTagExample.java +++ b/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/ImageStreamTagExample.java @@ -42,7 +42,7 @@ public static void main(String[] args) throws InterruptedException { .build()); logger.info("Created ImageStreamTag: {}", isTag.getMetadata().getName()); int limit = 0; - while (client.imageStreamTags().inNamespace(project).withName(isTagName).fromServer().get() == null && limit++ < 10) { + while (client.imageStreamTags().inNamespace(project).withName(isTagName).get() == null && limit++ < 10) { TimeUnit.SECONDS.sleep(1); } logger.info("ImageStreamTags in {}:", project); diff --git a/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/LoadExample.java b/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/LoadExample.java index 608a662c720..010854cb03b 100644 --- a/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/LoadExample.java +++ b/kubernetes-examples/src/main/java/io/fabric8/openshift/examples/LoadExample.java @@ -60,7 +60,7 @@ public void visit(ObjectMetaBuilder item) { visitedList.stream().map(LoadExample::display).forEach(logger::info); final List fromServerList = client.load(TemplateExample.class.getResourceAsStream(LOADED_RESOURCE)) - .fromServer().get(); + .get(); logger.info("Found on server: {} items.", fromServerList.size()); fromServerList.stream().map(LoadExample::display).forEach(logger::info); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ClusterRoleBindingIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ClusterRoleBindingIT.java index a305a2a55c8..f114c49dccd 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ClusterRoleBindingIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ClusterRoleBindingIT.java @@ -58,7 +58,7 @@ void get() { void load() { ClusterRoleBinding aClusterRoleBinding = client.rbac().clusterRoleBindings() - .load(getClass().getResourceAsStream("/test-kubernetesclusterrolebinding.yml")).get(); + .load(getClass().getResourceAsStream("/test-kubernetesclusterrolebinding.yml")).item(); assertNotNull(aClusterRoleBinding); assertEquals("ClusterRoleBinding", aClusterRoleBinding.getKind()); assertNotNull(aClusterRoleBinding.getMetadata()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ClusterRoleIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ClusterRoleIT.java index d92a0c81488..e1732a80521 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ClusterRoleIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ClusterRoleIT.java @@ -62,7 +62,7 @@ void get() { void load() { ClusterRole aClusterRole = client.rbac().clusterRoles() - .load(getClass().getResourceAsStream("/test-kubernetesclusterrole.yml")).get(); + .load(getClass().getResourceAsStream("/test-kubernetesclusterrole.yml")).item(); assertNotNull(aClusterRole); assertEquals("ClusterRole", aClusterRole.getKind()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ConfigMapIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ConfigMapIT.java index 20512952782..2e83c15f69d 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ConfigMapIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ConfigMapIT.java @@ -35,7 +35,7 @@ class ConfigMapIT { @Test void load() { - ConfigMap aConfigMap = client.configMaps().load(getClass().getResourceAsStream("/test-configmap.yml")).get(); + ConfigMap aConfigMap = client.configMaps().load(getClass().getResourceAsStream("/test-configmap.yml")).item(); assertThat(aConfigMap).isNotNull(); assertEquals("game-config", aConfigMap.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CronJobIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CronJobIT.java index 833e4d5eb14..2ef5c8df530 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CronJobIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CronJobIT.java @@ -37,7 +37,7 @@ class CronJobIT { @Test void load() { - CronJob aCronJob = client.batch().v1beta1().cronjobs().load(getClass().getResourceAsStream("/test-cronjob.yml")).get(); + CronJob aCronJob = client.batch().v1beta1().cronjobs().load(getClass().getResourceAsStream("/test-cronjob.yml")).item(); assertNotNull(aCronJob); assertEquals("hello", aCronJob.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CustomResourceDefinitionIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CustomResourceDefinitionIT.java index eea6179db8a..536656bdabf 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CustomResourceDefinitionIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/CustomResourceDefinitionIT.java @@ -60,7 +60,7 @@ public void tearDown() { void load() { // When final CustomResourceDefinition result = client.apiextensions().v1().customResourceDefinitions() - .load(getClass().getResourceAsStream("/test-crd.yml")).get(); + .load(getClass().getResourceAsStream("/test-crd.yml")).item(); // Then assertThat(result).isNotNull(); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/DeploymentIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/DeploymentIT.java index b05fc17ae35..7ee3e028240 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/DeploymentIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/DeploymentIT.java @@ -43,7 +43,7 @@ class DeploymentIT { @Test void load() { - Deployment aDeployment = client.apps().deployments().load(getClass().getResourceAsStream("/test-deployments.yml")).get(); + Deployment aDeployment = client.apps().deployments().load(getClass().getResourceAsStream("/test-deployments.yml")).item(); assertThat(aDeployment).isNotNull(); assertEquals("nginx-deployment", aDeployment.getMetadata().getName()); } @@ -83,7 +83,7 @@ void waitTest() { @Test void listFromServer() { Deployment deployment1 = client.apps().deployments().withName("deployment-standard").get(); - List resources = client.resourceList(deployment1).fromServer().get(); + List resources = client.resourceList(deployment1).get(); assertNotNull(resources); assertEquals(1, resources.size()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/IngressIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/IngressIT.java index e5b3b5c6771..f185874e212 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/IngressIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/IngressIT.java @@ -37,7 +37,7 @@ class IngressIT { @Test void load() { - Ingress aIngress = client.network().v1().ingresses().load(getClass().getResourceAsStream("/test-ingress.yml")).get(); + Ingress aIngress = client.network().v1().ingresses().load(getClass().getResourceAsStream("/test-ingress.yml")).item(); assertThat(aIngress).isNotNull(); assertEquals("test-multiple-paths", aIngress.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/NamespaceIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/NamespaceIT.java index ac1e0191138..0dec0040acc 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/NamespaceIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/NamespaceIT.java @@ -32,7 +32,7 @@ class NamespaceIT { @Test void testCrud() { // Load - Namespace namespace = client.namespaces().load(getClass().getResourceAsStream("/test-namespace.yml")).get(); + Namespace namespace = client.namespaces().load(getClass().getResourceAsStream("/test-namespace.yml")).item(); assertThat(namespace).isNotNull(); assertEquals("fabric8-test", namespace.getMetadata().getName()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/NetworkPolicyIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/NetworkPolicyIT.java index cfc9e443511..f10cb251c2c 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/NetworkPolicyIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/NetworkPolicyIT.java @@ -39,7 +39,7 @@ class NetworkPolicyIT { @Test void load() { NetworkPolicy loadedNetworkPolicy = client.network().v1().networkPolicies() - .load(getClass().getResourceAsStream("/test-networkpolicy.yml")).get(); + .load(getClass().getResourceAsStream("/test-networkpolicy.yml")).item(); assertNotNull(loadedNetworkPolicy); assertEquals("networkpolicy", loadedNetworkPolicy.getMetadata().getName()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodEvictIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodEvictIT.java index 86d7e4067c8..82ae2f35b66 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodEvictIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodEvictIT.java @@ -90,7 +90,7 @@ void evict() { // cant evict because only one left assertFalse(client.pods().resource(pod1).evict()); // ensure it really is still up - assertTrue(Readiness.getInstance().isReady(client.pods().resource(pod1).fromServer().get())); + assertTrue(Readiness.getInstance().isReady(client.pods().resource(pod1).get())); // create another pod to satisfy PDB client.pods().resource(pod3).createOrReplace(); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodIT.java index 5bc1c2db3cc..81bdad93845 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodIT.java @@ -71,7 +71,7 @@ class PodIT { @Test void load() { - Pod aPod = client.pods().load(getClass().getResourceAsStream("/test-pod.yml")).get(); + Pod aPod = client.pods().load(getClass().getResourceAsStream("/test-pod.yml")).item(); assertThat(aPod).isNotNull(); assertEquals("nginx", aPod.getMetadata().getName()); } @@ -349,7 +349,7 @@ void copyFile() throws IOException { void listFromServer() { client.pods().withName("pod-standard").waitUntilReady(POD_READY_WAIT_IN_SECONDS, TimeUnit.SECONDS); final Pod pod1 = client.pods().withName("pod-standard").get(); - List resources = client.resourceList(pod1).fromServer().get(); + List resources = client.resourceList(pod1).get(); assertNotNull(resources); assertEquals(1, resources.size()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodSecurityPolicyIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodSecurityPolicyIT.java index b84a0649296..2d12a8e35c1 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodSecurityPolicyIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodSecurityPolicyIT.java @@ -42,7 +42,7 @@ class PodSecurityPolicyIT { void load() { PodSecurityPolicy loadedPodSecurityPolicy = client.policy().v1beta1().podSecurityPolicies() - .load(getClass().getResourceAsStream("/test-podsecuritypolicy.yml")).get(); + .load(getClass().getResourceAsStream("/test-podsecuritypolicy.yml")).item(); assertNotNull(loadedPodSecurityPolicy); assertEquals("example", loadedPodSecurityPolicy.getMetadata().getName()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ReplicaSetIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ReplicaSetIT.java index 48251344f0f..ea56a1fc0d2 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ReplicaSetIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ReplicaSetIT.java @@ -39,7 +39,7 @@ class ReplicaSetIT { @Test void load() { ReplicaSet replicaSet = client.apps().replicaSets() - .load(getClass().getResourceAsStream("/test-replicaset.yml")).get(); + .load(getClass().getResourceAsStream("/test-replicaset.yml")).item(); assertThat(replicaSet).isNotNull(); assertEquals("frontend", replicaSet.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ReplicationControllerIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ReplicationControllerIT.java index e5478be8c49..9c46b1367fc 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ReplicationControllerIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ReplicationControllerIT.java @@ -35,7 +35,7 @@ class ReplicationControllerIT { @Test void load() { ReplicationController aReplicationController = client.replicationControllers() - .load(getClass().getResourceAsStream("/test-replicationcontroller.yml")).get(); + .load(getClass().getResourceAsStream("/test-replicationcontroller.yml")).item(); assertThat(aReplicationController).isNotNull(); assertEquals("nginx", aReplicationController.getMetadata().getName()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RoleBindingIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RoleBindingIT.java index e4c6cbcfcfc..7b0085adf6d 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RoleBindingIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RoleBindingIT.java @@ -62,7 +62,7 @@ void get() { void load() { RoleBinding aRoleBinding = client.rbac().roleBindings() - .load(getClass().getResourceAsStream("/test-kubernetesrolebinding.yml")).get(); + .load(getClass().getResourceAsStream("/test-kubernetesrolebinding.yml")).item(); assertNotNull(aRoleBinding); assertEquals("RoleBinding", aRoleBinding.getKind()); assertNotNull(aRoleBinding.getMetadata()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RoleIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RoleIT.java index 6a89605d714..9b4f63b6fba 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RoleIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/RoleIT.java @@ -65,7 +65,7 @@ void get() { void load() { Role aRole = client.rbac().roles() - .load(getClass().getResourceAsStream("/test-kubernetesrole.yml")).get(); + .load(getClass().getResourceAsStream("/test-kubernetesrole.yml")).item(); assertNotNull(aRole); assertEquals("Role", aRole.getKind()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/SecretIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/SecretIT.java index aa9aa4d8b9d..1d4e884d740 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/SecretIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/SecretIT.java @@ -43,7 +43,7 @@ class SecretIT { @Test void load() { - Secret aSecret = client.secrets().load(getClass().getResourceAsStream("/test-secret.yml")).get(); + Secret aSecret = client.secrets().load(getClass().getResourceAsStream("/test-secret.yml")).item(); assertThat(aSecret).isNotNull(); assertEquals("my-secret", aSecret.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ServiceAccountIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ServiceAccountIT.java index e021798c630..3d5aece987b 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ServiceAccountIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ServiceAccountIT.java @@ -38,7 +38,7 @@ class ServiceAccountIT { @Test void load() { ServiceAccount svcAccount = client.serviceAccounts() - .load(getClass().getResourceAsStream("/test-serviceaccount.yml")).get(); + .load(getClass().getResourceAsStream("/test-serviceaccount.yml")).item(); assertThat(svcAccount).isNotNull(); assertThat(svcAccount.getMetadata().getName()).isNotNull(); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ServiceIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ServiceIT.java index ccbdd8da116..bcf063a7e0b 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ServiceIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ServiceIT.java @@ -43,7 +43,7 @@ class ServiceIT { @Test void load() { - Service aService = client.services().load(getClass().getResourceAsStream("/test-service.yml")).get(); + Service aService = client.services().load(getClass().getResourceAsStream("/test-service.yml")).item(); assertThat(aService).isNotNull(); assertEquals("my-service", aService.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/StatefulSetIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/StatefulSetIT.java index a8b395656e3..f2b1c95b4f4 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/StatefulSetIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/StatefulSetIT.java @@ -38,7 +38,7 @@ class StatefulSetIT { @Test void load() { StatefulSet aStatefulSet = client.apps().statefulSets() - .load(getClass().getResourceAsStream("/test-statefulset.yml")).get(); + .load(getClass().getResourceAsStream("/test-statefulset.yml")).item(); assertThat(aStatefulSet).isNotNull(); assertEquals("web", aStatefulSet.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/StorageClassIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/StorageClassIT.java index 0e50ff8b130..57d0f172754 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/StorageClassIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/StorageClassIT.java @@ -34,7 +34,7 @@ class StorageClassIT { @Test void load() { StorageClass storageClassLoaded = client.storage().storageClasses() - .load(getClass().getResourceAsStream("/test-storageclass.yml")).get(); + .load(getClass().getResourceAsStream("/test-storageclass.yml")).item(); assertNotNull(storageClassLoaded); assertEquals("gluster-vol-default", storageClassLoaded.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigIT.java index 3c73f44719c..b668e6eee14 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/BuildConfigIT.java @@ -42,7 +42,7 @@ class BuildConfigIT { @Test void load() { BuildConfig aBuildConfig = client.buildConfigs() - .load(getClass().getResourceAsStream("/test-buildconfig.yml")).get(); + .load(getClass().getResourceAsStream("/test-buildconfig.yml")).item(); assertThat(aBuildConfig).isNotNull(); assertEquals("ruby-sample-build", aBuildConfig.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/DeploymentConfigIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/DeploymentConfigIT.java index f3dd1ced07a..de6401d1e1c 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/DeploymentConfigIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/DeploymentConfigIT.java @@ -41,7 +41,7 @@ class DeploymentConfigIT { @Test void load() { DeploymentConfig deploymentConfig = client.deploymentConfigs() - .load(getClass().getResourceAsStream("/test-deploymentconfig.yml")).get(); + .load(getClass().getResourceAsStream("/test-deploymentconfig.yml")).item(); assertThat(deploymentConfig).isNotNull(); assertEquals("frontend", deploymentConfig.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamIT.java index 375c380a015..1d8dee80869 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamIT.java @@ -41,7 +41,7 @@ class ImageStreamIT { @Test void load() { ImageStream aImageStream = client.imageStreams() - .load(getClass().getResourceAsStream("/test-imagestream.yml")).get(); + .load(getClass().getResourceAsStream("/test-imagestream.yml")).item(); assertThat(aImageStream).isNotNull(); assertEquals("my-ruby", aImageStream.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamTagIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamTagIT.java index 78d49aba259..3150b68dc9f 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamTagIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/ImageStreamTagIT.java @@ -39,7 +39,7 @@ class ImageStreamTagIT { @Test void load() { ImageStreamTag loadedIST = client.imageStreamTags() - .load(getClass().getResourceAsStream("/test-ist.yml")).get(); + .load(getClass().getResourceAsStream("/test-ist.yml")).item(); assertNotNull(loadedIST); assertEquals("bar1:1.0.12", loadedIST.getMetadata().getName()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/RouteIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/RouteIT.java index cc9226ca030..4c8d6c9825a 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/RouteIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/RouteIT.java @@ -41,7 +41,7 @@ class RouteIT { @Test void load() { - Route aRoute = client.routes().load(getClass().getResourceAsStream("/test-route.yml")).get(); + Route aRoute = client.routes().load(getClass().getResourceAsStream("/test-route.yml")).item(); assertThat(aRoute).isNotNull(); assertEquals("host-route", aRoute.getMetadata().getName()); } diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/SecurityContextConstraintsIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/SecurityContextConstraintsIT.java index 0945d07a99d..113c26e0ab0 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/SecurityContextConstraintsIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/SecurityContextConstraintsIT.java @@ -42,7 +42,7 @@ class SecurityContextConstraintsIT { void load() { SecurityContextConstraints loadedSCC = client.securityContextConstraints() - .load(getClass().getResourceAsStream("/test-scc.yml")).get(); + .load(getClass().getResourceAsStream("/test-scc.yml")).item(); assertNotNull(loadedSCC); assertEquals("test-scc", loadedSCC.getMetadata().getName()); diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/ServiceToURLIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/ServiceToURLIT.java index 80ec4e4ff2a..18dd4018180 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/ServiceToURLIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/ServiceToURLIT.java @@ -85,7 +85,7 @@ void getURL() { // Testing Ingress Impl Ingress ingress = client.extensions().ingresses().load(getClass().getResourceAsStream("/test-ingress-extensions.yml")) - .get(); + .item(); client.extensions().ingresses().create(ingress); url = client.services().withName("svc2").getURL("80"); diff --git a/kubernetes-itests/src/test/java/io/fabric8/openshift/TemplateIT.java b/kubernetes-itests/src/test/java/io/fabric8/openshift/TemplateIT.java index 73bd2185ab4..4d079a50701 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/openshift/TemplateIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/openshift/TemplateIT.java @@ -46,7 +46,7 @@ void load() { Template template = client.templates() .withParameters(Collections.singletonMap("REDIS_PASSWORD", "secret")) - .load(getClass().getResourceAsStream("/test-template.yml")).get(); + .load(getClass().getResourceAsStream("/test-template.yml")).item(); assertThat(template).isNotNull(); assertEquals(1, template.getObjects().size()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/APIServiceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/APIServiceTest.java index 7436a920490..37ea89bf42c 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/APIServiceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/APIServiceTest.java @@ -59,7 +59,7 @@ void load() { // Given // When - APIService apiService = client.apiServices().load(getClass().getResourceAsStream("/test-apiservice.yml")).get(); + APIService apiService = client.apiServices().load(getClass().getResourceAsStream("/test-apiservice.yml")).item(); // Then assertNotNull(apiService); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSIDriverTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSIDriverTest.java index 1c8850c13ee..9d547693e50 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSIDriverTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSIDriverTest.java @@ -28,6 +28,7 @@ import java.net.HttpURLConnection; import java.util.List; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; @EnableKubernetesMockClient @@ -37,7 +38,7 @@ class CSIDriverTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/test-csidriver.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/test-csidriver.yml")).items(); assertThat(items).isNotNull(); assertThat(items.get(0)) .isInstanceOf(CSIDriver.class) diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSINodeTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSINodeTest.java index 1cf26f5fc1d..a1987404dd2 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSINodeTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSINodeTest.java @@ -38,7 +38,7 @@ class CSINodeTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/test-csinode.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/test-csinode.yml")).items(); assertThat(items).isNotNull(); AssertionsForClassTypes.assertThat(items.get(0)) .isInstanceOf(CSINode.class) diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSIStorageCapacityTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSIStorageCapacityTest.java index cf74f29571b..f3432a99d8d 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSIStorageCapacityTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CSIStorageCapacityTest.java @@ -38,7 +38,7 @@ class CSIStorageCapacityTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/test-csistoragecapacity.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/test-csistoragecapacity.yml")).items(); assertThat(items).isNotNull(); AssertionsForClassTypes.assertThat(items.get(0)) .isInstanceOf(CSIStorageCapacity.class) diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CertificateSigningRequestTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CertificateSigningRequestTest.java index d7960d0cd01..0f719d35727 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CertificateSigningRequestTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CertificateSigningRequestTest.java @@ -44,7 +44,7 @@ void testLoad() { // Given // When - List resources = client.load(getClass().getResourceAsStream("/test-csr.yml")).get(); + List resources = client.load(getClass().getResourceAsStream("/test-csr.yml")).items(); // Then assertEquals(1, resources.size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterRoleCrudTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterRoleCrudTest.java index fb402c6a25f..df0bb3ae554 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterRoleCrudTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterRoleCrudTest.java @@ -154,6 +154,6 @@ void crudTest() { @Test void testLoadFromFile() { - assertNotNull(client.rbac().clusterRoles().load(getClass().getResourceAsStream("/test-clusterrole.yml")).get()); + assertNotNull(client.rbac().clusterRoles().load(getClass().getResourceAsStream("/test-clusterrole.yml")).item()); } } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterRoleTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterRoleTest.java index 0ef9cc3219d..75127d90b11 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterRoleTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ClusterRoleTest.java @@ -25,7 +25,6 @@ import java.util.List; -import static org.assertj.core.api.AssertionsForClassTypes.fail; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -37,7 +36,7 @@ class ClusterRoleTest { @Test void testLoadFromFile() { ClusterRole kubernetesClusterRole = client.rbac().clusterRoles() - .load(getClass().getResourceAsStream("/test-clusterrole.yml")).get(); + .load(getClass().getResourceAsStream("/test-clusterrole.yml")).item(); assertNotNull(kubernetesClusterRole); } @@ -50,14 +49,10 @@ void testHandlersLoadFromFile() { assertNotNull(load); - try { - List hasMetadata = load.get(); + List hasMetadata = load.items(); - assertNotNull(hasMetadata); - assertEquals(1, hasMetadata.size()); - assertEquals("viewer", hasMetadata.get(0).getMetadata().getName()); - } catch (NullPointerException e) { - fail("No handler found for specified resource"); - } + assertNotNull(hasMetadata); + assertEquals(1, hasMetadata.size()); + assertEquals("viewer", hasMetadata.get(0).getMetadata().getName()); } } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ConfigMapTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ConfigMapTest.java index bfff65e0e5d..a9b2942fe23 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ConfigMapTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ConfigMapTest.java @@ -88,7 +88,7 @@ void testDeletes() throws InterruptedException { @Test void testFromResourceWithFileConfigMap() throws InterruptedException { ConfigMap configMap = client.configMaps() - .load(getClass().getResourceAsStream("/test-application-properties-config-map.yml")).get(); + .load(getClass().getResourceAsStream("/test-application-properties-config-map.yml")).item(); assertEquals("cfg1", configMap.getMetadata().getName()); Map data = (Map) configMap.getData(); @@ -105,7 +105,7 @@ void testFromResourceWithFileConfigMap() throws InterruptedException { @Test void testFromResourceConfigMap() throws InterruptedException { - ConfigMap configMap = client.configMaps().load(getClass().getResourceAsStream("/test-config-map.yml")).get(); + ConfigMap configMap = client.configMaps().load(getClass().getResourceAsStream("/test-config-map.yml")).item(); assertEquals("cfg1", configMap.getMetadata().getName()); Map keys = (Map) configMap.getData(); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ControllerRevisionTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ControllerRevisionTest.java index 63bcb9c125d..509cc929724 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ControllerRevisionTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ControllerRevisionTest.java @@ -28,6 +28,7 @@ import java.net.HttpURLConnection; import java.util.List; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; @EnableKubernetesMockClient @@ -37,7 +38,7 @@ class ControllerRevisionTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/test-controllerrevision.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/test-controllerrevision.yml")).items(); assertThat(items).isNotNull().hasSize(1); assertThat(items.get(0)).isInstanceOf(ControllerRevision.class); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CronJobTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CronJobTest.java index 2547ccdec80..6b7f1c9c1fe 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CronJobTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CronJobTest.java @@ -255,12 +255,12 @@ void testCreateWithNameMismatch() { @Test void testLoadFromFile() { - assertNotNull(client.batch().cronjobs().load(getClass().getResourceAsStream("/test-cronjob.yml")).get()); + assertNotNull(client.batch().cronjobs().load(getClass().getResourceAsStream("/test-cronjob.yml")).item()); } @Test void testHandlersLoadFromFile() { - List hasMetadata = client.load(getClass().getResourceAsStream("/test-cronjob.yml")).get(); + List hasMetadata = client.load(getClass().getResourceAsStream("/test-cronjob.yml")).items(); assertNotNull(hasMetadata); assertEquals(1, hasMetadata.size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java index ee0c0b4cc14..391bb91468e 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceCrudTest.java @@ -53,7 +53,7 @@ void setUp() { .apiextensions().v1() .customResourceDefinitions() .load(getClass().getResourceAsStream("/crontab-crd.yml")) - .get(); + .item(); client.apiextensions().v1().customResourceDefinitions().create(cronTabCrd); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceDefinitionTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceDefinitionTest.java index 6b36e0d1c51..f1a81960d90 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceDefinitionTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceDefinitionTest.java @@ -78,7 +78,7 @@ void testLoad() { @Test void testLoadWithJsonSchemaPropsOrBool() { CustomResourceDefinition customResourceDefinition = client.apiextensions().v1beta1().customResourceDefinitions() - .load(getClass().getResourceAsStream("/kafka-crd.yml")).get(); + .load(getClass().getResourceAsStream("/kafka-crd.yml")).item(); assertNotNull(customResourceDefinition); assertEquals("kafkatopics.kafka.test", customResourceDefinition.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java index 4c27320cc6d..bdbca9e279f 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/CustomResourceTest.java @@ -75,7 +75,7 @@ class CustomResourceTest { @Test void testLoad() throws IOException { GenericKubernetesResource customResource = client.genericKubernetesResources(customResourceDefinitionContext) - .load(getClass().getResourceAsStream("/test-hello-cr.yml")).get(); + .load(getClass().getResourceAsStream("/test-hello-cr.yml")).item(); assertThat(customResource) .isNotNull() .hasFieldOrPropertyWithValue("metadata.name", "example-hello"); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DeploymentTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DeploymentTest.java index a899ba3efd8..094914bde77 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DeploymentTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DeploymentTest.java @@ -380,7 +380,7 @@ void testListFromServer() { .withPath("/apis/apps/v1/namespaces/test/deployments/deployment1") .andReturn(200, serverDeployment).once(); - List resources = client.resourceList(clientDeployment).fromServer().get(); + List resources = client.resourceList(clientDeployment).get(); assertNotNull(resources); assertEquals(1, resources.size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/EndpointSliceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/EndpointSliceTest.java index 263fc165c6f..cc13a12b675 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/EndpointSliceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/EndpointSliceTest.java @@ -38,7 +38,7 @@ class EndpointSliceTest { void load() { // Given + When EndpointSlice es = client.discovery().v1beta1().endpointSlices().load(getClass().getResourceAsStream("/endpointslice.yml")) - .get(); + .item(); // Than assertThat(es).isNotNull(); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/EndpointsTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/EndpointsTest.java index 8bdbe6549e8..b81a0a32412 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/EndpointsTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/EndpointsTest.java @@ -172,7 +172,7 @@ public void testCreateWithNameMismatch() { @Test public void testLoad() { - Endpoints endpoints = client.endpoints().load(getClass().getResourceAsStream("/test-endpoints.yml")).get(); + Endpoints endpoints = client.endpoints().load(getClass().getResourceAsStream("/test-endpoints.yml")).item(); assertNotNull(endpoints); assertEquals("external-web", endpoints.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/FlowSchemaTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/FlowSchemaTest.java index 549ecc95136..4f3916f4cc3 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/FlowSchemaTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/FlowSchemaTest.java @@ -28,6 +28,7 @@ import java.net.HttpURLConnection; import java.util.List; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; @EnableKubernetesMockClient @@ -37,7 +38,7 @@ class FlowSchemaTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/v1beta1-flowschema.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/v1beta1-flowschema.yml")).items(); assertThat(items).isNotNull().hasSize(1); assertThat(items.get(0)) .isInstanceOf(FlowSchema.class) diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/LimitRangeLoadTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/LimitRangeLoadTest.java index 2fa61915a7f..97bf713adb6 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/LimitRangeLoadTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/LimitRangeLoadTest.java @@ -33,7 +33,7 @@ public class LimitRangeLoadTest { @Test public void load() { - LimitRange limitRange = client.limitRanges().load(getClass().getResourceAsStream("/test-limitRange.yml")).get(); + LimitRange limitRange = client.limitRanges().load(getClass().getResourceAsStream("/test-limitRange.yml")).item(); assertNotNull(limitRange); assertEquals("resource-limits", limitRange.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/LoadTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/LoadTest.java index cd7aa01f4d1..450536fab54 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/LoadTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/LoadTest.java @@ -39,7 +39,7 @@ void testResourceGetFromLoadWhenMultipleDocumentsWithDelimiter() throws Exceptio // given // when - List result = client.load(getClass().getResourceAsStream("/multiple-document-template.yml")).get(); + List result = client.load(getClass().getResourceAsStream("/multiple-document-template.yml")).items(); // then assertNotNull(result); @@ -52,7 +52,7 @@ void testResourceGetFromLoadWhenMultipleDocumentsWithDelimiter() throws Exceptio @Test void testNetworkPolicyLoad() { - List itemList = client.load(getClass().getResourceAsStream("/test-networkpolicy.yml")).get(); + List itemList = client.load(getClass().getResourceAsStream("/test-networkpolicy.yml")).items(); assertEquals(1, itemList.size()); NetworkPolicy ingress = (NetworkPolicy) itemList.get(0); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NamespaceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NamespaceTest.java index 7ad6ee1ec6f..ae7e08ce21e 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NamespaceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NamespaceTest.java @@ -145,7 +145,7 @@ public void testDeleteMulti() { @Test public void testLoadFromFile() { - Namespace namespace = client.namespaces().load(getClass().getResourceAsStream("/test-namespace.yml")).get(); + Namespace namespace = client.namespaces().load(getClass().getResourceAsStream("/test-namespace.yml")).item(); assertEquals("namespace-test", namespace.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1IngressTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1IngressTest.java index 8e16a0c4355..7681c4f1372 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1IngressTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1IngressTest.java @@ -47,7 +47,7 @@ class NetworkingV1IngressTest { @Test void testLoad() { - List itemList = client.load(getClass().getResourceAsStream("/test-v1-ingress.yml")).get(); + List itemList = client.load(getClass().getResourceAsStream("/test-v1-ingress.yml")).items(); assertEquals(1, itemList.size()); Ingress ingress = (Ingress) itemList.get(0); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1beta1IngressTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1beta1IngressTest.java index b2d0743c01d..df8ce97775c 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1beta1IngressTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/NetworkingV1beta1IngressTest.java @@ -45,7 +45,7 @@ class NetworkingV1beta1IngressTest { @Test void testLoad() { - List itemList = client.load(getClass().getResourceAsStream("/test-v1beta1-ingress.yml")).get(); + List itemList = client.load(getClass().getResourceAsStream("/test-v1beta1-ingress.yml")).items(); assertEquals(1, itemList.size()); Ingress ingress = (Ingress) itemList.get(0); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PersistentVolumeClaimTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PersistentVolumeClaimTest.java index 855d7d1f666..c2bcb0df5f2 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PersistentVolumeClaimTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PersistentVolumeClaimTest.java @@ -170,7 +170,7 @@ void testDeleteMulti() { @Test void testLoadFromFile() { PersistentVolumeClaim persistentVolumeClaim = client.persistentVolumeClaims() - .load(getClass().getResourceAsStream("/test-persistentvolumeclaim.yml")).get(); + .load(getClass().getResourceAsStream("/test-persistentvolumeclaim.yml")).item(); assertEquals("task-pv-claim", persistentVolumeClaim.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PersistentVolumeTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PersistentVolumeTest.java index 757d257a4d8..e4ae018569d 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PersistentVolumeTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PersistentVolumeTest.java @@ -118,7 +118,7 @@ public void testDeleteMulti() { @Test public void testLoadFromFile() { PersistentVolume persistentVolume = client.persistentVolumes() - .load(getClass().getResourceAsStream("/test-persistentvolume.yml")).get(); + .load(getClass().getResourceAsStream("/test-persistentvolume.yml")).item(); assertEquals("pv-test", persistentVolume.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodDisruptionBudgetTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodDisruptionBudgetTest.java index 6730a1b0c43..a62a2cb0aad 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodDisruptionBudgetTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodDisruptionBudgetTest.java @@ -162,6 +162,6 @@ public void testCreateWithNameMismatch() { @Test public void testLoadFromFile() { - assertNotNull(client.policy().podDisruptionBudget().load(getClass().getResourceAsStream("/test-pdb.yml")).get()); + assertNotNull(client.policy().podDisruptionBudget().load(getClass().getResourceAsStream("/test-pdb.yml")).item()); } } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodTemplateTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodTemplateTest.java index b6e368a749d..d855a85ba25 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodTemplateTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodTemplateTest.java @@ -38,7 +38,7 @@ public class PodTemplateTest { @Test @DisplayName("Should load a PodTemplate from yaml") public void testLoad() { - PodTemplate podTemplate = client.v1().podTemplates().load(getClass().getResourceAsStream("/test-podtemplate.yml")).get(); + PodTemplate podTemplate = client.v1().podTemplates().load(getClass().getResourceAsStream("/test-podtemplate.yml")).item(); assertNotNull(podTemplate); assertEquals("hello", podTemplate.getMetadata().getName()); assertEquals(1, podTemplate.getTemplate().getSpec().getContainers().size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodTest.java index 10267e9ca78..b559f875d71 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PodTest.java @@ -670,7 +670,7 @@ void testGetLogNotFound() { @Test void testLoad() { - Pod pod = client.pods().load(getClass().getResourceAsStream("/test-pod.yml")).get(); + Pod pod = client.pods().load(getClass().getResourceAsStream("/test-pod.yml")).item(); assertEquals("nginx", pod.getMetadata().getName()); } @@ -896,7 +896,7 @@ void testListFromServer() { .andReturn(200, serverPod) .once(); - List resources = client.resourceList(clientPod).fromServer().get(); + List resources = client.resourceList(clientPod).get(); assertNotNull(resources); assertEquals(1, resources.size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PriorityClassTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PriorityClassTest.java index e7952cfba4f..4e7b1d42696 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PriorityClassTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PriorityClassTest.java @@ -155,6 +155,6 @@ void testCreateWithNameMismatch() { @Test void testLoadFromFile() { assertNotNull( - client.scheduling().v1beta1().priorityClasses().load(getClass().getResourceAsStream("/test-priorityclass.yml")).get()); + client.scheduling().v1beta1().priorityClasses().load(getClass().getResourceAsStream("/test-priorityclass.yml")).item()); } } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PriorityLevelConfigurationTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PriorityLevelConfigurationTest.java index 4f2ddedac96..0188bfbb533 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PriorityLevelConfigurationTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/PriorityLevelConfigurationTest.java @@ -38,7 +38,7 @@ class PriorityLevelConfigurationTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/v1beta1-prioritylevelconfiguration.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/v1beta1-prioritylevelconfiguration.yml")).items(); assertThat(items).isNotNull().hasSize(1); AssertionsForClassTypes.assertThat(items.get(0)) .isInstanceOf(PriorityLevelConfiguration.class) diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceQuotaTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceQuotaTest.java index e9dd8a6b17f..b444dc6687b 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceQuotaTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceQuotaTest.java @@ -115,7 +115,7 @@ public void testeDeleteMulti() { @Test public void testLoadFromFile() { - List list = client.load(getClass().getResourceAsStream("/test-resourcequota.yml")).get(); + List list = client.load(getClass().getResourceAsStream("/test-resourcequota.yml")).items(); assertEquals(3, list.size()); assertTrue(list.get(0) instanceof ResourceQuota); assertEquals("compute-quota", list.get(0).getMetadata().getName()); @@ -147,7 +147,7 @@ public void testBuild() { .once(); Deployment deployment = client.apps().deployments() - .load(getClass().getResourceAsStream("/test-resourcequota-deployment.yml")).get(); + .load(getClass().getResourceAsStream("/test-resourcequota-deployment.yml")).item(); server.expect().withPath("/apis/apps/v1/namespaces/myspace/deployments/deployment").andReturn(200, deployment).once(); ResourceQuota resourcequota = client.resourceQuotas().inNamespace("myspace").withName("compute-quota").get(); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceTest.java index e2481629c31..baf5648adaa 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ResourceTest.java @@ -662,7 +662,7 @@ void testFromServerGet() { server.expect().get().withPath("/api/v1/namespaces/test/pods/pod1").andReturn(200, pod).once(); - HasMetadata response = client.resource(pod).fromServer().get(); + HasMetadata response = client.resource(pod).get(); assertEquals(pod, response); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/RuntimeClassTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/RuntimeClassTest.java index caddbd26443..0ff154298f9 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/RuntimeClassTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/RuntimeClassTest.java @@ -43,7 +43,7 @@ void testLoad() { // Given // When - List itemList = client.load(getClass().getResourceAsStream("/test-runtimeclass.yml")).get(); + List itemList = client.load(getClass().getResourceAsStream("/test-runtimeclass.yml")).items(); // Then assertEquals(1, itemList.size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ServiceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ServiceTest.java index 27e76d14f3d..dee06e39505 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ServiceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/ServiceTest.java @@ -71,7 +71,7 @@ void prepareService() { @Test void testLoad() { - Service svc = client.services().load(getClass().getResourceAsStream("/test-service.yml")).get(); + Service svc = client.services().load(getClass().getResourceAsStream("/test-service.yml")).item(); assertNotNull(svc); assertEquals("httpbin", svc.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/StatefulSetTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/StatefulSetTest.java index 3283d91b24f..faf662fb0d9 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/StatefulSetTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/StatefulSetTest.java @@ -180,7 +180,7 @@ public void testDelete() { @Test public void testDeleteLoadedResource() { - StatefulSet response = client.apps().statefulSets().load(getClass().getResourceAsStream("/test-statefulset.yml")).get(); + StatefulSet response = client.apps().statefulSets().load(getClass().getResourceAsStream("/test-statefulset.yml")).item(); server.expect() .delete() .withPath("/apis/apps/v1/namespaces/test/statefulsets/example") diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CertificateSigningRequestTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CertificateSigningRequestTest.java index d634b6ff813..bf5d2fa3d47 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CertificateSigningRequestTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CertificateSigningRequestTest.java @@ -44,7 +44,7 @@ class V1CertificateSigningRequestTest { @Test void testLoad() { // When - List resources = client.load(getClass().getResourceAsStream("/test-v1-csr.yml")).get(); + List resources = client.load(getClass().getResourceAsStream("/test-v1-csr.yml")).items(); // Then assertThat(resources).hasSize(1); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CronJobTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CronJobTest.java index 1ed8c091ccd..cae9f7fc136 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CronJobTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1CronJobTest.java @@ -250,12 +250,12 @@ void testCreateWithNameMismatch() { @Test void testLoadFromFile() { - assertNotNull(client.batch().v1().cronjobs().load(getClass().getResourceAsStream("/test-cronjob.yml")).get()); + assertNotNull(client.batch().v1().cronjobs().load(getClass().getResourceAsStream("/test-cronjob.yml")).item()); } @Test void testHandlersLoadFromFile() { - List hasMetadata = client.load(getClass().getResourceAsStream("/v1-cronjob.yml")).get(); + List hasMetadata = client.load(getClass().getResourceAsStream("/v1-cronjob.yml")).items(); assertNotNull(hasMetadata); assertEquals(1, hasMetadata.size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1EndpointSliceTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1EndpointSliceTest.java index 67444ee52a3..51fa1de2e0c 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1EndpointSliceTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1EndpointSliceTest.java @@ -37,7 +37,7 @@ class V1EndpointSliceTest { void load() { // Given + When EndpointSlice es = client.discovery().v1().endpointSlices().load(getClass().getResourceAsStream("/v1-endpointslice.yml")) - .get(); + .item(); // Than assertThat(es).isNotNull(); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1HorizontalPodAutoscalerTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1HorizontalPodAutoscalerTest.java index 871dd4edd47..2e29e68bc40 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1HorizontalPodAutoscalerTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1HorizontalPodAutoscalerTest.java @@ -45,7 +45,7 @@ public class V1HorizontalPodAutoscalerTest { @Test void testLoadAsPlainList() { - List itemsList = client.load(getClass().getResourceAsStream("/test-horizontalpodautoscaler.yml")).get(); + List itemsList = client.load(getClass().getResourceAsStream("/test-horizontalpodautoscaler.yml")).items(); assertNotNull(itemsList); assertEquals(1, itemsList.size()); @@ -193,7 +193,7 @@ void testCreateWithNameMismatch() { @Test void testLoadFromFile() { HorizontalPodAutoscaler horizontalPodAutoscaler = client.autoscaling().v1().horizontalPodAutoscalers() - .load(getClass().getResourceAsStream("/test-horizontalpodautoscaler.yml")).get(); + .load(getClass().getResourceAsStream("/test-horizontalpodautoscaler.yml")).item(); assertEquals("php-apache", horizontalPodAutoscaler.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1IngressClassTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1IngressClassTest.java index 335616b065e..f63d49599c8 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1IngressClassTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1IngressClassTest.java @@ -45,7 +45,7 @@ class V1IngressClassTest { @Test void testLoad() { // When - List itemList = client.load(getClass().getResourceAsStream("/test-v1-ingressclass.yml")).get(); + List itemList = client.load(getClass().getResourceAsStream("/test-v1-ingressclass.yml")).items(); // Then assertEquals(1, itemList.size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1PodDisruptionBudgetTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1PodDisruptionBudgetTest.java index 8a33cb94310..dcd3671422b 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1PodDisruptionBudgetTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1PodDisruptionBudgetTest.java @@ -161,6 +161,6 @@ void testCreateWithNameMismatch() { @Test void testLoadFromFile() { - assertNotNull(client.policy().v1().podDisruptionBudget().load(getClass().getResourceAsStream("/v1-pdb.yml")).get()); + assertNotNull(client.policy().v1().podDisruptionBudget().load(getClass().getResourceAsStream("/v1-pdb.yml")).item()); } } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1PriorityClassTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1PriorityClassTest.java index d2983d32b10..e754b088bf6 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1PriorityClassTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1PriorityClassTest.java @@ -168,7 +168,8 @@ void testCreateWithNameMismatch() { @Test void testLoadFromFile() { - assertNotNull(client.scheduling().priorityClass().load(getClass().getResourceAsStream("/test-v1-priorityclass.yml")).get()); + assertNotNull( + client.scheduling().priorityClass().load(getClass().getResourceAsStream("/test-v1-priorityclass.yml")).item()); } } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1ValidatingWebhookConfigurationTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1ValidatingWebhookConfigurationTest.java index d69bf745a52..b047f57d232 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1ValidatingWebhookConfigurationTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1ValidatingWebhookConfigurationTest.java @@ -50,7 +50,7 @@ public void createUsingResource() { @Test public void load() { ValidatingWebhookConfiguration vwc = client.admissionRegistration().v1().validatingWebhookConfigurations() - .load(getClass().getResourceAsStream("/v1-vwc.yml")).get(); + .load(getClass().getResourceAsStream("/v1-vwc.yml")).item(); assertNotNull(vwc); assertEquals("pod-policy.example.com", vwc.getMetadata().getName()); assertEquals(1, vwc.getWebhooks().size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta1ValidatingWebhookConfigurationTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta1ValidatingWebhookConfigurationTest.java index 8546c4bedf0..efe8afd780d 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta1ValidatingWebhookConfigurationTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta1ValidatingWebhookConfigurationTest.java @@ -50,7 +50,7 @@ public void createUsingResource() { @Test public void load() { ValidatingWebhookConfiguration vwc = client.admissionRegistration().v1beta1().validatingWebhookConfigurations() - .load(getClass().getResourceAsStream("/v1beta1-vwc.yml")).get(); + .load(getClass().getResourceAsStream("/v1beta1-vwc.yml")).item(); assertNotNull(vwc); assertEquals("pod-policy.example.com", vwc.getMetadata().getName()); assertEquals(1, vwc.getWebhooks().size()); diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta2FlowSchemaTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta2FlowSchemaTest.java index 7fe6ebb1699..c9299b040ca 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta2FlowSchemaTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta2FlowSchemaTest.java @@ -38,7 +38,7 @@ class V1beta2FlowSchemaTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/v1beta2-flowschema.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/v1beta2-flowschema.yml")).items(); assertThat(items).isNotNull().hasSize(1); AssertionsForClassTypes.assertThat(items.get(0)) .isInstanceOf(FlowSchema.class) diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta2PriorityLevelConfigurationTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta2PriorityLevelConfigurationTest.java index 34aab50cc02..359c23bae9f 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta2PriorityLevelConfigurationTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V1beta2PriorityLevelConfigurationTest.java @@ -38,7 +38,7 @@ class V1beta2PriorityLevelConfigurationTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/v1beta2-prioritylevelconfiguration.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/v1beta2-prioritylevelconfiguration.yml")).items(); assertThat(items).isNotNull().hasSize(1); AssertionsForClassTypes.assertThat(items.get(0)) .isInstanceOf(PriorityLevelConfiguration.class) diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2HorizontalPodAutoscalerTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2HorizontalPodAutoscalerTest.java index da4450be1bd..107170fc639 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2HorizontalPodAutoscalerTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2HorizontalPodAutoscalerTest.java @@ -32,6 +32,7 @@ import java.util.List; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; @@ -43,7 +44,7 @@ class V2HorizontalPodAutoscalerTest { @Test void load() { - List itemsList = client.load(getClass().getResourceAsStream("/test-v2-hpa.yml")).get(); + List itemsList = client.load(getClass().getResourceAsStream("/test-v2-hpa.yml")).items(); assertThat(itemsList) .hasSize(1) @@ -209,7 +210,7 @@ void createWithNameMismatch() { @Test void loadFromFile() { HorizontalPodAutoscaler horizontalPodAutoscaler = client.autoscaling().v2().horizontalPodAutoscalers() - .load(getClass().getResourceAsStream("/test-v2-hpa.yml")).get(); + .load(getClass().getResourceAsStream("/test-v2-hpa.yml")).item(); assertThat(horizontalPodAutoscaler) .hasFieldOrPropertyWithValue("metadata.name", "php-apache"); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2beta1HorizontalPodAutoscalerTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2beta1HorizontalPodAutoscalerTest.java index ece9e50ac22..8ff21283934 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2beta1HorizontalPodAutoscalerTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2beta1HorizontalPodAutoscalerTest.java @@ -181,7 +181,7 @@ public void testCreateWithNameMismatch() { @Test public void testLoadFromFile() { HorizontalPodAutoscaler horizontalPodAutoscaler = client.autoscaling().v2beta1().horizontalPodAutoscalers() - .load(getClass().getResourceAsStream("/test-v2beta1-horizontalpodautoscaler.yml")).get(); + .load(getClass().getResourceAsStream("/test-v2beta1-horizontalpodautoscaler.yml")).item(); assertEquals("php-apache", horizontalPodAutoscaler.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2beta2HorizontalPodAutoscalerTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2beta2HorizontalPodAutoscalerTest.java index 3bcdb219397..09cd10b36f6 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2beta2HorizontalPodAutoscalerTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/V2beta2HorizontalPodAutoscalerTest.java @@ -45,7 +45,7 @@ public class V2beta2HorizontalPodAutoscalerTest { @Test void testLoadAsPlainList() { - List itemsList = client.load(getClass().getResourceAsStream("/test-v2beta2-hpa.yml")).get(); + List itemsList = client.load(getClass().getResourceAsStream("/test-v2beta2-hpa.yml")).items(); assertNotNull(itemsList); assertEquals(1, itemsList.size()); @@ -195,7 +195,7 @@ public void testCreateWithNameMismatch() { @Test public void testLoadFromFile() { HorizontalPodAutoscaler horizontalPodAutoscaler = client.autoscaling().v2beta2().horizontalPodAutoscalers() - .load(getClass().getResourceAsStream("/test-v2beta2-horizontalpodautoscaler.yml")).get(); + .load(getClass().getResourceAsStream("/test-v2beta2-horizontalpodautoscaler.yml")).item(); assertEquals("php-apache", horizontalPodAutoscaler.getMetadata().getName()); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/VolumeAttachmentTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/VolumeAttachmentTest.java index dedf3cbace4..2a90bd902a7 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/VolumeAttachmentTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/VolumeAttachmentTest.java @@ -28,6 +28,7 @@ import java.net.HttpURLConnection; import java.util.List; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; @EnableKubernetesMockClient @@ -37,7 +38,7 @@ class VolumeAttachmentTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/test-volumeattachment.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/test-volumeattachment.yml")).items(); assertThat(items).isNotNull(); assertThat(items.get(0)) .isInstanceOf(VolumeAttachment.class) diff --git a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/ClusterServiceVersionTest.java b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/ClusterServiceVersionTest.java index 4e3a8961393..7794ce59da3 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/ClusterServiceVersionTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/ClusterServiceVersionTest.java @@ -30,7 +30,7 @@ class ClusterServiceVersionTest { void testLoad() { ClusterServiceVersion clusterServiceVersion = client.operatorHub().clusterServiceVersions() .load(getClass().getResourceAsStream("/test-clusterserviceversion.yml")) - .get(); + .item(); assertThat(clusterServiceVersion) .isNotNull() diff --git a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/IngressTest.java b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/IngressTest.java index 9ddbde927f9..5aa6ea8f041 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/IngressTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/IngressTest.java @@ -36,7 +36,7 @@ class IngressTest { @Test void load() { List items = client.load(getClass().getResourceAsStream("/test-openshift-config-ingress.yml")) - .get(); + .items(); assertThat(items).isNotNull().hasSize(1); assertThat(items.get(0)).isInstanceOf(Ingress.class); } diff --git a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/OpenShiftLoadTest.java b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/OpenShiftLoadTest.java index 2bc3582bc22..95490417302 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/OpenShiftLoadTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/OpenShiftLoadTest.java @@ -34,13 +34,13 @@ class OpenShiftLoadTest { void testResourceGetFromLoadWhenSingleDocumentsWithStartingDelimiter() { // when - List result = client.load(getClass().getResourceAsStream("/test-template.yml")).get(); + List result = client.load(getClass().getResourceAsStream("/test-template.yml")).items(); // then assertNotNull(result); assertEquals(5, result.size()); HasMetadata deploymentResource = result.get(2); - assertEquals("image.openshift.io/v1", deploymentResource.getApiVersion()); + assertEquals("v1", deploymentResource.getApiVersion()); assertEquals("ImageStream", deploymentResource.getKind()); assertEquals("eap-app", deploymentResource.getMetadata().getName()); } @@ -49,7 +49,7 @@ void testResourceGetFromLoadWhenSingleDocumentsWithStartingDelimiter() { void testResourceGetFromLoadWhenSingleDocumentsWithoutDelimiter() { // when - List result = client.load(getClass().getResourceAsStream("/template-with-params.yml")).get(); + List result = client.load(getClass().getResourceAsStream("/template-with-params.yml")).items(); // then assertNotNull(result); diff --git a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/PrometheusRuleTest.java b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/PrometheusRuleTest.java index 51409e72397..176370fd37d 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/PrometheusRuleTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/PrometheusRuleTest.java @@ -38,7 +38,7 @@ class PrometheusRuleTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/test-prometheusrule.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/test-prometheusrule.yml")).items(); assertEquals(1, items.size()); assertTrue(items.get(0) instanceof PrometheusRule); PrometheusRule prometheusRule = (PrometheusRule) items.get(0); diff --git a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/PrometheusTest.java b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/PrometheusTest.java index a7067be6b08..62b5895ea65 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/PrometheusTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/PrometheusTest.java @@ -17,7 +17,13 @@ import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.IntOrString; -import io.fabric8.openshift.api.model.monitoring.v1.*; +import io.fabric8.openshift.api.model.monitoring.v1.AlertingSpec; +import io.fabric8.openshift.api.model.monitoring.v1.AlertmanagerEndpoints; +import io.fabric8.openshift.api.model.monitoring.v1.AlertmanagerEndpointsBuilder; +import io.fabric8.openshift.api.model.monitoring.v1.Prometheus; +import io.fabric8.openshift.api.model.monitoring.v1.PrometheusBuilder; +import io.fabric8.openshift.api.model.monitoring.v1.PrometheusList; +import io.fabric8.openshift.api.model.monitoring.v1.PrometheusListBuilder; import io.fabric8.openshift.client.OpenShiftClient; import org.junit.jupiter.api.Test; @@ -25,7 +31,9 @@ import java.util.ArrayList; import java.util.List; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; @EnableOpenShiftMockClient class PrometheusTest { @@ -35,7 +43,7 @@ class PrometheusTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/test-prometheus.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/test-prometheus.yml")).items(); assertEquals(1, items.size()); assertTrue(items.get(0) instanceof Prometheus); Prometheus prometheus = (Prometheus) items.get(0); diff --git a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/ServiceMonitorTest.java b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/ServiceMonitorTest.java index 12a02f750fd..8d553b5d84b 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/ServiceMonitorTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/ServiceMonitorTest.java @@ -38,7 +38,7 @@ class ServiceMonitorTest { @Test void load() { - List items = client.load(getClass().getResourceAsStream("/test-servicemonitor.yml")).get(); + List items = client.load(getClass().getResourceAsStream("/test-servicemonitor.yml")).items(); assertEquals(1, items.size()); assertTrue(items.get(0) instanceof ServiceMonitor); ServiceMonitor serviceMonitor = (ServiceMonitor) items.get(0); diff --git a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/TemplateTest.java b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/TemplateTest.java index e6bace4ce60..23acb5dc39a 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/TemplateTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/openshift/client/server/mock/TemplateTest.java @@ -236,7 +236,7 @@ void shouldLoadTemplateWithNumberParameters() { @Test void shouldGetTemplateWithNumberParameters() { OpenShiftClient client = new DefaultOpenShiftClient(new OpenShiftConfigBuilder().withDisableApiGroupCheck(true).build()); - Template template = client.templates().load(getClass().getResourceAsStream("/template-with-number-params.yml")).get(); + Template template = client.templates().load(getClass().getResourceAsStream("/template-with-number-params.yml")).item(); assertThat(template) .extracting(Template::getObjects) .asList() @@ -250,7 +250,7 @@ void shouldGetTemplateWithNumberParameters() { @Test void shouldGetTemplateFromServerWithNumberParameters() { - Template template = client.templates().load(getClass().getResourceAsStream("/template-with-number-params.yml")).get(); + Template template = client.templates().load(getClass().getResourceAsStream("/template-with-number-params.yml")).item(); server.expect() .withPath("/apis/template.openshift.io/v1/namespaces/test/templates/foo") @@ -273,7 +273,7 @@ void shouldGetTemplateFromServerWithNumberParameters() { @Test void shouldGetTemplateWithMultipleObjects() { OpenShiftClient client = new DefaultOpenShiftClient(new OpenShiftConfigBuilder().withDisableApiGroupCheck(true).build()); - Template template = client.templates().load(getClass().getResourceAsStream("/template-with-multiple-objects.yml")).get(); + Template template = client.templates().load(getClass().getResourceAsStream("/template-with-multiple-objects.yml")).item(); assertThat(template) .extracting(Template::getObjects) .asList() diff --git a/kubernetes-tests/src/test/java/io/fabric8/servicecatalog/client/mock/ServiceCatalogCrudTest.java b/kubernetes-tests/src/test/java/io/fabric8/servicecatalog/client/mock/ServiceCatalogCrudTest.java index bf56a47ca89..674c0d27726 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/servicecatalog/client/mock/ServiceCatalogCrudTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/servicecatalog/client/mock/ServiceCatalogCrudTest.java @@ -126,7 +126,7 @@ void testGet() { void testLoadFromFile() { ClusterServiceBroker brokerFromFile = client.clusterServiceBrokers() - .load(getClass().getResourceAsStream("/test-broker.yml")).get(); + .load(getClass().getResourceAsStream("/test-broker.yml")).item(); client.clusterServiceBrokers().create(brokerFromFile); diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/apps/DeploymentConfigOperationsImpl.java b/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/apps/DeploymentConfigOperationsImpl.java index d63fc271144..a595c884f18 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/apps/DeploymentConfigOperationsImpl.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/apps/DeploymentConfigOperationsImpl.java @@ -84,7 +84,7 @@ public DeploymentConfig deployLatest() { @Override public DeploymentConfig deployLatest(boolean wait) { - Long currentVersion = getMandatory().getStatus().getLatestVersion(); + Long currentVersion = getItemOrRequireFromServer().getStatus().getLatestVersion(); if (currentVersion == null) { currentVersion = 1L; } @@ -92,7 +92,7 @@ public DeploymentConfig deployLatest(boolean wait) { DeploymentConfig deployment = accept(d -> d.getStatus().setLatestVersion(latestVersion)); if (wait) { waitUntilDeploymentConfigIsScaled(deployment.getSpec().getReplicas()); - deployment = getMandatory(); + deployment = getItemOrRequireFromServer(); } return deployment; } @@ -107,7 +107,7 @@ public DeploymentConfig scale(int count, boolean wait) { DeploymentConfig deployment = accept(d -> d.getSpec().setReplicas(count)); if (wait) { waitUntilDeploymentConfigIsScaled(count); - deployment = getMandatory(); + deployment = getItemOrRequireFromServer(); } return deployment; } @@ -211,7 +211,7 @@ public LogWatch watchLog() { public LogWatch watchLog(OutputStream out) { try { // In case of DeploymentConfig we directly get logs at DeploymentConfig Url, but we need to wait for Pods - waitUntilDeploymentConfigPodBecomesReady(fromServer().get()); + waitUntilDeploymentConfigPodBecomesReady(get()); URL url = getResourceLogUrl(true); final LogWatchCallback callback = new LogWatchCallback(out, this.context.getExecutor()); return callback.callAndWait(this.httpClient, url); diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/build/BuildOperationsImpl.java b/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/build/BuildOperationsImpl.java index af0be9b3e5c..0849334f40a 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/build/BuildOperationsImpl.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/build/BuildOperationsImpl.java @@ -163,7 +163,7 @@ public LogWatch watchLog() { public LogWatch watchLog(OutputStream out) { try { // In case of Build we directly get logs at Build Url, but we need to wait for Pods - waitUntilBuildPodBecomesReady(fromServer().get()); + waitUntilBuildPodBecomesReady(get()); URL url = new URL(URLUtils.join(getResourceUrl().toString(), getLogParameters() + "&follow=true")); final LogWatchCallback callback = new LogWatchCallback(out, this.context.getExecutor()); return callback.callAndWait(this.httpClient, url); diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/core/TemplateOperationsImpl.java b/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/core/TemplateOperationsImpl.java index 9830a76f651..ab20127d404 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/core/TemplateOperationsImpl.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/core/TemplateOperationsImpl.java @@ -165,11 +165,11 @@ public TemplateOperationsImpl withParameters(Map parameters) { @Override public KubernetesList processLocally(Map valuesMap) { - Template t = withParameters(valuesMap).get(); + Template t = withParameters(valuesMap).getItemOrRequireFromServer(); - List parameters = t != null ? t.getParameters() : null; + List parameters = t.getParameters(); KubernetesList list = new KubernetesListBuilder() - .withItems(t != null && t.getObjects() != null ? t.getObjects() : Collections. emptyList()) + .withItems(t.getObjects()) .build(); try { diff --git a/platforms/karaf/itests/src/test/java/io/fabric8/kubernetes/karaf/itests/KubernetesDeserializerTest.java b/platforms/karaf/itests/src/test/java/io/fabric8/kubernetes/karaf/itests/KubernetesDeserializerTest.java index 4649d263053..3849eb7467c 100644 --- a/platforms/karaf/itests/src/test/java/io/fabric8/kubernetes/karaf/itests/KubernetesDeserializerTest.java +++ b/platforms/karaf/itests/src/test/java/io/fabric8/kubernetes/karaf/itests/KubernetesDeserializerTest.java @@ -52,7 +52,7 @@ public class KubernetesDeserializerTest extends TestBase { public void canDeserializeModelsFromDifferentKubernetesModules() { // When final List result = kubernetesClient.load( - KubernetesDeserializerTest.class.getResourceAsStream("/deserializer_test.yaml")).get(); + KubernetesDeserializerTest.class.getResourceAsStream("/deserializer_test.yaml")).items(); // Then assertEquals(22, result.size()); assertResourceTypes(result); @@ -62,7 +62,7 @@ public void canDeserializeModelsFromDifferentKubernetesModules() { public void canDeserializeModelsFromDifferentOpenShiftModules() { // When final List result = openShiftClient.load( - KubernetesDeserializerTest.class.getResourceAsStream("/deserializer_openshift_test.yaml")).get(); + KubernetesDeserializerTest.class.getResourceAsStream("/deserializer_openshift_test.yaml")).items(); // Then assertEquals(8, result.size()); assertResourceTypes(result);