2019-11-21 22:46:14 +01:00
|
|
|
|
// Copyright 2016-2019, Pulumi Corporation
|
2019-10-26 01:59:50 +02:00
|
|
|
|
|
2020-10-06 19:19:22 +02:00
|
|
|
|
using System.Collections.Immutable;
|
2019-10-26 01:59:50 +02:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
|
using Pulumirpc;
|
|
|
|
|
|
|
|
|
|
namespace Pulumi
|
|
|
|
|
{
|
|
|
|
|
public partial class Deployment
|
|
|
|
|
{
|
2020-10-06 19:19:22 +02:00
|
|
|
|
private async Task<(string urn, string id, Struct data, ImmutableDictionary<string, ImmutableHashSet<Resource>> dependencies)> ReadResourceAsync(
|
2019-10-27 08:06:16 +01:00
|
|
|
|
Resource resource, string id, ResourceArgs args, ResourceOptions options)
|
2019-10-26 01:59:50 +02:00
|
|
|
|
{
|
|
|
|
|
var name = resource.GetResourceName();
|
|
|
|
|
var type = resource.GetResourceType();
|
|
|
|
|
var label = $"resource:{name}[{type}]#...";
|
2019-10-27 08:06:16 +01:00
|
|
|
|
Log.Debug($"Reading resource: id={id}, t=${type}, name=${name}");
|
2019-10-26 01:59:50 +02:00
|
|
|
|
|
|
|
|
|
var prepareResult = await this.PrepareResourceAsync(
|
2021-04-17 00:12:53 +02:00
|
|
|
|
label, resource, custom: true, remote: false, args, options).ConfigureAwait(false);
|
2019-10-26 01:59:50 +02:00
|
|
|
|
|
2019-10-27 08:06:16 +01:00
|
|
|
|
Log.Debug($"ReadResource RPC prepared: id={id}, t={type}, name={name}" +
|
2019-10-26 01:59:50 +02:00
|
|
|
|
(_excessiveDebugOutput ? $", obj={prepareResult.SerializedProps}" : ""));
|
|
|
|
|
|
|
|
|
|
// Create a resource request and do the RPC.
|
|
|
|
|
var request = new ReadResourceRequest
|
|
|
|
|
{
|
|
|
|
|
Type = type,
|
|
|
|
|
Name = name,
|
2019-10-27 08:06:16 +01:00
|
|
|
|
Id = id,
|
2019-10-26 01:59:50 +02:00
|
|
|
|
Parent = prepareResult.ParentUrn,
|
|
|
|
|
Provider = prepareResult.ProviderRef,
|
|
|
|
|
Properties = prepareResult.SerializedProps,
|
2021-06-10 16:32:33 +02:00
|
|
|
|
Version = options.Version ?? "",
|
2019-10-26 01:59:50 +02:00
|
|
|
|
AcceptSecrets = true,
|
2020-12-10 19:21:05 +01:00
|
|
|
|
AcceptResources = !_disableResourceReferences,
|
2019-10-26 01:59:50 +02:00
|
|
|
|
};
|
|
|
|
|
|
2021-06-10 16:32:33 +02:00
|
|
|
|
request.Dependencies.AddRange(prepareResult.AllDirectDependencyUrns);
|
2019-10-26 01:59:50 +02:00
|
|
|
|
|
|
|
|
|
// Now run the operation, serializing the invocation if necessary.
|
2021-07-22 00:44:10 +02:00
|
|
|
|
var response = await this.Monitor.ReadResourceAsync(resource, request).ConfigureAwait(false);
|
2019-10-26 01:59:50 +02:00
|
|
|
|
|
2020-10-06 19:19:22 +02:00
|
|
|
|
return (response.Urn, id, response.Properties, ImmutableDictionary<string, ImmutableHashSet<Resource>>.Empty);
|
2019-10-26 01:59:50 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|