Support CROSSPLANE_DIFF_DOCKER_NETWORK env var for container networking#255
Support CROSSPLANE_DIFF_DOCKER_NETWORK env var for container networking#255jtucci wants to merge 1 commit intocrossplane-contrib:mainfrom
Conversation
b733a4a to
8407101
Compare
|
@jcogilvie could you please review this? |
|
Thanks for the submission. Once upstream cuts a new version that includes the linked PR, I'll be able to bump our version and then review your change. |
When crossplane-diff runs inside a Docker container (e.g. a GitHub
Actions container job), function containers created via the Docker
socket land on a different Docker network and are unreachable.
This adds support for the CROSSPLANE_DIFF_DOCKER_NETWORK environment
variable. When set, the value is applied as the
render.crossplane.io/runtime-docker-network annotation on all function
resources before they are passed to render.Render(). This tells the
Crossplane render runtime to connect function containers to the
specified Docker network, making them reachable from the caller.
Usage in a GitHub Actions workflow:
env:
CROSSPLANE_DIFF_DOCKER_NETWORK: ${{ job.container.network }}
Depends on: crossplane/crossplane#7216
Signed-off-by: Jon Tucci <jonytucci01@gmail.com>
8407101 to
ea91a74
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for running crossplane-diff inside Docker container environments (e.g., GitHub Actions container jobs) by propagating a Docker network selection into the Crossplane render runtime via Function annotations.
Changes:
- Introduces
CROSSPLANE_DIFF_DOCKER_NETWORKenv var support and appliesrender.crossplane.io/runtime-docker-networkto Functions prior to rendering. - Applies the annotation for both
DefaultFunctionProvider(xr) andCachedFunctionProvider(comp) via a shared helper. - Adds unit tests for the annotation-application helper.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/diff/diffprocessor/function_provider.go | Adds env var + helper to annotate Functions and wires it into both function providers. |
| cmd/diff/diffprocessor/function_provider_test.go | Adds unit tests covering env-set/unset and existing annotations behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Cache for future calls | ||
| p.cache[compName] = fns | ||
|
|
||
| applyDockerNetworkAnnotation(fns, p.logger) | ||
|
|
||
| return fns, nil |
| if tt.envValue != "" { | ||
| t.Setenv(EnvDockerNetwork, tt.envValue) | ||
| } else { | ||
| os.Unsetenv(EnvDockerNetwork) | ||
| } |
|
It looks like this upstream fix hasn't been released on the 2.2 branch, and it isn't in 2.3.0-rc.0. So I'm still waiting on upstream for this. |
Description of your changes
When
crossplane-diffruns inside a Docker container (e.g. a GitHub Actions container job), function containers created via the Docker socket land on the default bridge network, which is isolated from the job container's network. This makes function containers unreachable, causing all compositions to fail with connection errors.This adds support for the
CROSSPLANE_DIFF_DOCKER_NETWORKenvironment variable. When set, the value is applied as therender.crossplane.io/runtime-docker-networkannotation on all Function resources before they are passed torender.Render(). This tells the Crossplane render runtime to connect function containers to the specified Docker network.The annotation is applied in both
DefaultFunctionProvider(used by thexrcommand) andCachedFunctionProvider(used by thecompcommand) via a shared helper function.Depends on crossplane/crossplane#7216 — that upstream PR must be merged first, and then the
go.moddependency in this repo needs to be bumped to pick up the new annotation support.Fixes #254
I have:
earthly -P +reviewableto ensure this PR is ready for review.Added or updated e2e tests.Documented this change as needed.Followed the API promotion workflow if this PR introduces, removes, or promotes an API.