Skip to main content
← Back to list
01Issue
FeatureOpenSwamp CLI
AssigneesNone

Relationships

#1608 Support --grants-dir for loading grants from a directory

Opened by stack72 · 8/11/2026

Problem

swamp serve currently accepts a single --grants-file path for external grants. In Kubernetes deployments, teams often want to manage grants as separate files — one per team, environment, or concern — mounted from individual ConfigMaps into a shared directory. Today this requires concatenating all grants into a single file.

Proposed Solution

Add --grants-dir <path> (env: SWAMP_GRANTS_DIR) that loads all .yaml/.yml files from the given directory as grant sources.

How --grants-file and --grants-dir work together

  • Both may be specified — they are additive. Grants from --grants-file and all files in --grants-dir are merged into the same validEntries map that already supports multiple file sources (keyed by filename).
  • Neither is required — the server starts with only repo-level grant definitions if neither is passed.
  • Duplicates across files — a grant with the same subject/action/resource appearing in multiple files is not an error. Each file is reconciled independently (same as today's repo-level grant files vs the external file). If two files grant the same permission, both produce a grant-config model instance; revocation of one file's grants does not affect the other's.
  • Validation — each file in the directory is parsed and validated independently. A validation error in any file is fatal at startup (same as --grants-file today), with the error message identifying the specific file and entry.
  • Empty/missing directory — an empty directory is not an error (0 grants loaded). A missing directory path is a fatal startup error.
  • Non-YAML files ignored — files not ending in .yaml or .yml are silently skipped. This avoids issues with ConfigMap-mounted ..data symlinks and other Kubernetes projected volume artifacts.
  • Not recursive — only top-level files in the directory are loaded. Subdirectories are ignored.

Interaction with --grant-reload auto

When --grant-reload auto is set, changes to files in the grants directory should trigger a policy snapshot reload, the same way changes to repo-level grant definitions do today.

Example

# Kubernetes: mount multiple ConfigMaps into one directory
volumes:
  - name: grants
    projected:
      sources:
        - configMap:
            name: grants-engineering
        - configMap:
            name: grants-data-science
        - configMap:
            name: grants-platform

containers:
  - name: swamp
    command:
      - swamp
      - serve
      - --grants-dir
      - /etc/swamp/grants/
      - --grant-reload
      - auto
    volumeMounts:
      - name: grants
        mountPath: /etc/swamp/grants
        readOnly: true

Alternatives

  • Glob pattern (--grants-file '/etc/swamp/grants/*.yaml') — more flexible but harder to validate, and shell globbing behavior varies
  • Repeatable --grants-file — allows multiple files but requires listing each one explicitly, which doesn't work well with dynamic ConfigMap mounts
02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED

Open

8/11/2026, 8:00:35 PM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.