Skip to content

feat(diffprocessor): add --function-registry-override flag to override function image registry#314

Merged
jcogilvie merged 4 commits into
crossplane-contrib:mainfrom
cahillsf:stephen.cahill/CLOUDR-1645-introduce-registry-override
May 5, 2026
Merged

feat(diffprocessor): add --function-registry-override flag to override function image registry#314
jcogilvie merged 4 commits into
crossplane-contrib:mainfrom
cahillsf:stephen.cahill/CLOUDR-1645-introduce-registry-override

Conversation

@cahillsf
Copy link
Copy Markdown
Contributor

@cahillsf cahillsf commented May 5, 2026

Description of your changes

Adds a --function-registry-override CLI flag that rewrites the registry portion of every function package reference at diff time, via a new RegistryOverrideFunctionProvider that wraps the default FunctionProvider. The path, tag, and/or digest in each ref are preserved — only the registry hostname is replaced. Useful in air-gapped environments, behind corporate proxies, or when pulling function images from a registry mirror.

The override applies to both standard tag refs (registry/path:tag) and digest refs (registry/path@sha256:...). Refs without a / are left untouched. The flag only affects how crossplane-diff pulls images locally — it does not modify Function resources or anything in the cluster.

Example: --function-registry-override my-company.registry.io rewrites
xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.11.0 to
my-company.registry.io/crossplane-contrib/function-go-templating:v0.11.0.

Fixes #

I have:

  • Read and followed Crossplane's contribution process.
  • Run earthly -P +reviewable to ensure this PR is ready for review.
  • Added or updated unit tests.
  • Added or updated e2e tests.
  • Documented this change as needed.
  • Followed the API promotion workflow if this PR introduces, removes, or promotes an API.

@cahillsf cahillsf force-pushed the stephen.cahill/CLOUDR-1645-introduce-registry-override branch from ecbe34e to b0700d5 Compare May 5, 2026 18:16
@cahillsf cahillsf marked this pull request as ready for review May 5, 2026 18:18
Copilot AI review requested due to automatic review settings May 5, 2026 18:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a CLI flag to override the registry host used when pulling Crossplane function images during diff processing, intended to support registry mirrors / air-gapped environments without mutating in-cluster Function resources.

Changes:

  • Added --function-registry-override flag and threaded it from CLI parsing into diff processor configuration.
  • Wrapped the existing FunctionProvider with a RegistryOverrideFunctionProvider that rewrites function package refs before use.
  • Added unit tests for the registry rewrite helper and provider wrapper; updated README flag documentation for xr and comp.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Documents the new --function-registry-override flag for xr and comp.
cmd/diff/main.go Adds the new CLI flag to shared command fields.
cmd/diff/cmd_utils.go Plumbs the CLI flag into diffprocessor options.
cmd/diff/diffprocessor/processor_config.go Adds config field + option constructor for the override.
cmd/diff/diffprocessor/diff_processor.go Wraps the FunctionProvider when an override is configured.
cmd/diff/diffprocessor/function_provider.go Implements the provider wrapper and replaceRegistry helper.
cmd/diff/diffprocessor/function_provider_test.go Adds tests for replaceRegistry and the wrapper provider.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/diff/diffprocessor/function_provider.go Outdated
Comment thread cmd/diff/diffprocessor/function_provider_test.go
cahillsf added 4 commits May 5, 2026 14:36
…n image registry

Introduces a CLI flag that rewrites the registry portion of every function
package ref before functions are pulled, via a RegistryOverrideFunctionProvider
that wraps the default provider.

Refs: CLOUDR-1645

Signed-off-by: Stephen Cahill <stephen.cahill@datadoghq.com>
- Drop redundant explicit type from functionProvider declaration; use a
  type conversion at the call site to keep the variable typed as the
  FunctionProvider interface.
- Add doc comments on RegistryOverrideFunctionProvider.GetFunctionsForComposition
  and .Cleanup.

Signed-off-by: Stephen Cahill <stephen.cahill@datadoghq.com>
…rride

The flag always rewrites the registry portion of every function package
ref; "override" reads more accurately than the flag setting "the"
function registry, and aligns with the existing
RegistryOverrideFunctionProvider type name.

Renames:
- --function-registry           -> --function-registry-override
- CommonCmdFields.FunctionRegistry -> .FunctionRegistryOverride
- ProcessorConfig.FunctionRegistry -> .FunctionRegistryOverride
- WithFunctionRegistry             -> WithFunctionRegistryOverride

Refs: CLOUDR-1645

Signed-off-by: Stephen Cahill <stephen.cahill@datadoghq.com>
Adds the new flag to the xr and comp flag tables and a "Function Registry
Override" section parallel to the existing "Function Credentials" section,
covering when to use the flag and how it rewrites package refs.

Refs: CLOUDR-1645

Signed-off-by: Stephen Cahill <stephen.cahill@datadoghq.com>
@cahillsf cahillsf force-pushed the stephen.cahill/CLOUDR-1645-introduce-registry-override branch from b0700d5 to d265494 Compare May 5, 2026 18:37
@jcogilvie
Copy link
Copy Markdown
Collaborator

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@jcogilvie jcogilvie enabled auto-merge (squash) May 5, 2026 20:26
@jcogilvie jcogilvie merged commit d5a07eb into crossplane-contrib:main May 5, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants