Skip to content

Commit

Permalink
fix (kubernetes-client) : reintroduce Replaceable interface in NonNam…
Browse files Browse the repository at this point in the history
…espaceOperation

This was introduced by mistake in Dry Run implementation as part of
WritableOperation and was subsequently removed in
fabric8io#3798

But it makes sense for replace operation to work without name. It can be
inferred from the passed object.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>

(cherry picked from commit ea07b7f)
Signed-off-by: Marc Nuri <marc@marcnuri.com>
  • Loading branch information
rohanKanojia authored and manusa committed Apr 5, 2022
1 parent eed1a91 commit 4e700a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void replaceStatusSubresource() {
// use the original pet, no need to pick up the resourceVersion
pet.getSpec().setType("shouldn't change");
pet.setStatus(petStatusToUpdate);
Pet updatedPet = petClient.inNamespace(currentNamespace).withName(pet.getMetadata().getName()).replaceStatus(pet);
Pet updatedPet = petClient.inNamespace(currentNamespace).replaceStatus(pet);

// Then
assertPet(updatedPet, "pet-replacestatus", "Pigeon", "Sleeping");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void testStatusSubresourceHandling() {

cronTab.getMetadata().setLabels(labels);

result = cronTabClient.withName(cronTab.getMetadata().getName()).replace(cronTab);
result = cronTabClient.replace(cronTab);

String originalUid = result.getMetadata().getUid();

Expand All @@ -187,7 +187,7 @@ void testStatusSubresourceHandling() {
labels.put("other", "label");
cronTab.setStatus(null);

result = cronTabClient.withName(cronTab.getMetadata().getName()).replace(cronTab);
result = cronTabClient.replace(cronTab);

// should retain the existing
assertNotNull(result.getStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void testStatusReplace() throws InterruptedException {
server.expect().put().withPath("/apis/example.crd.com/v1alpha1/stars/sun/status").andReturn(200, "{\"apiVersion\":\"example.crd.com/v1alpha1\",\"kind\":\"Star\",\"metadata\":{\"name\":\"sun\",\"resourceVersion\":\"2\"},\"spec\":{\"type\":\"G\",\"location\":\"Galaxy\"},\"status\":{\"location\":\"M\"}}").once();
starClient = client.customResources(Star.class);

Star replaced = starClient.inNamespace("test").withName(updatedStar.getMetadata().getName()).replaceStatus(updatedStar);
Star replaced = starClient.inNamespace("test").replaceStatus(updatedStar);
assertEquals("2", replaced.getMetadata().getResourceVersion());
RecordedRequest recordedRequest = server.getLastRequest();
// get of the latest version, put of status
Expand Down

0 comments on commit 4e700a2

Please sign in to comment.