Skip to content

Passing dict manifests to strictly-typed kubernetes-asyncio API calls #412

@dyens

Description

@dyens

In the new version, types have been added. For example:

def create_namespaced_secret(self, namespace: str, body: V1Secret, ...) -> Awaitable[V1Secret]: 
    ...

Previously, you could pass either a V1Secret or a dict[str, Any] to this function. Now the type system complains when you try to pass a dict.

The thing is, I don't know in advance what manifest dict I'll receive (it can have different sets of fields), so I can't explicitly construct a V1Secret.

What's the right approach now?

create_namespaced_secret(namespace, cast(V1Secret, dict_manifest))

Or maybe?

create_namespaced_secret(namespace, api_client.__deserialize_model(dict_manifest, V1Secret))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions