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

Cannot override "Metadata" when kcl import -m crd #1844

Open
spastorclovr opened this issue Jan 27, 2025 · 2 comments
Open

Cannot override "Metadata" when kcl import -m crd #1844

spastorclovr opened this issue Jan 27, 2025 · 2 comments

Comments

@spastorclovr
Copy link

Bug Report

1. Minimal reproduce step (Required)

Have a CRDS like so

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: apps.app
spec:
  group: apps.app
  names:
    kind: App
    plural: apps
  versions:
  - name: v1alpha1
    schema:
      openAPIV3Schema:
        type: object
        properties:
          metadata:
            type: object
            properties:
              name:
                type: string
                description: The name of the App
            required:
              - name
  • run kcl import -m crd

2. What did you expect to see? (Required)

I would expect the generated schema wiith at least

metadata?: AppsAppV1alpha1AppMetadata

and AppsAppV1alpha1AppMetadata defined as

schema AppsAppV1alpha1AppMetadata:
    r"""
    apps app v1alpha1 app metadata

    Attributes
    ----------
    name : str, default is Undefined, required
        The name of the App
    """


    name: str

3. What did you see instead (Required)

metadata?: v1.ObjectMeta

4. What is your KCL components version? (Required)

0.11.0

@Peefy
Copy link
Contributor

Peefy commented Jan 27, 2025

Hello @spastorclovr

Are you saying that you want to use a custom metadata structure to constrain metadata to only set fields such as name and not annotations, labels, etc? If so, could you provide more detailed information?

One way you can manually modify the metadata field definition of CRD KCL schema.

@spastorclovr
Copy link
Author

Hey @Peefy,

Yes exactly I need to change the shema corresponding to metadata to make sure our users enter some meaningfull string + also because as we are using the schema for auto-suggestions in their IDE, I wanted to make sure there were no other stuff proposed that would be irrelevant for us in the context of Crossplane Claims we are in.

I did like you are suggesting (adding manually after generation the metadata definition as we want it) but it is true, that if we coud get it generated out of the CRD that would be easier. 😄

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

No branches or pull requests

2 participants