Skip to content

chore(chart): reduce crd size by removing description#2106

Open
yashmehrotra wants to merge 1 commit intomainfrom
strip-crds
Open

chore(chart): reduce crd size by removing description#2106
yashmehrotra wants to merge 1 commit intomainfrom
strip-crds

Conversation

@yashmehrotra
Copy link
Copy Markdown
Member

@yashmehrotra yashmehrotra commented Apr 15, 2026

Summary by CodeRabbit

Release Notes

  • Chores

    • Automated removal of field descriptions from generated Custom Resource Definition manifests to streamline YAML output.
  • Refactor

    • Restructured the ScrapePlugin CRD schema layout, simplifying field definitions and organizational structure.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

Walkthrough

A new make target removes description fields from generated CRD YAML files in the build pipeline. The scrapeplugins CRD schema is restructured with simplified field definitions and descriptions removed throughout.

Changes

Cohort / File(s) Summary
Build Configuration
Makefile
Added strip-crd-descriptions target to post-process CRD YAMLs by removing description fields. Updated manifests target to invoke this new target after CRD generation. Minor formatting adjustment to modernize target.
CRD Schema Definition
chart/crds/configs.flanksource.com_scrapeplugins.yaml
Restructured spec schema sections including aliases, changes, properties, relationship, and retention with simplified field definitions and removed documentation annotations. Consolidated nested object structures and clarified field relationships without altering core functionality.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'chore(chart): reduce crd size by removing description' directly and clearly describes the main change: removing description fields from CRD YAMLs to reduce their size.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch strip-crds
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch strip-crds

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 15, 2026

Benchstat

Base: 3c5b31f68194a3b602dc0ed574f043255da79cf6
Head: bb2e4714f36e2b6bdbb468c2517e5242e0afd364

✅ No significant performance changes detected

Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/config-db/bench
cpu: AMD EPYC 7763 64-Core Processor                
                                         │ bench-base.txt │           bench-head.txt           │
                                         │     sec/op     │    sec/op     vs base              │
BenchSaveResultsSeed/N=1000-4                 633.2m ± 7%   627.9m ±  6%       ~ (p=0.937 n=6)
BenchSaveResultsUpdateUnchanged/N=1000-4      715.4m ± 1%   719.6m ± 24%       ~ (p=0.180 n=6)
BenchSaveResultsUpdateChanged/N=1000-4         1.164 ± 2%    1.166 ±  1%       ~ (p=0.485 n=6)
geomean                                       807.8m        807.7m        -0.02%

                                         │ bench-base.txt │           bench-head.txt           │
                                         │      MB/s      │    MB/s     vs base                │
BenchSaveResultsSeed/N=1000-4                0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
BenchSaveResultsUpdateUnchanged/N=1000-4     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
BenchSaveResultsUpdateChanged/N=1000-4       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                 ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                         │ bench-base.txt │           bench-head.txt           │
                                         │      B/op      │     B/op      vs base              │
BenchSaveResultsSeed/N=1000-4                36.05Mi ± 0%   36.07Mi ± 0%       ~ (p=0.240 n=6)
BenchSaveResultsUpdateUnchanged/N=1000-4     25.59Mi ± 0%   25.57Mi ± 0%       ~ (p=0.589 n=6)
BenchSaveResultsUpdateChanged/N=1000-4       74.84Mi ± 0%   74.98Mi ± 0%       ~ (p=0.132 n=6)
geomean                                      41.02Mi        41.05Mi       +0.06%

                                         │ bench-base.txt │          bench-head.txt           │
                                         │   allocs/op    │  allocs/op   vs base              │
BenchSaveResultsSeed/N=1000-4                 442.0k ± 0%   442.0k ± 0%       ~ (p=0.310 n=6)
BenchSaveResultsUpdateUnchanged/N=1000-4      314.0k ± 0%   314.0k ± 0%       ~ (p=0.563 n=6)
BenchSaveResultsUpdateChanged/N=1000-4        904.6k ± 0%   904.7k ± 0%       ~ (p=0.132 n=6)
geomean                                       500.8k        500.8k       +0.00%

@yashmehrotra yashmehrotra requested a review from moshloop April 16, 2026 03:42
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Around line 192-195: The Makefile target strip-crd-descriptions depends on an
undeclared, unpinned yq and doesn’t guard against an empty glob; add a pinned
YQ_VERSION variable and a bootstrap step that mirrors existing tools
(download/extract the specific yq binary into a tools path and expose it via a
YQ_BIN variable), update the target to call $(YQ_BIN) instead of plain yq, and
harden the loop over chart/crds/*.yaml (e.g., skip non-existent matches or use a
safe find pattern) so it fails gracefully when the directory is empty; also
update the repo setup/CI docs/config to document the required YQ_VERSION.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 39db49d9-4e6a-4c6d-b2e4-00e4a369a8d1

📥 Commits

Reviewing files that changed from the base of the PR and between 3c5b31f and bb2e471.

📒 Files selected for processing (3)
  • Makefile
  • chart/crds/configs.flanksource.com_scrapeconfigs.yaml
  • chart/crds/configs.flanksource.com_scrapeplugins.yaml

Comment thread Makefile
Comment on lines +192 to +195
strip-crd-descriptions:
@for f in chart/crds/*.yaml; do \
yq 'del(.. | select(has("description")).description)' "$$f" > "$$f.tmp" && mv "$$f.tmp" "$$f"; \
done
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify yq is referenced/installed anywhere else in the repo
rg -nP '\byq\b' -g '!**/vendor/**' -g '!**/node_modules/**'

Repository: flanksource/config-db

Length of output: 176


🏁 Script executed:

# Check the Makefile structure and how other tools are installed
head -200 Makefile | tail -100

Repository: flanksource/config-db

Length of output: 2824


🏁 Script executed:

# Check if chart/crds directory exists and has yaml files
fd '\.yaml$' chart/crds 2>/dev/null | head -20

Repository: flanksource/config-db

Length of output: 172


🏁 Script executed:

# Look for other tool installations in Makefile
rg -n 'controller-gen|kustomize' Makefile -B2 -A2

Repository: flanksource/config-db

Length of output: 2126


🏁 Script executed:

# Check if there's any documentation or references to yq versions
rg -n 'yq|jq' Makefile -i | head -20

Repository: flanksource/config-db

Length of output: 167


🏁 Script executed:

# Look for any go.mod or requirements that might hint at yq usage
cat go.mod | grep -i yq || echo "No yq in go.mod"

Repository: flanksource/config-db

Length of output: 80


🌐 Web query:

mikefarah yq del select has description syntax vs python yq

💡 Result:

In mikefarah/yq (Go implementation), to delete array elements that have a "description" key, use: del(.[] | select(has("description"))) This works because: - .[] iterates over array elements - has("description") checks if the key exists in the object (returns true even if value is null/empty) - select(has("description")) filters to those elements - del deletes the matching elements from the array Examples from official docs: - del(.[] | select(. == "*at")) deletes array elements matching wildcard - del(.. | select(has("name")).name) recursively deletes "name" keys For objects in an array of objects: yq 'del(.path.to.array[] | select(has("description")))' file.yaml In python-yq (kislyuk/yq, jq wrapper), syntax is identical since it pipes YAML to jq: del(.[] | select(has("description"))) No syntax differences found for this operation; both support jq-like select and has. mikefarah/yq adds native YAML features (comments, etc.), but core filter syntax matches jq. Sample input: items: - name: foo description: bar - name: baz Command: yq 'del(.items[] | select(has("description")))' file.yaml Output: items: - name: baz

Citations:


Undeclared yq dependency and missing version pinning.

The strip-crd-descriptions target relies on yq being installed but doesn't bootstrap it like other tools (controller-gen, kustomize, etc.) do in this Makefile. Additionally, there's no version specification for yq—contributors might have different versions with varying behavior and flag support.

The glob pattern chart/crds/*.yaml could also fail ungracefully if the directory becomes empty; defensive programming would guard against this.

🔧 Suggested hardening
 strip-crd-descriptions:
-	`@for` f in chart/crds/*.yaml; do \
-		yq 'del(.. | select(has("description")).description)' "$$f" > "$$f.tmp" && mv "$$f.tmp" "$$f"; \
-	done
+	`@command` -v yq >/dev/null 2>&1 || { echo "ERROR: yq is required"; exit 1; }
+	`@shopt` -s nullglob 2>/dev/null || true; \
+	for f in chart/crds/*.yaml; do \
+		[ -e "$$f" ] || continue; \
+		yq -i 'del(.. | select(has("description")).description)' "$$f"; \
+	done

Also document the required yq version in your setup/CI configuration.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
strip-crd-descriptions:
@for f in chart/crds/*.yaml; do \
yq 'del(.. | select(has("description")).description)' "$$f" > "$$f.tmp" && mv "$$f.tmp" "$$f"; \
done
strip-crd-descriptions:
`@command` -v yq >/dev/null 2>&1 || { echo "ERROR: yq is required"; exit 1; }
`@shopt` -s nullglob 2>/dev/null || true; \
for f in chart/crds/*.yaml; do \
[ -e "$$f" ] || continue; \
yq -i 'del(.. | select(has("description")).description)' "$$f"; \
done
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` around lines 192 - 195, The Makefile target strip-crd-descriptions
depends on an undeclared, unpinned yq and doesn’t guard against an empty glob;
add a pinned YQ_VERSION variable and a bootstrap step that mirrors existing
tools (download/extract the specific yq binary into a tools path and expose it
via a YQ_BIN variable), update the target to call $(YQ_BIN) instead of plain yq,
and harden the loop over chart/crds/*.yaml (e.g., skip non-existent matches or
use a safe find pattern) so it fails gracefully when the directory is empty;
also update the repo setup/CI docs/config to document the required YQ_VERSION.

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.

1 participant