admission-control
Use when the user asks to "write a validator", "add validation", "implement admission control", "write a mutating webhook", "add a mutation handler", "validate incoming resources", "implement admission logic", "add admission webhooks", "write ingress validation", or asks how to validate or mutate resources before they are persisted in a grafana-app-sdk app. Provides guidance on implementing validation and mutation admission handlers for grafana-app-sdk apps.
Security Assessment
About admission-control
admission-control is a developer-guidance skill for implementing validation and mutation admission handlers in grafana-app-sdk apps. It solves the problem of intercepting resource create/update requests before they are persisted — to accept or reject them (validation) or to modify them, such as setting defaults or normalizing fields (mutation) — within the grafana-app-sdk framework. It explains that the admission business logic is identical whether the app runs as a standalone operator (which stands up its own webhook server) or inside grafana/apps (where admission is auto-registered as an in-process Kubernetes plugin).
The skill walks through generating an App stub (grafana-app-sdk project component add operator), implementing the Validator interface (returning nil to admit or an error to reject, with access to the incoming object, old object, and operation type, and the option to use k8s.NewAdmissionError for controlled error responses), and implementing the Mutator interface (returning a MutatingResponse with the optionally modified object, and the guidance that rejection belongs in validators, not mutators). It provides Go example handlers, shows how to register validators and mutators in pkg/app/app.go via simple.NewApp and ManagedKinds, and notes that mutation and validation must also be enabled in the kind's CUE definition. It documents the AdmissionRequest fields (Object, OldObject, Action, UserInfo, Kind, Group, Version) and common validation patterns — immutability checks, cross-field validation, and referential validation — plus a reference file on admission patterns and error-message conventions.
It targets Go developers building grafana-app-sdk applications who need to enforce resource invariants or apply defaults at admission time. Use cases include writing a validator for a custom kind, adding a mutating webhook to set defaults, enforcing field immutability, and validating cross-field or referential constraints before persistence.
FAQ
What is the difference between validation and mutation here?
Validation accepts or rejects a create/update request but cannot change the resource; mutation modifies the resource before persistence (for example setting defaults or normalizing fields). Best practice is to reject requests in validators, not mutators.
Does the code differ between standalone and grafana/apps deployments?
No. The handler code is identical. The only difference is the runtime: standalone operators stand up their own webhook server, while grafana/apps auto-registers admission as an in-process Kubernetes plugin.
How do I register admission handlers?
Register validators and mutators when building the app in pkg/app/app.go via simple.NewApp with ManagedKinds entries that set Validator and Mutator per kind; mutation and validation must also be enabled in the kind's CUE definition.
What information is available in an admission request?
AdmissionRequest exposes Object (incoming resource), OldObject (previous state on updates), Action (create/update/delete/connect), UserInfo, and the Kind, Group, and Version fields.
What common validation patterns are covered?
Immutability checks (field cannot change after creation), cross-field validation (for example startTime must be before endTime), and referential validation (checking a referenced resource exists).
Install admission-control
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
grafana/skills