Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Preserve labels and fields when using CRD's withResourceVersion() #1425

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Bugs

Improvements

* Fix #1425: Preserve labels and fields when using CRD's withResourceVersion()

Dependency Upgrade
* Upgrade Sundrio to 0.16.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,26 @@ protected BaseOperation(OkHttpClient client, Config config, String apiGroupName,
this.fields = fields;
}

protected BaseOperation(OkHttpClient client, Config config, String apiGroupName, String apiVersion, String resourceT, String namespace, String name, Boolean cascading, T item, String resourceVersion, Boolean reloadingFromServer, Class<T> type, Class<L> listType, Class<D> doneableType) {
super(client, config, apiGroup(item, apiGroupName), apiVersion(item, apiVersion), resourceT, namespace, name(item, name));
protected BaseOperation(OkHttpClient client, Config config, String apiGroup, String apiVersion, String resourceT, String namespace, String name, Boolean cascading, T item, String resourceVersion, Boolean reloadingFromServer, long gracePeriodSeconds, Map<String, String> labels, Map<String, String> labelsNot, Map<String, String[]> labelsIn, Map<String, String[]> labelsNotIn, Map<String, String> fields, Class<T> type, Class<L> listType, Class<D> doneableType) {
super(client, config, apiGroup, apiVersion(item, apiVersion), resourceT, namespace, name(item, name));
this.cascading = cascading;
this.item = item;
this.resourceVersion = resourceVersion;
this.reloadingFromServer = reloadingFromServer;
this.type = type;
this.listType = listType;
this.doneableType = doneableType;
this.reaper = null;
this.gracePeriodSeconds = gracePeriodSeconds;
this.labels = labels;
this.labelsNot = labelsNot;
this.labelsIn = labelsIn;
this.labelsNotIn = labelsNotIn;
this.fields = fields;
}

protected BaseOperation(OkHttpClient client, Config config, String apiGroup, String apiVersion, String resourceT, String namespace, String name, Boolean cascading, T item, String resourceVersion, Boolean reloadingFromServer, Class<T> type, Class<L> listType, Class<D> doneableType) {
super(client, config, apiGroup, apiVersion(item, apiVersion), resourceT, namespace, name(item, name));
this.cascading = cascading;
this.item = item;
this.resourceVersion = resourceVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ protected HasMetadataOperation(OkHttpClient client, Config config, String apiGro
super(client, config, apiGroup, apiVersion, resourceT, namespace, name, cascading, item, resourceVersion, reloadingFromServer, gracePeriodSeconds, labels, labelsNot, labelsIn, labelsNotIn, fields);
}

protected HasMetadataOperation(OkHttpClient client, Config config, String apiGroup, String apiVersion, String resourceT, String namespace, String name, Boolean cascading, T item, String resourceVersion, Boolean reloadingFromServer, long gracePeriodSeconds, Map<String, String> labels, Map<String, String> labelsNot, Map<String, String[]> labelsIn, Map<String, String[]> labelsNotIn, Map<String, String> fields, Class<T> type, Class<L> listType, Class<D> doneableType) {
super(client, config, apiGroup, apiVersion, resourceT, namespace, name, cascading, item, resourceVersion, reloadingFromServer, gracePeriodSeconds, labels, labelsNot, labelsIn, labelsNotIn, fields, type, listType, doneableType);
}

public HasMetadataOperation(OkHttpClient client, Config config, String apiGroup, String apiVersion, String resourceT, String namespace, String name, Boolean cascading, T item, String resourceVersion, Boolean reloadingFromServer, Class<T> type, Class<L> listType, Class<D> doneableType) {
super(client, config, apiGroup, apiVersion, resourceT, namespace, name, cascading, item, resourceVersion, reloadingFromServer, type, listType, doneableType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

/**
*/
Expand All @@ -59,6 +60,17 @@ public CustomResourceOperationsImpl(OkHttpClient client, Config config, String a
}
}

protected CustomResourceOperationsImpl(OkHttpClient client, Config config, String apiGroup, String apiVersion, String resourceT, boolean resouceNamespaced, String namespace, String name, Boolean cascading, T item, String resourceVersion, Boolean reloadingFromServer, long gracePeriodSeconds, Map<String, String> labels, Map<String, String> labelsNot, Map<String, String[]> labelsIn, Map<String, String[]> labelsNotIn, Map<String, String> fields, Class<T> type, Class<L> listType, Class<D> doneableType) {
super(client, config, apiGroup, apiVersion, resourceT, namespace, name, cascading, item, resourceVersion, reloadingFromServer, gracePeriodSeconds, labels, labelsNot, labelsIn, labelsNotIn, fields, type, listType, doneableType);
this.resourceNamespaced = resouceNamespaced;
this.apiVersion = getAPIGroup() + "/" + getAPIVersion();

KubernetesDeserializer.registerCustomKind(type.getSimpleName(), type);
if (KubernetesResource.class.isAssignableFrom(listType)) {
KubernetesDeserializer.registerCustomKind(listType.getSimpleName(), (Class<? extends KubernetesResource>) listType);
}
}

protected static String apiGroup(CustomResourceDefinition crd) {
return crd.getSpec().getGroup();
}
Expand Down Expand Up @@ -124,7 +136,7 @@ public Gettable<T> fromServer() {

@Override
public Watchable<Watch, Watcher<T>> withResourceVersion(String resourceVersion) {
return new CustomResourceOperationsImpl<>(client, getConfig(), getAPIGroup(), getAPIVersion(), getResourceT(), resourceNamespaced, getNamespace(), getName(), isCascading(), getItem(), resourceVersion, isReloadingFromServer(), getType(), getListType(), getDoneableType());
return new CustomResourceOperationsImpl<>(client, getConfig(), getAPIGroup(), getAPIVersion(), getResourceT(), resourceNamespaced, getNamespace(), getName(), isCascading(), getItem(), resourceVersion, isReloadingFromServer(), getGracePeriodSeconds(), getLabels(), getLabelsNot(), getLabelsIn(), getLabelsNotIn(), getFields(), getType(), getListType(), getDoneableType());
}

@Override
Expand Down