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

Fix: Moving yaml_decode, and using it in ConfigGroup as well #2317

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 []