App Deployments (4a/N): shared compose parser + admin validation#218
Merged
Conversation
Increment 4a of the App Deployments epic. Extract the app 'compose-ish'
YAML parser into a small shared crate so the API validates it with the
exact same code the operator will use to render Kubernetes objects.
- New lnvps_compose crate (serde + serde_yaml, no heavy deps): typed model
(Compose/Service/Port/Volume/SecretDecl/ConfigField/Backup), parse +
validate, referenced_vars, and resolve_env (${...} substitution across
services, errors on unknown refs).
- Validation enforced at parse: at least one service, image required,
expose: ingress only on http ports, absolute non-traversal volume mount
paths, depends_on must reference real services, backup is exactly one of
command|volume (volume must be declared).
- lnvps_api_admin now parses compose via lnvps_compose::Compose::parse on
app create/update, rejecting invalid/unsafe compose with a clear 400
(was: non-empty check only).
- 9 unit tests in the crate (route96+mariadb multi-service, defaults,
var extraction, cross-service resolution, all rejection paths) + admin
validator test updated.
Operator reconcile (compose -> k8s objects) is increment 4b.
Part of work/app-deployments.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Increment 4a of the managed App Deployments epic (see
work/app-deployments.md). Extracts the app compose-ish YAML parser into a small shared crate so the API validates a compose with the exact same code the operator will use to render Kubernetes objects — no drift between what admins can save and what the operator can deploy.New crate:
lnvps_composeMinimal deps (serde + serde_yaml + anyhow) so it's cheap for both the API and the operator binary to pull in.
Compose(services/secrets/config, plain top-level keys, nox-*),Service,Port(expose/protocol),Volume,SecretDecl(generate),ConfigField,Backup.parse+validate,referenced_vars, andresolve_env(${…}substitution across services — generated secrets, config values,${HOSTNAME}, service refs — erroring on unknown references).Validation enforced at parse time
imagerequired.expose: ingressonly onprotocol: httpports (WS rides HTTP → wss)...(directory-traversal guard).depends_onmust reference real services.backupis exactly one ofcommand|volume(andvolumemust be declared).Shared with the API
lnvps_api_adminnow runslnvps_compose::Compose::parseonPOST/PATCH /api/admin/v1/apps, so invalid/unsafe compose is rejected with a clear400at catalog-edit time (previously only a non-empty check).Tests / docs
Next
4b) operator reconcile:
lnvps_compose→ Namespace + Deployment/StatefulSet + Service + Ingress + PVC + generated Secret + NetworkPolicy + ResourceQuota, status write-back, teardown; filtered by the operator'scluster_id.