Skip to content

Commit

Permalink
Fix: Moving yaml_decode, and using it in ConfigGroup as well (#2317)
Browse files Browse the repository at this point in the history
* Fix: Moving yaml_decode, and using it in ConfigGroup as well, Fixes #2309

* Chore: Updating changelog
  • Loading branch information
rshade committed Feb 16, 2023
1 parent 92fd8cf commit 623fbbe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## Unreleased

- moves `invoke_yaml_decode` into ConfigGroup for python (https://github.com/pulumi/pulumi-kubernetes/pull/2317)
## 3.24.0 (February 6, 2023)

- Fix unencrypted secrets in the state `outputs` after `Secret.get` #2300
- Fix unencrypted secrets in the state `outputs` after `Secret.get` (https://github.com/pulumi/pulumi-kubernetes/pull/2300)
- Upgrade to latest helm and k8s client dependencies (https://github.com/pulumi/pulumi-kubernetes/pull/2292)
- Fix await status for Job and Pod (https://github.com/pulumi/pulumi-kubernetes/pull/2299)

Expand Down
12 changes: 7 additions & 5 deletions provider/pkg/gen/python-templates/yaml/yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ConfigGroup(pulumi.ComponentResource):
invoke_opts = pulumi.InvokeOptions(version=_utilities.get_version(),
provider=opts.provider if opts.provider else None)

__ret__ = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts).value['result']
__ret__ = invoke_yaml_decode(text, invoke_opts)
resources = _parse_yaml_document(__ret__, opts, transformations, resource_prefix)
# Add any new YAML resources to the ConfigGroup's resources
self.resources = pulumi.Output.all(resources, self.resources).apply(lambda x: {**x[0], **x[1]})
Expand Down Expand Up @@ -344,10 +344,8 @@ class ConfigFile(pulumi.ComponentResource):
# in package.json.
invoke_opts = pulumi.InvokeOptions(version=_utilities.get_version(),
provider=opts.provider if opts.provider else None)
def invoke_yaml_decode(text):
inv = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts)
return inv.value['result'] if inv is not None and inv.value is not None else []
__ret__ = invoke_yaml_decode(text)

__ret__ = invoke_yaml_decode(text, invoke_opts)

# 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
Expand Down Expand Up @@ -516,3 +514,7 @@ def _parse_yaml_object(
return [identifier.apply(
lambda x: (f"{gvk}:{x}",
CustomResource(f"{x}", api_version, kind, spec, metadata, opts)))]

def invoke_yaml_decode(text, invoke_opts):
inv = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts)
return inv.value['result'] if inv is not None and inv.value is not None else []
12 changes: 7 additions & 5 deletions sdk/python/pulumi_kubernetes/yaml/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def omit_resource(obj, opts):
invoke_opts = pulumi.InvokeOptions(version=_utilities.get_version(),
provider=opts.provider if opts.provider else None)

__ret__ = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts).value['result']
__ret__ = invoke_yaml_decode(text, invoke_opts)
resources = _parse_yaml_document(__ret__, opts, transformations, resource_prefix)
# Add any new YAML resources to the ConfigGroup's resources
self.resources = pulumi.Output.all(resources, self.resources).apply(lambda x: {**x[0], **x[1]})
Expand Down Expand Up @@ -344,10 +344,8 @@ def omit_resource(obj, opts):
# in package.json.
invoke_opts = pulumi.InvokeOptions(version=_utilities.get_version(),
provider=opts.provider if opts.provider else None)
def invoke_yaml_decode(text):
inv = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts)
return inv.value['result'] if inv is not None and inv.value is not None else []
__ret__ = invoke_yaml_decode(text)

__ret__ = invoke_yaml_decode(text, invoke_opts)

# 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
Expand Down Expand Up @@ -1924,3 +1922,7 @@ def _parse_yaml_object(
return [identifier.apply(
lambda x: (f"{gvk}:{x}",
CustomResource(f"{x}", api_version, kind, spec, metadata, opts)))]

def invoke_yaml_decode(text, invoke_opts):
inv = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts)
return inv.value['result'] if inv is not None and inv.value is not None else []

0 comments on commit 623fbbe

Please sign in to comment.