Skip to content

Add support for ephemeralContainers - #48

Merged
MPV merged 1 commit into
masterfrom
claude/ephemeral-containers-support-qybk3c
Jul 23, 2026
Merged

Add support for ephemeralContainers#48
MPV merged 1 commit into
masterfrom
claude/ephemeral-containers-support-qybk3c

Conversation

@MPV

@MPV MPV commented Jul 23, 2026

Copy link
Copy Markdown
Owner

What

Collects OCI images from a pod's ephemeralContainers in addition to containers and initContainers.

Why

kir previously ignored ephemeralContainers, so images injected via kubectl debug (or otherwise present in a manifest's ephemeral container list) were silently missing from the output. For a tool whose purpose is enumerating every image a pod would run — e.g. to feed a vulnerability scanner — that's a coverage gap.

How

GetContainersFromObject in k8s/k8s.go now walks podSpec.EphemeralContainers. Because EphemeralContainerCommon is a direct type definition of corev1.Container, each entry converts cleanly without copying fields:

for _, ec := range podSpec.EphemeralContainers {
    containers = append(containers, corev1.Container(ec.EphemeralContainerCommon))
}

Nothing else needed changing — EphemeralContainers already rides along on the PodSpec for every supported kind (Pod, Deployment, DaemonSet, ReplicaSet, StatefulSet, Job, CronJob), and everything downstream is generic over []corev1.Container.

Tests

  • k8s/k8s_test.go: new table case asserting an ephemeral container's image is collected alongside regular and init containers.
  • yamlparser/yamlparser_test.go: round-trip test that decodes a Pod manifest with ephemeralContainers from YAML and confirms all three image sources come through, exercising the deserializer path end-to-end.

go build ./... and go test ./... both pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_013YcWYpbf4mF49SYnbkf28b


Generated by Claude Code

@MPV
MPV force-pushed the claude/ephemeral-containers-support-qybk3c branch from c481737 to 934bc2c Compare July 23, 2026 06:38
Collect images from podSpec.EphemeralContainers alongside Containers
and InitContainers in GetContainersFromObject. EphemeralContainerCommon
is a direct type definition of Container, so each entry converts cleanly
without copying fields.

Add unit coverage in the k8s and yamlparser packages. For the end-to-end
approval layer, fold ephemeralContainers into the existing Pod fixture
(the only kind where they are valid, since they are injected into a live
Pod via the ephemeralcontainers subresource rather than declared in a
workload template), ordered regular -> init -> ephemeral.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013YcWYpbf4mF49SYnbkf28b
@MPV
MPV force-pushed the claude/ephemeral-containers-support-qybk3c branch from 934bc2c to 57408d8 Compare July 23, 2026 07:07
@MPV
MPV merged commit 387f381 into master Jul 23, 2026
1 check passed
@MPV
MPV deleted the claude/ephemeral-containers-support-qybk3c branch July 23, 2026 08:14
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.

2 participants