[sdk/dotnet] Don't send deps maps when using output values

This commit is contained in:
Justin Van Patten 2021-11-12 16:12:56 -08:00
parent fca55516e6
commit 52f3437100
2 changed files with 19 additions and 9 deletions

View file

@ -52,11 +52,13 @@ namespace Pulumi
argsDict = argsDict.SetItem("__self__", self);
}
var keepOutputs = await MonitorSupportsOutputValues().ConfigureAwait(false);
var (serialized, argDependencies) = await SerializeFilteredPropertiesAsync(
$"call:{token}",
argsDict, _ => true,
keepResources: true,
keepOutputValues: await MonitorSupportsOutputValues().ConfigureAwait(false)).ConfigureAwait(false);
keepOutputValues: keepOutputs).ConfigureAwait(false);
Log.Debug($"Call RPC prepared: token={token}" +
(_excessiveDebugOutput ? $", obj={serialized}" : ""));
@ -84,13 +86,17 @@ namespace Pulumi
Args = serialized,
};
// Add arg dependencies to the request.
foreach (var (argName, directDependencies) in argDependencies)
// Only include the arg dependencies map in the request when *not* keeping output values.
// When keeping output values, the dependencies will already exist within the args.
if (!keepOutputs)
{
var urns = await GetAllTransitivelyReferencedResourceUrnsAsync(directDependencies).ConfigureAwait(false);
var deps = new CallRequest.Types.ArgumentDependencies();
deps.Urns.AddRange(urns);
request.ArgDependencies.Add(argName, deps);
foreach (var (argName, directDependencies) in argDependencies)
{
var urns = await GetAllTransitivelyReferencedResourceUrnsAsync(directDependencies).ConfigureAwait(false);
var deps = new CallRequest.Types.ArgumentDependencies();
deps.Urns.AddRange(urns);
request.ArgDependencies.Add(argName, deps);
}
}
// Kick off the call.

View file

@ -21,7 +21,10 @@ namespace Pulumi
var label = $"resource:{name}[{type}]";
Log.Debug($"Registering resource start: t={type}, name={name}, custom={custom}, remote={remote}");
var request = CreateRegisterResourceRequest(type, name, custom, remote, options);
// Keep track of whether we've kept output values when serializing.
var hasOutputs = remote && await MonitorSupportsOutputValues().ConfigureAwait(false);
var request = CreateRegisterResourceRequest(type, name, custom, remote, options, hasOutputs);
Log.Debug($"Preparing resource: t={type}, name={name}, custom={custom}, remote={remote}");
var prepareResult = await PrepareResourceAsync(label, resource, custom, remote, args, options).ConfigureAwait(false);
@ -65,7 +68,7 @@ namespace Pulumi
}
private static RegisterResourceRequest CreateRegisterResourceRequest(
string type, string name, bool custom, bool remote, ResourceOptions options)
string type, string name, bool custom, bool remote, ResourceOptions options, bool hasOutputs)
{
var customOpts = options as CustomResourceOptions;
var deleteBeforeReplace = customOpts?.DeleteBeforeReplace;
@ -89,6 +92,7 @@ namespace Pulumi
Update = TimeoutString(options.CustomTimeouts?.Update),
},
Remote = remote,
HasOutputs = hasOutputs,
};
if (customOpts != null)