diff options
author | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
---|---|---|
committer | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
commit | 107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch) | |
tree | ca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/hashicorp/terraform/configs/configschema/schema.go | |
parent | 844b5a68d8af4791755b8f0ad293cc99f5959183 (diff) | |
download | terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip |
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/configs/configschema/schema.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/configs/configschema/schema.go | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/configs/configschema/schema.go b/vendor/github.com/hashicorp/terraform/configs/configschema/schema.go new file mode 100644 index 0000000..5a67334 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/configs/configschema/schema.go | |||
@@ -0,0 +1,130 @@ | |||
1 | package configschema | ||
2 | |||
3 | import ( | ||
4 | "github.com/zclconf/go-cty/cty" | ||
5 | ) | ||
6 | |||
7 | // Block represents a configuration block. | ||
8 | // | ||
9 | // "Block" here is a logical grouping construct, though it happens to map | ||
10 | // directly onto the physical block syntax of Terraform's native configuration | ||
11 | // syntax. It may be a more a matter of convention in other syntaxes, such as | ||
12 | // JSON. | ||
13 | // | ||
14 | // When converted to a value, a Block always becomes an instance of an object | ||
15 | // type derived from its defined attributes and nested blocks | ||
16 | type Block struct { | ||
17 | // Attributes describes any attributes that may appear directly inside | ||
18 | // the block. | ||
19 | Attributes map[string]*Attribute | ||
20 | |||
21 | // BlockTypes describes any nested block types that may appear directly | ||
22 | // inside the block. | ||
23 | BlockTypes map[string]*NestedBlock | ||
24 | } | ||
25 | |||
26 | // Attribute represents a configuration attribute, within a block. | ||
27 | type Attribute struct { | ||
28 | // Type is a type specification that the attribute's value must conform to. | ||
29 | Type cty.Type | ||
30 | |||
31 | // Description is an English-language description of the purpose and | ||
32 | // usage of the attribute. A description should be concise and use only | ||
33 | // one or two sentences, leaving full definition to longer-form | ||
34 | // documentation defined elsewhere. | ||
35 | Description string | ||
36 | |||
37 | // Required, if set to true, specifies that an omitted or null value is | ||
38 | // not permitted. | ||
39 | Required bool | ||
40 | |||
41 | // Optional, if set to true, specifies that an omitted or null value is | ||
42 | // permitted. This field conflicts with Required. | ||
43 | Optional bool | ||
44 | |||
45 | // Computed, if set to true, specifies that the value comes from the | ||
46 | // provider rather than from configuration. If combined with Optional, | ||
47 | // then the config may optionally provide an overridden value. | ||
48 | Computed bool | ||
49 | |||
50 | // Sensitive, if set to true, indicates that an attribute may contain | ||
51 | // sensitive information. | ||
52 | // | ||
53 | // At present nothing is done with this information, but callers are | ||
54 | // encouraged to set it where appropriate so that it may be used in the | ||
55 | // future to help Terraform mask sensitive information. (Terraform | ||
56 | // currently achieves this in a limited sense via other mechanisms.) | ||
57 | Sensitive bool | ||
58 | } | ||
59 | |||
60 | // NestedBlock represents the embedding of one block within another. | ||
61 | type NestedBlock struct { | ||
62 | // Block is the description of the block that's nested. | ||
63 | Block | ||
64 | |||
65 | // Nesting provides the nesting mode for the child block, which determines | ||
66 | // how many instances of the block are allowed, how many labels it expects, | ||
67 | // and how the resulting data will be converted into a data structure. | ||
68 | Nesting NestingMode | ||
69 | |||
70 | // MinItems and MaxItems set, for the NestingList and NestingSet nesting | ||
71 | // modes, lower and upper limits on the number of child blocks allowed | ||
72 | // of the given type. If both are left at zero, no limit is applied. | ||
73 | // | ||
74 | // As a special case, both values can be set to 1 for NestingSingle in | ||
75 | // order to indicate that a particular single block is required. | ||
76 | // | ||
77 | // These fields are ignored for other nesting modes and must both be left | ||
78 | // at zero. | ||
79 | MinItems, MaxItems int | ||
80 | } | ||
81 | |||
82 | // NestingMode is an enumeration of modes for nesting blocks inside other | ||
83 | // blocks. | ||
84 | type NestingMode int | ||
85 | |||
86 | //go:generate stringer -type=NestingMode | ||
87 | |||
88 | const ( | ||
89 | nestingModeInvalid NestingMode = iota | ||
90 | |||
91 | // NestingSingle indicates that only a single instance of a given | ||
92 | // block type is permitted, with no labels, and its content should be | ||
93 | // provided directly as an object value. | ||
94 | NestingSingle | ||
95 | |||
96 | // NestingGroup is similar to NestingSingle in that it calls for only a | ||
97 | // single instance of a given block type with no labels, but it additonally | ||
98 | // guarantees that its result will never be null, even if the block is | ||
99 | // absent, and instead the nested attributes and blocks will be treated | ||
100 | // as absent in that case. (Any required attributes or blocks within the | ||
101 | // nested block are not enforced unless the block is explicitly present | ||
102 | // in the configuration, so they are all effectively optional when the | ||
103 | // block is not present.) | ||
104 | // | ||
105 | // This is useful for the situation where a remote API has a feature that | ||
106 | // is always enabled but has a group of settings related to that feature | ||
107 | // that themselves have default values. By using NestingGroup instead of | ||
108 | // NestingSingle in that case, generated plans will show the block as | ||
109 | // present even when not present in configuration, thus allowing any | ||
110 | // default values within to be displayed to the user. | ||
111 | NestingGroup | ||
112 | |||
113 | // NestingList indicates that multiple blocks of the given type are | ||
114 | // permitted, with no labels, and that their corresponding objects should | ||
115 | // be provided in a list. | ||
116 | NestingList | ||
117 | |||
118 | // NestingSet indicates that multiple blocks of the given type are | ||
119 | // permitted, with no labels, and that their corresponding objects should | ||
120 | // be provided in a set. | ||
121 | NestingSet | ||
122 | |||
123 | // NestingMap indicates that multiple blocks of the given type are | ||
124 | // permitted, each with a single label, and that their corresponding | ||
125 | // objects should be provided in a map whose keys are the labels. | ||
126 | // | ||
127 | // It's an error, therefore, to use the same label value on multiple | ||
128 | // blocks. | ||
129 | NestingMap | ||
130 | ) | ||