Skip to content

Commit

Permalink
[apply] add support for fieldValidation value (defaulting to Strict)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmannibucau committed Aug 25, 2023
1 parent 4f55678 commit c1fd8a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<lowercased resource kind>s = /apis/....`.")
@ConfigProperty(name = "bundlebee.kube.resourceMapping", defaultValue = "")
Expand Down Expand Up @@ -412,7 +417,7 @@ private CompletionStage<HttpResponse<String>> 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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c1fd8a0

Please # to comment.