fixes
This commit is contained in:
parent
f1f1b80deb
commit
636f2c9a73
|
@ -14,7 +14,9 @@ public static class Program
|
|||
{
|
||||
if (!properties.TryGetValue("__provider", out var providerValue))
|
||||
{
|
||||
throw new RpcException(new Status(StatusCode.Unknown, "Dynamic resource had no '__provider' property"));
|
||||
var props = string.Concat(properties.Select(item => string.Format("{0} = {1}", item.Key, item.Value)));
|
||||
var msg = string.Format("Dynamic resource had no '__provider' property, was: {0}", props);
|
||||
throw new RpcException(new Status(StatusCode.Unknown, msg));
|
||||
}
|
||||
|
||||
if(!(providerValue is string providerString))
|
||||
|
@ -74,17 +76,22 @@ public static class Program
|
|||
|
||||
public override async Task<CreateResponse> Create(CreateRequest request, ServerCallContext context)
|
||||
{
|
||||
var properties = Pulumi.Serialization.Rpc.DeserialiseProperties(request.Properties);
|
||||
var (provider, inputs) = GetProvider(properties);
|
||||
try {
|
||||
var properties = Pulumi.Serialization.Rpc.DeserialiseProperties(request.Properties);
|
||||
var (provider, inputs) = GetProvider(properties);
|
||||
|
||||
var (id, outputs) = await provider.Create(inputs);
|
||||
var (id, outputs) = await provider.Create(inputs);
|
||||
|
||||
var response = new CreateResponse();
|
||||
response.Id = id;
|
||||
response.Properties = Pulumi.Serialization.Rpc.SerialiseProperties(outputs);
|
||||
// Readd provider
|
||||
response.Properties.Fields.Add("__provider", request.Properties.Fields["__provider"]);
|
||||
return response;
|
||||
var response = new CreateResponse();
|
||||
response.Id = id;
|
||||
response.Properties = Pulumi.Serialization.Rpc.SerialiseProperties(outputs);
|
||||
// Readd provider
|
||||
response.Properties.Fields.Add("__provider", request.Properties.Fields["__provider"]);
|
||||
return response;
|
||||
} catch (System.Exception ex)
|
||||
{
|
||||
throw new RpcException(new Status(StatusCode.Unknown, ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
public override Task<ReadResponse> Read(ReadRequest request, ServerCallContext context)
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace Pulumi
|
|||
{
|
||||
public class DynamicResourceArgs : ResourceArgs
|
||||
{
|
||||
[Input("__provider")]
|
||||
internal string Provider { get; set; } = null!;
|
||||
[Input("__provider", required: true)]
|
||||
public Input<string> Provider { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class DynamicResource : CustomResource
|
||||
|
@ -21,8 +21,11 @@ namespace Pulumi
|
|||
|
||||
private static bool ByValueFilter(System.Reflection.Assembly assembly)
|
||||
{
|
||||
var pulumiAssembly = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
return assembly != pulumiAssembly;
|
||||
// Assemblies known to be used for defining dynamic providers
|
||||
var knownAssemblies = new string [] {
|
||||
"Pulumi", "System.Collections.Immutable"
|
||||
};
|
||||
return Array.Exists(knownAssemblies, name => name == assembly.FullName);
|
||||
}
|
||||
|
||||
private static ResourceArgs SetProvider(DynamicResourceProvider provider, DynamicResourceArgs? args)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Pulumi.Serialization
|
|||
public static ImmutableDictionary<string, object?> DeserialiseProperties(Struct properties)
|
||||
{
|
||||
var output = Deserializer.Deserialize(Value.ForStruct(properties));
|
||||
if (!output.IsKnown || !output.IsSecret)
|
||||
if (!output.IsKnown || output.IsSecret)
|
||||
{
|
||||
throw new Exception("Deserialize of a Struct should always be known and not secret!");
|
||||
}
|
||||
|
|
|
@ -596,8 +596,9 @@ func TestAboutDotnet(t *testing.T) {
|
|||
func TestDynamicDotnet(t *testing.T) {
|
||||
var randomVal string
|
||||
integration.ProgramTest(t, &integration.ProgramTestOptions{
|
||||
Dir: filepath.Join("dynamic", "dotnet"),
|
||||
Dependencies: []string{"Pulumi"},
|
||||
PreviewCommandlineFlags: "-v9",
|
||||
Dir: filepath.Join("dynamic", "dotnet"),
|
||||
Dependencies: []string{"Pulumi"},
|
||||
ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
|
||||
randomVal = stack.Outputs["random_val"].(string)
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue