Skip to content

Commit

Permalink
Fixed compiler error and formatting.
Browse files Browse the repository at this point in the history
Signed-off-by: Alicrow <writerofalicrow@gmail.com>
  • Loading branch information
Alibirb committed Jul 7, 2022
1 parent 0628d38 commit 31aad12
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions examples/admission_controller.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use kube::core::{
admission::{AdmissionRequest, AdmissionResponse, AdmissionReview},
DynamicObject, ResourceExt,
DynamicObject, Resource, ResourceExt,
};
use std::{convert::Infallible, error::Error};
use tracing::*;
Expand Down Expand Up @@ -74,20 +74,16 @@ fn mutate(res: AdmissionResponse, obj: &DynamicObject) -> Result<AdmissionRespon

// Ensure labels exist before adding a key to it
if obj.meta().labels.is_none() {
patches.push(
json_patch::PatchOperation::Add(json_patch::AddOperation {
path: "/metadata/labels".into(),
value: serde_json::json!({}),
}),
);
patches.push(json_patch::PatchOperation::Add(json_patch::AddOperation {
path: "/metadata/labels".into(),
value: serde_json::json!({}),
}));
}
// Add our label
patches.push(
json_patch::PatchOperation::Add(json_patch::AddOperation {
path: "/metadata/labels/admission".into(),
value: serde_json::Value::String("modified-by-admission-controller".into()),
}),
);
patches.push(json_patch::PatchOperation::Add(json_patch::AddOperation {
path: "/metadata/labels/admission".into(),
value: serde_json::Value::String("modified-by-admission-controller".into()),
}));
Ok(res.with_patch(json_patch::Patch(patches))?)
} else {
Ok(res)
Expand Down

0 comments on commit 31aad12

Please sign in to comment.