Filter out internal properties when deserializing data (#3560)
This commit is contained in:
parent
eedd277cd7
commit
d7e93472b3
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2016-2019, Pulumi Corporation
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading.Tasks;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Pulumi.Serialization;
|
||||
using Xunit;
|
||||
|
||||
namespace Pulumi.Tests.Serialization
|
||||
{
|
||||
public class InternalPropertyTests : ConverterTests
|
||||
{
|
||||
[Fact]
|
||||
public void IgnoreInternalProperty()
|
||||
{
|
||||
var data = Converter.ConvertValue<ImmutableDictionary<string, string>>("", new Value
|
||||
{
|
||||
StructValue = new Struct
|
||||
{
|
||||
Fields =
|
||||
{
|
||||
{ "a", new Value { StringValue = "b" } },
|
||||
{ "__defaults", new Value { BoolValue = true } },
|
||||
}
|
||||
}
|
||||
});
|
||||
Assert.True(data.IsKnown);
|
||||
Assert.True(data.Value.ContainsKey("a"));
|
||||
Assert.Equal("b", data.Value["a"]);
|
||||
Assert.False(data.Value.ContainsKey("__defaults"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -75,6 +75,13 @@ namespace Pulumi.Serialization
|
|||
|
||||
foreach (var (key, element) in v.StructValue.Fields)
|
||||
{
|
||||
// Unilaterally skip properties considered internal by the Pulumi engine.
|
||||
// These don't actually contribute to the exposed shape of the object, do
|
||||
// not need to be passed back to the engine, and often will not match the
|
||||
// expected type we are deserializing into.
|
||||
if (key.StartsWith("__"))
|
||||
continue;
|
||||
|
||||
var elementData = Deserialize(element);
|
||||
(isKnown, isSecret) = OutputData.Combine(elementData, isKnown, isSecret);
|
||||
result.Add(key, elementData.Value);
|
||||
|
|
Loading…
Reference in a new issue