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

using a strategic merge to prevent a 422 #3148

Merged
merged 2 commits into from
May 26, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class PatchContext {
private String fieldManager;
private Boolean force;
private PatchType patchType;

public static PatchContext of(PatchType type) {
return new PatchContext.Builder().withPatchType(type).build();
}

public List<String> getDryRun() {
return dryRun;
Expand Down
19 changes: 14 additions & 5 deletions kubernetes-itests/src/test/java/io/fabric8/kubernetes/WatchIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@

import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.PodBuilder;
import io.fabric8.kubernetes.client.*;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
import io.fabric8.kubernetes.client.dsl.base.PatchContext;
import io.fabric8.kubernetes.client.dsl.base.PatchType;
import org.arquillian.cube.kubernetes.api.Session;
import org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes;
import org.arquillian.cube.requirement.ArquillianConditionalRunner;
Expand Down Expand Up @@ -82,10 +87,14 @@ public void onClose() {
}
});

client.pods().inNamespace(currentNamespace).withName("sample-watch-pod").edit(p -> new PodBuilder(p)
.editMetadata().addToLabels("foo", "bar")
.endMetadata()
.build());
client.pods()
.inNamespace(currentNamespace)
.withName("sample-watch-pod")
.patch(PatchContext.of(PatchType.STRATEGIC_MERGE), new PodBuilder()
.withNewMetadata()
.addToLabels("foo", "bar")
.endMetadata()
.build());

assertTrue(eventLatch.await(10, TimeUnit.SECONDS));
watch.close();
Expand Down