Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PoC] Use cog to generate go and typescript models + resources #296

Closed
wants to merge 6 commits into from

Conversation

K-Phoen
Copy link
Member

@K-Phoen K-Phoen commented May 29, 2024

Draft PR meant to try out cog as a potential replacement for Go and Typescript codegen purposes.

ToDo:

  • the thema.CustomKindParser provided by grafana-app-sdk used with cog's CUE parser struggle to correctly handle references to objects defined "above" the currently parsed root. Ex:
    #InnerObject2: { // ← object defined "above" the current root
        name: string
        details: {
            [string]: _
        }
    }
    
    spec: { // ← current root
        inner: #InnerObject1
        // ...
    }
    Cog detects this case correctly, gets the path to InnerObject2 (something like customKind.lineage._sortedSchemas[1]._#schema.#InnerObject2), but resolving this path (with LookupPath() fails on hidden fields introduced by thema (_sortedSchemas and _#schema).
    If thema support isn't meant to stick around long-term, this issue might not be worth solving.

Note: this PR isn't necessarily meant to be finished or merged, it's more a sandbox to play with cog + grafana-app-sdk.

@radiohead
Copy link
Contributor

@K-Phoen thank you for experimenting with this! This is something that's been on our radar for a while, but we never had any bandwidth for.

Please let us know if we can help get this ready for a review. One notable change we've made since this PR was opened is that we got rid of Thema support, so this should no longer be an issue.

@K-Phoen
Copy link
Member Author

K-Phoen commented Nov 12, 2024

Not having to support Thema schemas should simplify things :)

I'll get back to working on this and let you know if I need a hand!

@K-Phoen
Copy link
Member Author

K-Phoen commented Nov 19, 2024

Closing this in favor of #485

@K-Phoen K-Phoen closed this Nov 19, 2024
@K-Phoen K-Phoen deleted the cog/sandbox branch November 19, 2024 16:06
IfSentient pushed a commit that referenced this pull request Nov 23, 2024
Replaces #296

This PR replaces cuetsy and deepmap/oapi-codegen to generate Go and TS
types.

Note: the code by cog can be different from what is currently generated,
I'd need some help to review these changes and determine if they are
correct/acceptable.
I followed the [issue tracker
tutorial](https://github.com/grafana/grafana-app-sdk/tree/main/docs/tutorials/issue-tracker)
and the results seem to make sense to me but I'm far from being an
expert 😅
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.

2 participants