use of io.kubernetes.client.util.generic.options.PatchOptions in project java by kubernetes-client.
the class KubectlApply method executeServerSideApply.
private ApiType executeServerSideApply() throws KubectlException {
refreshDiscovery();
GenericKubernetesApi<ApiType, KubernetesListObject> api = getGenericApi();
PatchOptions patchOptions = new PatchOptions();
patchOptions.setForce(this.forceConflict);
patchOptions.setFieldManager(this.fieldManager);
if (ModelMapper.isNamespaced(this.targetObj.getClass())) {
String targetNamespace = namespace != null ? namespace : Strings.isNullOrEmpty(targetObj.getMetadata().getNamespace()) ? Namespaces.NAMESPACE_DEFAULT : targetObj.getMetadata().getNamespace();
KubernetesApiResponse<KubernetesObject> response = null;
try {
return api.patch(targetNamespace, targetObj.getMetadata().getName(), V1Patch.PATCH_FORMAT_APPLY_YAML, new V1Patch(apiClient.getJSON().serialize(targetObj)), patchOptions).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
} else {
try {
return api.patch(targetObj.getMetadata().getName(), V1Patch.PATCH_FORMAT_APPLY_YAML, new V1Patch(apiClient.getJSON().serialize(targetObj)), patchOptions).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
}
}
use of io.kubernetes.client.util.generic.options.PatchOptions in project java by kubernetes-client.
the class PatchHelper method dryRunStrategyMergePatch.
public static <ApiType extends KubernetesObject, ApiListType extends KubernetesListObject> ApiType dryRunStrategyMergePatch(GenericKubernetesApi<ApiType, ApiListType> genericApi, String patch, String namespace, String name) throws ApiException {
PatchOptions options = new PatchOptions();
options.setDryRun("All");
return genericApi.patch(namespace, name, V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, new V1Patch(patch), options).throwsApiException().getObject();
}
Aggregations