Expand dependencies when marshaling output values (#8301)
* Expand dependencies when marshaling output values [sdk/python] * Update CHANGELOG_PENDING.md * Use existing code * Fix lint
This commit is contained in:
parent
343b4a3501
commit
e629bc32d5
|
@ -18,6 +18,9 @@
|
||||||
However, the streaming output can be extended to `preview` by using the `PULUMI_ENABLE_STREAMING_JSON_PREVIEW` environment variable.
|
However, the streaming output can be extended to `preview` by using the `PULUMI_ENABLE_STREAMING_JSON_PREVIEW` environment variable.
|
||||||
|
|
||||||
[#8275](https://github.com/pulumi/pulumi/pull/8275)
|
[#8275](https://github.com/pulumi/pulumi/pull/8275)
|
||||||
|
|
||||||
|
- [sdk/python] - Expand dependencies when marshaling output values
|
||||||
|
[#8301](https://github.com/pulumi/pulumi/pull/8301)
|
||||||
|
|
||||||
- [codegen/go] - Interaction between the `plain` and `default` tags of a type.
|
- [codegen/go] - Interaction between the `plain` and `default` tags of a type.
|
||||||
[#8254](https://github.com/pulumi/pulumi/pull/8254)
|
[#8254](https://github.com/pulumi/pulumi/pull/8254)
|
||||||
|
|
|
@ -624,7 +624,7 @@ export async function getAllTransitivelyReferencedResourceURNs(resources: Set<Re
|
||||||
// Then the transitively reachable resources of Comp1 will be [Cust1, Cust2, Cust3, Remote1].
|
// Then the transitively reachable resources of Comp1 will be [Cust1, Cust2, Cust3, Remote1].
|
||||||
// It will *not* include:
|
// It will *not* include:
|
||||||
// * Cust4 because it is a child of a custom resource
|
// * Cust4 because it is a child of a custom resource
|
||||||
// * Comp2 because it is a non-remote component resoruce
|
// * Comp2 because it is a non-remote component resource
|
||||||
// * Comp3 and Cust5 because Comp3 is a child of a remote component resource
|
// * Comp3 and Cust5 because Comp3 is a child of a remote component resource
|
||||||
|
|
||||||
// To do this, first we just get the transitively reachable set of resources (not diving
|
// To do this, first we just get the transitively reachable set of resources (not diving
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright 2016-2018, Pulumi Corporation.
|
# Copyright 2016-2021, Pulumi Corporation.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -69,7 +69,7 @@ def is_custom_timeouts(obj: Any) -> bool:
|
||||||
|
|
||||||
def is_stack(obj: Any) -> bool:
|
def is_stack(obj: Any) -> bool:
|
||||||
"""
|
"""
|
||||||
Returns true if the given type is an Output, false otherwise.
|
Returns true if the given type is a Stack, false otherwise.
|
||||||
"""
|
"""
|
||||||
from .stack import Stack # pylint: disable=import-outside-toplevel
|
from .stack import Stack # pylint: disable=import-outside-toplevel
|
||||||
return isinstance(obj, Stack)
|
return isinstance(obj, Stack)
|
||||||
|
|
|
@ -640,11 +640,13 @@ class RegisterResponse:
|
||||||
self.propertyDependencies = propertyDependencies
|
self.propertyDependencies = propertyDependencies
|
||||||
|
|
||||||
|
|
||||||
# Merge all providers opts (opts.provider and both list and dict forms of opts.providers) into a single dict.
|
|
||||||
def convert_providers(
|
def convert_providers(
|
||||||
provider: Optional['ProviderResource'],
|
provider: Optional['ProviderResource'],
|
||||||
providers: Optional[Union[Mapping[str, 'ProviderResource'],
|
providers: Optional[Union[Mapping[str, 'ProviderResource'],
|
||||||
Sequence['ProviderResource']]]) -> Mapping[str, 'ProviderResource']:
|
Sequence['ProviderResource']]]) -> Mapping[str, 'ProviderResource']:
|
||||||
|
"""
|
||||||
|
Merge all providers opts (opts.provider and both list and dict forms of opts.providers) into a single dict.
|
||||||
|
"""
|
||||||
if provider is not None:
|
if provider is not None:
|
||||||
return convert_providers(None, [provider])
|
return convert_providers(None, [provider])
|
||||||
|
|
||||||
|
@ -661,7 +663,7 @@ def convert_providers(
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
async def _add_dependency(deps: Set[str], res: 'Resource', from_resource: 'Resource'):
|
async def _add_dependency(deps: Set[str], res: 'Resource', from_resource: Optional['Resource']):
|
||||||
"""
|
"""
|
||||||
_add_dependency adds a dependency on the given resource to the set of deps.
|
_add_dependency adds a dependency on the given resource to the set of deps.
|
||||||
|
|
||||||
|
@ -700,14 +702,14 @@ async def _add_dependency(deps: Set[str], res: 'Resource', from_resource: 'Resou
|
||||||
if not res._remote:
|
if not res._remote:
|
||||||
return
|
return
|
||||||
|
|
||||||
no_cycles = declare_dependency(from_resource, res)
|
no_cycles = declare_dependency(from_resource, res) if from_resource else True
|
||||||
if no_cycles:
|
if no_cycles:
|
||||||
urn = await res.urn.future()
|
urn = await res.urn.future()
|
||||||
if urn:
|
if urn:
|
||||||
deps.add(urn)
|
deps.add(urn)
|
||||||
|
|
||||||
|
|
||||||
async def _expand_dependencies(deps: Iterable['Resource'], from_resource: 'Resource') -> Set[str]:
|
async def _expand_dependencies(deps: Iterable['Resource'], from_resource: Optional['Resource']) -> Set[str]:
|
||||||
"""
|
"""
|
||||||
_expand_dependencies expands the given iterable of Resources into a set of URNs.
|
_expand_dependencies expands the given iterable of Resources into a set of URNs.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright 2016-2018, Pulumi Corporation.
|
# Copyright 2016-2021, Pulumi Corporation.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -27,6 +27,7 @@ from google.protobuf import struct_pb2
|
||||||
from semver import VersionInfo as Version
|
from semver import VersionInfo as Version
|
||||||
import six
|
import six
|
||||||
from . import known_types, settings
|
from . import known_types, settings
|
||||||
|
from .resource import _expand_dependencies
|
||||||
from .. import log
|
from .. import log
|
||||||
from .. import _types
|
from .. import _types
|
||||||
from .. import urn as urn_util
|
from .. import urn as urn_util
|
||||||
|
@ -278,7 +279,7 @@ async def serialize_property(value: 'Input[Any]',
|
||||||
|
|
||||||
if known_types.is_output(value):
|
if known_types.is_output(value):
|
||||||
output = cast('Output', value)
|
output = cast('Output', value)
|
||||||
value_resources = await output.resources()
|
value_resources: Set['Resource'] = await output.resources()
|
||||||
deps.extend(value_resources)
|
deps.extend(value_resources)
|
||||||
|
|
||||||
# When serializing an Output, we will either serialize it as its resolved value or the
|
# When serializing an Output, we will either serialize it as its resolved value or the
|
||||||
|
@ -287,14 +288,19 @@ async def serialize_property(value: 'Input[Any]',
|
||||||
# resolved with known values.
|
# resolved with known values.
|
||||||
is_known = await output._is_known
|
is_known = await output._is_known
|
||||||
is_secret = await output._is_secret
|
is_secret = await output._is_secret
|
||||||
value = await serialize_property(output.future(), deps, input_transformer, typ, keep_output_values=False)
|
promise_deps: List['Resource'] = []
|
||||||
|
value = await serialize_property(output.future(), promise_deps, input_transformer, typ, keep_output_values=False)
|
||||||
|
deps.extend(promise_deps)
|
||||||
|
value_resources.update(promise_deps)
|
||||||
|
|
||||||
if keep_output_values and await settings.monitor_supports_output_values():
|
if keep_output_values and await settings.monitor_supports_output_values():
|
||||||
# TODO[pulumi/pulumi#7977]: Expand dependencies
|
urn_deps: List['Resource'] = []
|
||||||
dependencies: Set[str] = set()
|
|
||||||
for resource in value_resources:
|
for resource in value_resources:
|
||||||
urn = await serialize_property(resource.urn, deps, input_transformer, keep_output_values=False)
|
await serialize_property(resource.urn, urn_deps, input_transformer, keep_output_values=False)
|
||||||
dependencies.add(cast(str, urn))
|
promise_deps.extend(set(urn_deps))
|
||||||
|
value_resources.update(urn_deps)
|
||||||
|
|
||||||
|
dependencies = await _expand_dependencies(value_resources, None)
|
||||||
|
|
||||||
output_value: Dict[str, Any] = {
|
output_value: Dict[str, Any] = {
|
||||||
_special_sig_key: _special_output_value_sig
|
_special_sig_key: _special_output_value_sig
|
||||||
|
|
Loading…
Reference in a new issue