Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Skip TopKind in maps #70

Merged
merged 3 commits into from
Dec 23, 2022
Merged

Skip TopKind in maps #70

merged 3 commits into from
Dec 23, 2022

Conversation

spinillos
Copy link
Member

@spinillos spinillos commented Dec 22, 2022

I was testing v0.1.3 with our current cue files and I saw the following:

panels: [...(#Panel | #GraphPanel | #HeatmapPanel)] @grafanamaturity(NeedsExpertReview)

was generating:

panels?: Array<(Panel | RowPanel | {
    type: 'graph';
  } | {
    type: 'heatmap';
})>;

with 0.1.3:

panels?: Array<(Panel | Record<string, unknown> | Record<string, unknown>)>;

And its not right.

The issue came because GraphPanel and HeatmapPanel are structs with data like:

#Something: {
  foo: "bar"
  ...
}

These structs are detected as maps, their kind is cue.TopKind and we set unknown. So if we skip them, we can generate the proper value without losing information.

Note: I back any as default in TopKind kind. When we detect an empty {...} the writer is going to print Result<string, unknown> like it was doing before.

@spinillos spinillos merged commit 77a030e into main Dec 23, 2022
@spinillos spinillos deleted the skip-top-kinds-in-maps branch December 23, 2022 10:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant