Skip to content

Commit

Permalink
Fix: Python SDK: kustomize.Directory: handle a not fully configured p…
Browse files Browse the repository at this point in the history
…rovider (#2347)

* Fix: Python SDK: kustomize.Directory: handle a not fully configured provider

Fixes: #2346

* Fix: Python SDK: kustomize.Directory: modify the template

Per #2347 (comment)

Result of:

```console
pulumi-kubernetes $ cp sdk/python/pulumi_kubernetes/kustomize/kustomize.py provider/pkg/gen/python-templates/kustomize/kustomize.py
pulumi-kubernetes $ make python_sdk
[...]
pulumi-kubernetes $
```

Fixes: #2346

* Fix: Python SDK: kustomize.Directory: add a changelog entry

Per #2347 (comment)

---------

Co-authored-by: Kyle Pitzen <kyle.pitzen@gmail.com>
  • Loading branch information
filip-zyzniewski and kpitzen committed Apr 7, 2023
1 parent 9b7eeae commit a907bdd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

- Allow instantiation of kustomize.Directory with a not fully configured provider (https://github.com/pulumi/pulumi-kubernetes/pull/2347)

## 3.24.3 (April 6, 2023)

- Handle CSA to SSA field manager conflicts (https://github.com/pulumi/pulumi-kubernetes/pull/2354)
Expand Down
8 changes: 6 additions & 2 deletions provider/pkg/gen/python-templates/kustomize/kustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,16 @@ def omit_resource(obj, opts):
provider=opts.provider if opts.provider else None)

__ret__ = pulumi.runtime.invoke(
'kubernetes:kustomize:directory', {'directory': directory}, invoke_opts).value['result']
'kubernetes:kustomize:directory', {'directory': directory}, invoke_opts)

# Handle the cases when the provider is not fully configured:
# https://github.com/pulumi/pulumi/blob/v3.60.1/sdk/go/common/resource/plugin/provider_plugin.go#L1364-L1367
result = (__ret__.value or {}).get('result', [])

# Note: Unlike NodeJS, Python requires that we "pull" on our futures in order to get them scheduled for
# execution. In order to do this, we leverage the engine's RegisterResourceOutputs to wait for the
# resolution of all resources that this YAML document created.
self.resources = k8s.yaml.yaml._parse_yaml_document(__ret__, opts, transformations, resource_prefix)
self.resources = k8s.yaml.yaml._parse_yaml_document(result, opts, transformations, resource_prefix)
self.register_outputs({"resources": self.resources})

def translate_output_property(self, prop: str) -> str:
Expand Down
8 changes: 6 additions & 2 deletions sdk/python/pulumi_kubernetes/kustomize/kustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,16 @@ def omit_resource(obj, opts):
provider=opts.provider if opts.provider else None)

__ret__ = pulumi.runtime.invoke(
'kubernetes:kustomize:directory', {'directory': directory}, invoke_opts).value['result']
'kubernetes:kustomize:directory', {'directory': directory}, invoke_opts)

# Handle the cases when the provider is not fully configured:
# https://github.com/pulumi/pulumi/blob/v3.60.1/sdk/go/common/resource/plugin/provider_plugin.go#L1364-L1367
result = (__ret__.value or {}).get('result', [])

# Note: Unlike NodeJS, Python requires that we "pull" on our futures in order to get them scheduled for
# execution. In order to do this, we leverage the engine's RegisterResourceOutputs to wait for the
# resolution of all resources that this YAML document created.
self.resources = k8s.yaml.yaml._parse_yaml_document(__ret__, opts, transformations, resource_prefix)
self.resources = k8s.yaml.yaml._parse_yaml_document(result, opts, transformations, resource_prefix)
self.register_outputs({"resources": self.resources})

def translate_output_property(self, prop: str) -> str:
Expand Down

0 comments on commit a907bdd

Please sign in to comment.