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

Add new dynamic class CustomResourceDict with version support #7

Open
4 tasks
gordonbondon opened this issue Mar 8, 2021 · 0 comments · May be fixed by #13
Open
4 tasks

Add new dynamic class CustomResourceDict with version support #7

gordonbondon opened this issue Mar 8, 2021 · 0 comments · May be fixed by #13
Labels
enhancement New feature or request

Comments

@gordonbondon
Copy link
Owner

gordonbondon commented Mar 8, 2021

Current approach with CustomResource["relative/path/to/crd.yaml", "spec", "some_property"] is limited to having only one definition/version in crd file and its impossible to extend with new options. Returned errors always mention TypedDict('Jsonschema') which is not userfriendly.

Instead, we should use get_dynamic_class_hook https://github.com/python/mypy/blob/3acbf3fe78a61c19ff96754233ada453472004c4/mypy/plugin.py#L692-L705 to provide more options while creating custom resource type definition. Possible syntax:

MyResource = CustomResourceDict(
    definition_path="/path/to/crd.yaml",
    property_path: ["spec", "some_property"]
    group: "myapi.io",
    version: "v1",
    kind: "MyResource"
)

First iteration should include these features:

  • CustomResourceDict dynamic hook
  • Handle multiple versions per CustomResourceDefinition
  • Handle multiple definitions per file
  • Set TypeDict name from kind

Similar to https://github.com/lovasoa/marshmallow_dataclass/blob/513e8bfc0dcef02314180790486cea3c04f65178/marshmallow_dataclass/mypy.py

@gordonbondon gordonbondon added the enhancement New feature or request label Mar 8, 2021
@gordonbondon gordonbondon changed the title New dynamic class CustomResourceDict with version support Add new dynamic class CustomResourceDict with version support Mar 23, 2021
@gordonbondon gordonbondon linked a pull request Aug 29, 2021 that will close this issue
@gordonbondon gordonbondon pinned this issue Jan 31, 2022
@gordonbondon gordonbondon unpinned this issue Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant