-
Notifications
You must be signed in to change notification settings - Fork 91
/
value.go
54 lines (42 loc) · 1.63 KB
/
value.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package attr
import (
"context"
"github.com/hashicorp/terraform-plugin-go/tftypes"
)
const (
// UnknownValueString should be returned by Value.String() implementations,
// when Value.IsUnknown() returns true.
UnknownValueString = "<unknown>"
// NullValueString should be returned by Value.String() implementations
// when Value.IsNull() returns true.
NullValueString = "<null>"
)
// Value defines an interface for describing data associated with an attribute.
// Values allow provider developers to specify data in a convenient format, and
// have it transparently be converted to formats Terraform understands.
type Value interface {
// Type returns the Type that created the Value.
Type(context.Context) Type
// ToTerraformValue returns the data contained in the Value as
// a tftypes.Value.
ToTerraformValue(context.Context) (tftypes.Value, error)
// Equal must return true if the Value is considered semantically equal
// to the Value passed as an argument.
Equal(Value) bool
// IsNull returns true if the Value is not set, or is explicitly set to null.
IsNull() bool
// IsUnknown returns true if the value is not yet known.
IsUnknown() bool
// String returns a summary representation of either the underlying Value,
// or UnknownValueString (`<unknown>`) when IsUnknown() returns true,
// or NullValueString (`<null>`) when IsNull() return true.
//
// This is an intentionally lossy representation, that are best suited for
// logging and error reporting, as they are not protected by
// compatibility guarantees within the framework.
String() string
FrameworkValue
}
type FrameworkValue interface {
ToFrameworkValue() Value
}