Skarlso / crd-to-sample-yaml

Generate a sample YAML file from a CRD and view it rendered on a nice website
https://crdtoyaml.com/
Apache License 2.0
131 stars 17 forks source link

Generated HTML GVK not filled #123

Closed markussiebert closed 1 month ago

markussiebert commented 1 month ago

Hi,

when I look at

image

I think that it might be possible to hard code the GroupVersion and Kind?

It would be great if Kind/Version are displayed there. In the details pane, the correct values are used.

Skarlso commented 1 month ago

Ah, I'm not using values there. What's there is the Description of the Kind and apiVersion values in the properties section.

If you don't have any descriptions, I guess I can try to fill it with the actual value. 🤔

markussiebert commented 1 month ago

OK, I think in general, it's not useful to parse the crd for both fields...

image

in the headline above the resource, cty says what GVK this is for - so I think apiVersion and kind should look like

apiVersion: the current GV - in this case some.thi.ng/v1alpha1 kind: the current K - in this case Project

(maybe we could show that both are string - but even if there is a pattern/enum/something we shouldn't show it)

I looked into the json schemas of k8s resources like configmap and so on. They define Kind as an enum, but apiVersion is string or nil - but both is not useful for examples/documentation...

What do you think?

Skarlso commented 1 month ago

Fair point. I'll see how I can define them nicely... Or give them a value or something. The generation is rather generic so including specific field handling is a bit of a pain in the arse. :D

Skarlso commented 1 month ago

The AWSCluster definition defines kind and apiVersion like this:

            apiVersion:
              description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
              type: string
            kind:
              description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
              type: string

I think everyone does it differently, so I think there is merit in displaying them and the constraint they are setting.

That said, I can definitely add the value in there as well.

Skarlso commented 1 month ago
Screenshot 2024-10-19 at 22 48 15

@markussiebert How about something like this? If the description is empty, I'll fill in the actual value?

markussiebert commented 1 month ago

Great, would be sufficient I think