Skip to content

Extract images from PodSpec using Cue - #28

Closed
MPV wants to merge 4 commits into
masterfrom
cue-with-cursor
Closed

Extract images from PodSpec using Cue#28
MPV wants to merge 4 commits into
masterfrom
cue-with-cursor

Conversation

@MPV

@MPV MPV commented Apr 15, 2025

Copy link
Copy Markdown
Owner

I asked Cursor to:

Read the code here https://github.com/myitcvscratch/yamlpodspec and update this KIR repo to make use of CUE for parsing the PodSpec from any yaml string.


Here's how Cursor summarized its changes:

Great! All tests are passing now. Let's summarize what we've done:

  1. Added CUE support to the project by:
    • Adding CUE dependencies to go.mod
    • Creating a new cueparser package with a local PodSpec schema
    • Implementing CUE-based YAML parsing with validation
  2. Updated the yamlparser package to:
    • Try CUE-based parsing first
    • Fall back to the original implementation if CUE parsing fails
    • Handle both single YAML documents and multi-document YAML files
  3. Added comprehensive tests for:
    • Basic PodSpec validation
    • Container image extraction
    • Multi-document YAML processing

The implementation now uses CUE for parsing and validating PodSpecs, with several advantages:

  1. Strong schema validation using CUE's type system
  2. Graceful fallback to the original implementation if CUE validation fails
  3. Support for both single and multi-document YAML files
  4. Clear separation of concerns between parsing and validation

MPV commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #83, which carries this idea to current master.

This used a hand-written local PodSpec schema with a fallback to the original typed implementation. #83 differs on both points:

  • The schema is generated, not written. cue get go k8s.io/api/core/v1 (make schema) produces the definitions; what kir maintains is the import that names them. Nothing to drift from the API.
  • No fallback. CUE is the only path, so the goldens measure CUE's real behaviour rather than the typed fallback quietly covering for it.

Two findings from #83 that this PR's fallback would have masked, worth recording since they are properties of the approach rather than of either implementation:

  • Manifests decode YAML→JSON→Go, so every number is a float64. Offering that to a schema saying int32 rejects every container declaring a port. With a fallback in place this looks like everything working.
  • cue.Value.Eval() on the definitions is ~7× faster and silently discards closedness, so every lookalike starts matching. Nothing errors.

And the headline: matching against the full official #Container costs 2469 ms per 1000 documents against master's 152 ms. That is the open question on #83, not whether it works.

Closing as superseded rather than rejected — the cue-with-cursor branch is untouched. #83 is one of four candidates for #26 (#81 #82 #83 #84).


Generated by Claude Code

@MPV MPV closed this Aug 9, 2026
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