Skip to content

Commit 5fddef9

Browse files
committed
atc: resource validation triggers on yoke label removal
1 parent ae088f0 commit 5fddef9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cmd/atc-installer/installer/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func Run(cfg Config) (flight.Stages, error) {
360360
MatchConditions: []admissionregistrationv1.MatchCondition{
361361
{
362362
Name: "yoke-labeled",
363-
Expression: fmt.Sprintf("%q in object.metadata.labels", internal.LabelYokeRelease),
363+
Expression: fmt.Sprintf("%q in object.metadata.labels || %q in oldObject.metadata.labels", internal.LabelYokeRelease, internal.LabelYokeRelease),
364364
},
365365
{
366366
Name: "not-atc-service-account",

cmd/atc/handler.go

+9
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ func Handler(client *k8s.Client, cache *wasm.ModuleCache, controllers *atc.Contr
252252
review.Response = &admissionv1.AdmissionResponse{
253253
UID: review.Request.UID,
254254
Allowed: true,
255+
Result: &metav1.Status{
256+
Status: metav1.StatusSuccess,
257+
Message: "validation passed",
258+
},
255259
}
256260

257261
var prev unstructured.Unstructured
@@ -279,6 +283,11 @@ func Handler(client *k8s.Client, cache *wasm.ModuleCache, controllers *atc.Contr
279283

280284
defer func() {
281285
review.Request = nil
286+
addRequestAttrs(r.Context(), slog.Group(
287+
"validation",
288+
"allowed", review.Response.Allowed,
289+
"details", review.Response.Result.Message,
290+
))
282291
json.NewEncoder(w).Encode(review)
283292
}()
284293

0 commit comments

Comments
 (0)