-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #2701: Add Support for Merge Patch for Kubernetes resources
+ Allow option to configure PatchType in patch operation + Use MediaType in PatchType enum + Add merge-patch+json example
- Loading branch information
1 parent
c06d990
commit b54d41f
Showing
11 changed files
with
630 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.fabric8.kubernetes.client.dsl.base; | ||
|
||
import java.util.List; | ||
|
||
public class PatchContext { | ||
private List<String> dryRun; | ||
private String fieldManager; | ||
private Boolean force; | ||
private PatchType patchType; | ||
|
||
public List<String> getDryRun() { | ||
return dryRun; | ||
} | ||
|
||
public void setDryRun(List<String> dryRun) { | ||
this.dryRun = dryRun; | ||
} | ||
|
||
public String getFieldManager() { | ||
return fieldManager; | ||
} | ||
|
||
public void setFieldManager(String fieldManager) { | ||
this.fieldManager = fieldManager; | ||
} | ||
|
||
public Boolean getForce() { | ||
return force; | ||
} | ||
|
||
public void setForce(Boolean force) { | ||
this.force = force; | ||
} | ||
|
||
public PatchType getPatchType() { | ||
return patchType; | ||
} | ||
|
||
public void setPatchType(PatchType patchType) { | ||
this.patchType = patchType; | ||
} | ||
|
||
public static class Builder { | ||
private final PatchContext patchContext; | ||
|
||
public Builder() { | ||
this.patchContext = new PatchContext(); | ||
} | ||
|
||
public Builder withDryRun(List<String> dryRun) { | ||
this.patchContext.setDryRun(dryRun); | ||
return this; | ||
} | ||
|
||
public Builder withFieldManager(String fieldManager) { | ||
this.patchContext.setFieldManager(fieldManager); | ||
return this; | ||
} | ||
|
||
public Builder withForce(Boolean force) { | ||
this.patchContext.setForce(force); | ||
return this; | ||
} | ||
|
||
public Builder withPatchType(PatchType patchType) { | ||
this.patchContext.setPatchType(patchType); | ||
return this; | ||
} | ||
|
||
public PatchContext build() { | ||
return this.patchContext; | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/PatchType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.fabric8.kubernetes.client.dsl.base; | ||
|
||
import okhttp3.MediaType; | ||
|
||
import static io.fabric8.kubernetes.client.dsl.base.OperationSupport.JSON_PATCH; | ||
import static io.fabric8.kubernetes.client.dsl.base.OperationSupport.JSON_MERGE_PATCH; | ||
import static io.fabric8.kubernetes.client.dsl.base.OperationSupport.STRATEGIC_MERGE_JSON_PATCH; | ||
|
||
/** | ||
* Enum for different Patch types supported by Patch | ||
*/ | ||
public enum PatchType { | ||
JSON(JSON_PATCH), | ||
JSON_MERGE(JSON_MERGE_PATCH), | ||
STRATEGIC_MERGE(STRATEGIC_MERGE_JSON_PATCH); | ||
|
||
private final MediaType mediaType; | ||
|
||
PatchType(MediaType mediaType) { | ||
this.mediaType = mediaType; | ||
} | ||
|
||
public MediaType getMediaType() { | ||
return this.mediaType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.