Skip to content

fix(crd): validate packaged CRD artifacts - #202

Merged
GatewayJ merged 2 commits into
rustfs:mainfrom
GatewayJ:agent/crd-artifact-validation
Jul 29, 2026
Merged

fix(crd): validate packaged CRD artifacts#202
GatewayJ merged 2 commits into
rustfs:mainfrom
GatewayJ:agent/crd-artifact-validation

Conversation

@GatewayJ

Copy link
Copy Markdown
Member

Type of Change

  • New Feature
  • Bug Fix
  • Documentation
  • Performance Improvement
  • Test/CI
  • Refactor
  • Other:

Related Issues

Follow-up to #198.

Summary of Changes

  • Keep the development PolicyBinding CRD synchronized with the normalized generated schema.
  • Parse rendered CRDs structurally when checking spec.names.categories.
  • Scan every Helm chart CRD document and reject duplicate or unexpected CRD names.
  • Track both the Helm and development PolicyBinding CRD files against generated output.

Checklist

  • I have read and followed the CONTRIBUTING.md guidelines
  • Passed make pre-commit (fmt-check + clippy + test + console-lint + console-fmt-check)
  • Added/updated necessary tests
  • Documentation updated (N/A; no documentation change required)
  • CHANGELOG.md updated under [Unreleased] (N/A; no user-facing feature change)
  • CI/CD passed (pending)

Impact

  • Breaking change (CRD/API compatibility)
  • Requires doc/config/deployment update
  • Other impact: prevents duplicate or stale packaged CRD artifacts from passing tests

Verification

make pre-commit

Additional Notes

This addresses the review follow-ups identified after merging #198.

@GatewayJ

Copy link
Copy Markdown
Member Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1cc8813c6a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib.rs Outdated
.map(|crd| crd.metadata.name.expect("generated CRD should have a name"))
.collect::<BTreeSet<_>>();
let crd_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("deploy/rustfs-operator/crds");
let mut entries = fs::read_dir(&crd_dir)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Traverse nested chart CRD directories

When a CRD is placed under a subdirectory such as crds/vendor/foo.yaml, fs::read_dir returns only the vendor directory, which the extension filter then skips, so this validation passes without checking that packaged artifact. Helm’s CRDObjects implementation selects chart files by the crds/ path prefix, including nested files; recursively walk this directory or inspect the packaged chart so duplicate and unexpected nested CRDs are rejected.

Useful? React with 👍 / 👎.

Comment thread src/lib.rs
for crd in parse_crds(&yaml) {
let name = crd.metadata.name.as_deref().unwrap_or("<unnamed>");
assert!(
crd.spec.names.categories.is_none(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Verify that categories is absent from the serialized YAML

If rendering regresses to emitting spec.names.categories: null, deserializing into the optional categories field produces None, so this assertion passes even though the key was not omitted. That allows regenerated packaged artifacts to violate the exact omission this regression test is intended to enforce; inspect the YAML mapping for key presence rather than relying only on the deserialized Option.

Useful? React with 👍 / 👎.

@GatewayJ
GatewayJ marked this pull request as ready for review July 29, 2026 13:47
@GatewayJ
GatewayJ added this pull request to the merge queue Jul 29, 2026
Merged via the queue into rustfs:main with commit f62f291 Jul 29, 2026
3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5cb09cf533

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib.rs
Comment on lines +1055 to +1057
["yaml", "yml", "json"]
.iter()
.any(|expected| extension.eq_ignore_ascii_case(expected))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match Helm's case-sensitive manifest extensions

When a file under crds/ uses an uppercase suffix—as the new .YML and .JSON fixtures do—this helper selects it, but Helm's hasManifestExtension accepts only the exact lowercase extensions .yaml, .yml, and .json. The validation therefore does not actually mirror Helm: it can parse and count an artifact that Helm will skip during CRD installation, or fail on an uppercase auxiliary file Helm ignores. Use the same case-sensitive extension comparison as Helm.

Useful? React with 👍 / 👎.

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