Pulumi-kubernetes: Python modules don't export sub-module names

Created on 11 Jun 2020  路  1Comment  路  Source: pulumi/pulumi-kubernetes

It looks like we don't export sub-module names for the Kubernetes provider in Python like we do all other resource providers.

That means this style isn't supported:

import pulumi_kubernetes as k8s
pull_secret = k8s.core.v1.Secret(...)

This leads to an error: AttributeError: module 'pulumi_kubernetes' has no attribute 'core'.

This inconsistency is unfortunate and, personally, I prefer to use this style when mixing lots of different resource providers (like AWS) since otherwise you end up with pull_secret = Secret(...) or things like pull_secret = v1.Secret(...), which doesn't tell you contextually what's happening.

The other resource packages do this:

for pkg in __all__:
    if pkg != 'config':
        importlib.import_module(f'{__name__}.{pkg}')

to re-export module names. I realize that dynamic export doesn't work well with MyPy (see https://github.com/pulumi/pulumi/issues/4416) but -- unless this was done intentionally in the Kubernetes package -- I'd vote for just doing it until we have a better story there, so we're consistent across all of our providers.

Most helpful comment

I believe this will get fixed as part of https://github.com/pulumi/pulumi-kubernetes/issues/1085.

>All comments

I believe this will get fixed as part of https://github.com/pulumi/pulumi-kubernetes/issues/1085.

Was this page helpful?
0 / 5 - 0 ratings