forked from fabric8io/kubernetes-client
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix fabric8io#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
bba93b2
commit 21bcbc4
Showing
11 changed files
with
611 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
68 changes: 68 additions & 0 deletions
68
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,68 @@ | ||
/** | ||
* 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 io.sundr.builder.annotations.Buildable; | ||
|
||
import java.util.List; | ||
|
||
@Buildable(editableEnabled = false, validationEnabled = false, generateBuilderPackage = false, lazyCollectionInitEnabled = false, builderPackage = "io.fabric8.kubernetes.api.builder") | ||
public class PatchContext { | ||
private List<String> dryRun; | ||
private String fieldManager; | ||
private Boolean force; | ||
private PatchType patchType; | ||
|
||
public PatchContext(List<String> dryRun, String fieldManager, Boolean force, PatchType patchType) { | ||
this.dryRun = dryRun; | ||
this.fieldManager = fieldManager; | ||
this.force = force; | ||
this.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; | ||
} | ||
|
||
} |
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.