From ab8ddcfc6b37f7bb61a7aef281cb1e5a3182c064 Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Fri, 15 Mar 2019 15:02:22 +0200 Subject: [PATCH] fix: Misc fixes. --- .../kubernetes/client/dsl/base/BaseOperation.java | 2 +- .../kubernetes/client/dsl/base/OperationContext.java | 3 +-- .../dsl/internal/CustomResourceOperationContext.java | 12 ------------ .../client/dsl/internal/OpenShiftOperation.java | 6 ++++-- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java index cfd3e68f09a..2c81354c19f 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/BaseOperation.java @@ -318,7 +318,7 @@ public T create(T... resources) throws KubernetesClientException { if (resources.length > 1) { throw new IllegalArgumentException("Too many items to create."); } else if (resources.length == 1) { - return handleCreate(resources[0]); + return withItem(resources[0]).create(); } else if (getItem() == null) { throw new IllegalArgumentException("Nothing to create."); } else { diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationContext.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationContext.java index 83086427306..6557b5d55d9 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationContext.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationContext.java @@ -15,7 +15,6 @@ */ package io.fabric8.kubernetes.client.dsl.base; -import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.client.Config; import io.fabric8.kubernetes.client.utils.ApiVersionUtil; import io.fabric8.kubernetes.client.utils.Utils; @@ -68,7 +67,7 @@ public OperationContext(OkHttpClient client, Config config, String plural, Strin this.reloadingFromServer = reloadingFromServer; this.gracePeriodSeconds = gracePeriodSeconds; this.item = item; - this.apiGroupName = Utils.isNullOrEmpty(apiGroupName) ? ApiVersionUtil.apiGroup(item, apiGroupName) : apiGroupName; + this.apiGroupName = ApiVersionUtil.apiGroup(item, apiGroupName); this.apiGroupVersion = ApiVersionUtil.apiVersion(item, apiGroupVersion); } diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/CustomResourceOperationContext.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/CustomResourceOperationContext.java index 31e863f00f2..b0c53dfa9f4 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/CustomResourceOperationContext.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/CustomResourceOperationContext.java @@ -125,18 +125,6 @@ public CustomResourceOperationContext withGracePeriodSeconds(long gracePeriodSec return new CustomResourceOperationContext(client, config, plural, namespace, name, apiGroupName, apiGroupVersion, cascading,item, labels, labelsNot, labelsIn, labelsNotIn, fields, resourceVersion, reloadingFromServer, gracePeriodSeconds, crd, type, listType, doneableType); } - public CustomResourceOperationContext withRolling(boolean rolling) { - return new CustomResourceOperationContext(client, config, plural, namespace, name, apiGroupName, apiGroupVersion, cascading,item, labels, labelsNot, labelsIn, labelsNotIn, fields, resourceVersion, reloadingFromServer, gracePeriodSeconds, crd, type, listType, doneableType); - } - - public CustomResourceOperationContext withRollingTimeout(long rollingTimeout) { - return new CustomResourceOperationContext(client, config, plural, namespace, name, apiGroupName, apiGroupVersion, cascading,item, labels, labelsNot, labelsIn, labelsNotIn, fields, resourceVersion, reloadingFromServer, gracePeriodSeconds, crd, type, listType, doneableType); - } - - public CustomResourceOperationContext withRollingTimeUnit(TimeUnit rollingTimeUnit) { - return new CustomResourceOperationContext(client, config, plural, namespace, name, apiGroupName, apiGroupVersion, cascading,item, labels, labelsNot, labelsIn, labelsNotIn, fields, resourceVersion, reloadingFromServer, gracePeriodSeconds, crd, type, listType, doneableType); - } - public CustomResourceOperationContext withCrd(Object crd) { return new CustomResourceOperationContext(client, config, plural, namespace, name, apiGroupName, apiGroupVersion, cascading,item, labels, labelsNot, labelsIn, labelsNotIn, fields, resourceVersion, reloadingFromServer, gracePeriodSeconds, crd, type, listType, doneableType); } diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/OpenShiftOperation.java b/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/OpenShiftOperation.java index 34fef1fe0c1..a2462a6d8cf 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/OpenShiftOperation.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/dsl/internal/OpenShiftOperation.java @@ -24,6 +24,7 @@ import io.fabric8.kubernetes.client.dsl.base.HasMetadataOperation; import io.fabric8.kubernetes.client.dsl.base.OperationContext; import io.fabric8.kubernetes.client.utils.URLUtils; +import io.fabric8.kubernetes.client.utils.Utils; import io.fabric8.openshift.client.DefaultOpenShiftClient; import io.fabric8.openshift.client.OpenShiftClient; import io.fabric8.openshift.client.OpenShiftConfig; @@ -42,12 +43,13 @@ public static OperationContext wrap(OperationContext context) { OpenShiftConfig config = OpenShiftConfig.wrap(context.getConfig()); String oapiVersion = config.getOapiVersion(); OpenShiftClient oc = new DefaultOpenShiftClient(context.getClient(), config); - if (config.isOpenShiftAPIGroups(oc)) { + if (Utils.isNotNullOrEmpty(context.getApiGroupName()) && config.isOpenShiftAPIGroups(oc)) { String apiGroupUrl = URLUtils.join(config.getMasterUrl(), "apis", context.getApiGroupName(), oapiVersion); String apiGroupVersion = URLUtils.join(context.getApiGroupName(), oapiVersion); return context.withConfig(new OpenShiftConfig(config, apiGroupUrl)).withApiGroupName(context.getApiGroupName()).withApiGroupVersion(apiGroupVersion); } else { - return context.withApiGroupVersion(oapiVersion); + String apiGroupUrl = URLUtils.join(config.getMasterUrl(), "oapi", oapiVersion); + return context.withConfig(new OpenShiftConfig(config, apiGroupUrl)).withApiGroupName(context.getApiGroupName()).withApiGroupVersion(oapiVersion); } }