From c1fd8a0bbb06ad6b1839dbdb764b4d288aa3801d Mon Sep 17 00:00:00 2001 From: Romain Manni-Bucau Date: Fri, 25 Aug 2023 18:46:44 +0400 Subject: [PATCH] [apply] add support for fieldValidation value (defaulting to Strict) --- .../java/io/yupiik/bundlebee/core/kube/KubeClient.java | 7 ++++++- ...io.yupiik.bundlebee.core.kube.KubeClientTest_apply.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bundlebee-core/src/main/java/io/yupiik/bundlebee/core/kube/KubeClient.java b/bundlebee-core/src/main/java/io/yupiik/bundlebee/core/kube/KubeClient.java index 67aba958..bc83ed02 100644 --- a/bundlebee-core/src/main/java/io/yupiik/bundlebee/core/kube/KubeClient.java +++ b/bundlebee-core/src/main/java/io/yupiik/bundlebee/core/kube/KubeClient.java @@ -97,6 +97,11 @@ public class KubeClient implements ConfigHolder { @BundleBee private JsonBuilderFactory jsonBuilderFactory; + @Inject + @Description("`fieldValidation` - server side validation - value when applying a descriptor, values can be `Strict`, `Warn` pr `Ignore`. Note that using `skip` will ignore the query parameter.") + @ConfigProperty(name = "bundlebee.kube.fieldValidation", defaultValue = "Strict") + private String fieldValidation; + @Inject @Description("Enables to define resource mapping, syntax uses propeties one: `s = /apis/....`.") @ConfigProperty(name = "bundlebee.kube.resourceMapping", defaultValue = "") @@ -412,7 +417,7 @@ private CompletionStage> doApply(final JsonObject rawDesc, log.info(() -> "Applying '" + name + "' (kind=" + kindLowerCased + ")" + (!"namespaces".equals(kindLowerCased) ? " for namespace '" + namespace + "'" : "")); - final var fieldManager = "?fieldManager=kubectl-client-side-apply" + (!api.isDryRun() ? "" : ("&dryRun=All")); + final var fieldManager = "?fieldManager=kubectl-client-side-apply" + (!api.isDryRun() ? "" : ("&dryRun=All")) + ("skip".equals(fieldValidation) ? "" : ("&fieldValidation=" + fieldValidation)); final var baseUri = toBaseUri(preparedDesc, kindLowerCased, namespace); if (api.isVerbose()) { diff --git a/bundlebee-core/src/test/resources/mock/http/io.yupiik.bundlebee.core.kube.KubeClientTest_apply.json b/bundlebee-core/src/test/resources/mock/http/io.yupiik.bundlebee.core.kube.KubeClientTest_apply.json index 30987189..e3cbeca2 100644 --- a/bundlebee-core/src/test/resources/mock/http/io.yupiik.bundlebee.core.kube.KubeClientTest_apply.json +++ b/bundlebee-core/src/test/resources/mock/http/io.yupiik.bundlebee.core.kube.KubeClientTest_apply.json @@ -12,7 +12,7 @@ { "request": { "method": "POST", - "uri": "https://kubernetes.bundlebee.yupiik.test/api/v1/namespaces/default/configmaps?fieldManager=kubectl-client-side-apply" + "uri": "https://kubernetes.bundlebee.yupiik.test/api/v1/namespaces/default/configmaps?fieldManager=kubectl-client-side-apply&fieldValidation=Strict" }, "response": { "status": 201,