]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/zclconf/go-cty/cty/unknown.go
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / zclconf / go-cty / cty / unknown.go
CommitLineData
15c0b25d
AP
1package cty
2
3// unknownType is the placeholder type used for the sigil value representing
4// "Unknown", to make it unambigiously distinct from any other possible value.
5type unknownType struct {
6}
7
8// Unknown is a special value that can be
9var unknown interface{} = &unknownType{}
10
11// UnknownVal returns an Value that represents an unknown value of the given
12// type. Unknown values can be used to represent a value that is
13// not yet known. Its meaning is undefined in cty, but it could be used by
14// an calling application to allow partial evaluation.
15//
16// Unknown values of any type can be created of any type. All operations on
17// Unknown values themselves return Unknown.
18func UnknownVal(t Type) Value {
19 return Value{
20 ty: t,
21 v: unknown,
22 }
23}
24
25func (t unknownType) GoString() string {
26 // This is the stringification of our internal unknown marker. The
27 // stringification of the public representation of unknowns is in
28 // Value.GoString.
29 return "cty.unknown"
30}
31
32type pseudoTypeDynamic struct {
33 typeImplSigil
34}
35
36// DynamicPseudoType represents the dynamic pseudo-type.
37//
38// This type can represent situations where a type is not yet known. Its
39// meaning is undefined in cty, but it could be used by a calling
40// application to allow expression type checking with some types not yet known.
41// For example, the application might optimistically permit any operation on
42// values of this type in type checking, allowing a partial type-check result,
43// and then repeat the check when more information is known to get the
44// final, concrete type.
45//
46// It is a pseudo-type because it is used only as a sigil to the calling
47// application. "Unknown" is the only valid value of this pseudo-type, so
48// operations on values of this type will always short-circuit as per
49// the rules for that special value.
50var DynamicPseudoType Type
51
52func (t pseudoTypeDynamic) Equals(other Type) bool {
53 _, ok := other.typeImpl.(pseudoTypeDynamic)
54 return ok
55}
56
57func (t pseudoTypeDynamic) FriendlyName() string {
58 return "dynamic"
59}
60
61func (t pseudoTypeDynamic) GoString() string {
62 return "cty.DynamicPseudoType"
63}
64
65// DynamicVal is the only valid value of the pseudo-type dynamic.
66// This value can be used as a placeholder where a value or expression's
67// type and value are both unknown, thus allowing partial evaluation. See
68// the docs for DynamicPseudoType for more information.
69var DynamicVal Value
70
71func init() {
72 DynamicPseudoType = Type{
73 pseudoTypeDynamic{},
74 }
75 DynamicVal = Value{
76 ty: DynamicPseudoType,
77 v: unknown,
78 }
79}