feat(podspec): find PodSpecs by reflecting over the decoded object (option A) - #81
Open
MPV wants to merge 1 commit into
Open
feat(podspec): find PodSpecs by reflecting over the decoded object (option A)#81MPV wants to merge 1 commit into
MPV wants to merge 1 commit into
Conversation
MPV
force-pushed
the
claude/podspec-a-scheme-reflection
branch
from
August 9, 2026 20:35
1e6a4a8 to
4d842eb
Compare
This was referenced Aug 9, 2026
MPV
force-pushed
the
claude/podspec-a-scheme-reflection
branch
from
August 10, 2026 06:39
4d842eb to
5990e9f
Compare
Option A of four candidate answers to #26, raised side by side for comparison. Keeps typed decoding; replaces the lookup with a search. k8s.FindPodSpecs walks the decoded Go value and collects every field of type corev1.PodSpec, wherever it sits. Kinds and paths both disappear: the seven-case type switch goes, and so does the kind allow-list in yamlparser that List items were checked against. Two built-in kinds the type switch omitted now work with no code dedicated to them: $ kir replicationcontroller.yaml # before: nothing nginx:1.27 $ kir podtemplate.yaml # before: nothing worker:3.1 Both are added to the golden kind table. Precision is unchanged — only real corev1.PodSpec values match, so no false positives — and there is no measurable cost, since decoding dominates (169ms -> 165ms over 1000 documents, within noise). The inherited limit is that reflection only sees what the scheme can decode, so custom resources embedding a PodSpec remain invisible. That is the half of #26 this option does not address; see ADR 0008. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013RYRsLAGHPcRuwhodXXmWP
MPV
force-pushed
the
claude/podspec-a-scheme-reflection
branch
from
August 13, 2026 07:49
5990e9f to
a56e43c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Option A of four candidate answers to #26, raised side by side so they can be compared. Scope
feat(podspec)finds the set — #81 #82 #83 #84. Only one should be merged.Rebased onto
2abd515(0.4.3) — Kubernetes v0.36.3, Go 1.26. All numbers re-measured on that base.masterRollout)--configWorkflow)--configReplicationController,PodTemplatecontainerslookalikego.sumlinesmake schema--schema--configAll four keep the existing goldens green and produce byte-identical output on the shared 1000-document corpus. Timings are best-of-7 in a single run on one machine.
Approach
Keep typed decoding; replace the lookup with a search.
k8s.FindPodSpecswalks the decoded Go value and collects every field of typecorev1.PodSpec, wherever it sits.Kinds and paths both disappear — the seven-case type switch, and the
supportedKindsallow-list thatListitems were checked against.What it buys
Two built-in kinds the type switch omitted now work, with no code naming them:
Both are checked-in fixtures with goldens, so the examples can't drift. A workload kind added to
k8s.io/apiin future needs no change here — the Kubernetes v0.32.3 → v0.36.3 bump in the rebase is a small demonstration: no code change, no golden moved.What it doesn't
Custom resources remain invisible — reflection only sees what the scheme can decode, so an Argo Rollout still yields nothing. This addresses #26's "less hardcoded kinds/structures" but not "easier to use with other (custom) resources". That is the reason to weigh it against B and C.
Notes for review
corev1.PodSpecvalues match, so no false positives are possible and no lookalike guard is needed.master's goldens and dependency set completely untouched, which is worth something if the answer to Dynamically findPodSpecin manifests #26 turns out to be "not yet".gofmt,go vet,go mod tidyno-op,go test -race ./...green. ADR 0009 records the decision as proposed, superseding ADR 0001 only if merged.