Skip to content

deploy/kubernetes: embed CRDs instead of duplicating them - #4845

Merged
asim merged 1 commit into
masterfrom
claude/k8s-dedup
Jul 12, 2026
Merged

deploy/kubernetes: embed CRDs instead of duplicating them#4845
asim merged 1 commit into
masterfrom
claude/k8s-dedup

Conversation

@asim

@asim asim commented Jul 12, 2026

Copy link
Copy Markdown
Member

The merged K8s foundation (#4839) kept each CRD manifest in two places:

  • real YAML under deploy/kubernetes/config/crd/{agent,service,flow}.yaml (what kubectl apply uses), and
  • byte-identical const agentCRD/serviceCRD/flowCRD strings in manifests.go (what the Go CRDManifests map returns).

Two copies of the same schema will silently drift — edit one, forget the other, and the applied CRD no longer matches what the package serves.

This makes config/crd/*.yaml the single source of truth and go:embeds it; CRDManifests now reads the embedded bytes. Drops ~120 lines of duplicated YAML.

  • No behavior change: CRDManifests[kind] returns the same content, still stdlib-only (embed), and TestCRDManifestsAreStructural / TestMapDeployment* pass unchanged.
  • manifests.go: 125 → 31 lines.

go build ./..., go test ./deploy/kubernetes/..., go vet, and golangci-lint run ./deploy/kubernetes/... pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CmdEY7pYmV5zzwCjNJ4ykL


Generated by Claude Code

The CRD manifests were kept in two places — real YAML under config/crd/
(for kubectl apply) and byte-identical const strings in manifests.go
(for the Go CRDManifests map) — which will silently drift.

Make config/crd/*.yaml the single source of truth and go:embed it;
CRDManifests now reads the embedded bytes. Drops ~120 lines of
duplicated YAML, no behavior change (still stdlib-only, tests unchanged).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CmdEY7pYmV5zzwCjNJ4ykL
Copilot AI review requested due to automatic review settings July 12, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown

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 removes duplicated Kubernetes CRD YAML embedded as Go string constants and instead embeds the canonical CRD manifests from deploy/kubernetes/config/crd/*.yaml, ensuring the Go-served CRDManifests content matches what users apply with kubectl.

Changes:

  • Replaces inlined CRD YAML string constants with go:embed-backed loading from config/crd/*.yaml.
  • Adds a small helper to read embedded CRD YAML and populates CRDManifests from embedded bytes.
  • Reduces manifests.go substantially by deleting duplicated manifest content.

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

Comment on lines +26 to +30
func mustCRD(name string) string {
b, err := crdFS.ReadFile("config/crd/" + name + ".yaml")
if err != nil {
panic(fmt.Sprintf("kubernetes: embedded CRD %q missing: %v", name, err))
}
@asim
asim merged commit aaa03f8 into master Jul 12, 2026
13 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