aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/zclconf/go-cty/cty/type.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/zclconf/go-cty/cty/type.go')
-rw-r--r--vendor/github.com/zclconf/go-cty/cty/type.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/vendor/github.com/zclconf/go-cty/cty/type.go b/vendor/github.com/zclconf/go-cty/cty/type.go
index ae5f1c8..730cb98 100644
--- a/vendor/github.com/zclconf/go-cty/cty/type.go
+++ b/vendor/github.com/zclconf/go-cty/cty/type.go
@@ -19,7 +19,7 @@ type typeImpl interface {
19 19
20 // FriendlyName returns a human-friendly *English* name for the given 20 // FriendlyName returns a human-friendly *English* name for the given
21 // type. 21 // type.
22 FriendlyName() string 22 FriendlyName(mode friendlyTypeNameMode) string
23 23
24 // GoString implements the GoStringer interface from package fmt. 24 // GoString implements the GoStringer interface from package fmt.
25 GoString() string 25 GoString() string
@@ -41,7 +41,25 @@ func (t Type) Equals(other Type) bool {
41 41
42// FriendlyName returns a human-friendly *English* name for the given type. 42// FriendlyName returns a human-friendly *English* name for the given type.
43func (t Type) FriendlyName() string { 43func (t Type) FriendlyName() string {
44 return t.typeImpl.FriendlyName() 44 return t.typeImpl.FriendlyName(friendlyTypeName)
45}
46
47// FriendlyNameForConstraint is similar to FriendlyName except that the
48// result is specialized for describing type _constraints_ rather than types
49// themselves. This is more appropriate when reporting that a particular value
50// does not conform to an expected type constraint.
51//
52// In particular, this function uses the term "any type" to refer to
53// cty.DynamicPseudoType, rather than "dynamic" as returned by FriendlyName.
54func (t Type) FriendlyNameForConstraint() string {
55 return t.typeImpl.FriendlyName(friendlyTypeConstraintName)
56}
57
58// friendlyNameMode is an internal combination of the various FriendlyName*
59// variants that just directly takes a mode, for easy passthrough for
60// recursive name construction.
61func (t Type) friendlyNameMode(mode friendlyTypeNameMode) string {
62 return t.typeImpl.FriendlyName(mode)
45} 63}
46 64
47// GoString returns a string approximating how the receiver type would be 65// GoString returns a string approximating how the receiver type would be
@@ -93,3 +111,10 @@ func (t Type) HasDynamicTypes() bool {
93 panic("HasDynamicTypes does not support the given type") 111 panic("HasDynamicTypes does not support the given type")
94 } 112 }
95} 113}
114
115type friendlyTypeNameMode rune
116
117const (
118 friendlyTypeName friendlyTypeNameMode = 'N'
119 friendlyTypeConstraintName friendlyTypeNameMode = 'C'
120)