Skip to content

Add --policy-overlay flag to merge things into the main --policy#3260

Draft
simonbaird wants to merge 2 commits intoconforma:mainfrom
simonbaird:policy-overlay-merge
Draft

Add --policy-overlay flag to merge things into the main --policy#3260
simonbaird wants to merge 2 commits intoconforma:mainfrom
simonbaird:policy-overlay-merge

Conversation

@simonbaird
Copy link
Copy Markdown
Member

I'm not sure if this is a good idea, just created a POC to see if we like it.

One challenge, the overlays are almost guaranteed to not be valid ECPs, so to have them available in the cluster we might need to create a new CRD called ConformaPolicyOverlay for example.

An alternative design that might work better than this: extend ECP so allows specifying a "base" config, and changes that should be applied to it.

simonbaird and others added 2 commits April 22, 2026 15:15
Introduces support for layering EnterpriseContractPolicy configurations
using overlay files, similar to CSS or Kustomize. This allows teams to
maintain a standard base policy and apply team-specific customizations
on top.

Key changes:
- Add MergePolicyConfigs() function with deep merge semantics:
  - Maps: deeply merged (overlay keys override base)
  - Arrays: concatenated (base + overlay items)
  - Scalars: last-wins (overlay replaces base)

- Add --policy-overlay flag to ec validate image:
  - Can be specified multiple times
  - Overlays applied in order
  - Backward compatible (no overlay = existing behavior)
  - Supports same formats as --policy (files, git, inline JSON/YAML)

- Include example files demonstrating usage:
  - Standard base policy
  - Team-specific overlay (excludes, ruleData)
  - Hotfix overlay (temporary overrides)
  - README with usage examples

Benefits:
- DRY: update standard policy once, all teams benefit
- Team autonomy: customize without forking
- Debuggability: see effective merged configuration

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds a new `ec inspect ecp` command to display the effective
EnterpriseContractPolicy configuration after merging overlays.
This provides visibility into what policy will actually be
evaluated during validation.

Usage:
  # Inspect base policy
  ec inspect ecp --policy standard.yaml

  # Inspect merged result
  ec inspect ecp --policy standard.yaml --policy-overlay team.yaml

  # Multiple overlays
  ec inspect ecp --policy standard.yaml \
    --policy-overlay team.yaml \
    --policy-overlay hotfix.yaml

The command outputs the final merged YAML configuration to stdout,
making it easy to understand and debug policy composition.

Includes comprehensive acceptance tests covering:
- Single policy inspection
- Single and multiple overlay merges
- Array concatenation behavior
- Map override semantics
- Deep nested structure merging

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 81649399-b571-4f85-a8a8-8f68e6feb2ce

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant