diff options
author | Jake Champlin <jake@gnu.space> | 2017-06-09 17:54:32 +0000 |
---|---|---|
committer | Jake Champlin <jake@gnu.space> | 2017-06-09 17:54:32 +0000 |
commit | 9b12e4fe6f3c95986f1f3ec791636c58ca7e7583 (patch) | |
tree | 38f5f12bec0e488a12f0459a7356e6b7de7d8f84 /vendor/github.com/hashicorp/terraform/helper/schema | |
parent | cec3de8a3bcaffd21dedd1bf42da4b490cae7e16 (diff) | |
download | terraform-provider-statuscake-9b12e4fe6f3c95986f1f3ec791636c58ca7e7583.tar.gz terraform-provider-statuscake-9b12e4fe6f3c95986f1f3ec791636c58ca7e7583.tar.zst terraform-provider-statuscake-9b12e4fe6f3c95986f1f3ec791636c58ca7e7583.zip |
Transfer of provider code
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/schema')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go | 30 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/terraform/helper/schema/schema.go | 4 |
2 files changed, 30 insertions, 4 deletions
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go b/vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go index c1564a2..856c675 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go | |||
@@ -41,6 +41,10 @@ type Provisioner struct { | |||
41 | // information. | 41 | // information. |
42 | ApplyFunc func(ctx context.Context) error | 42 | ApplyFunc func(ctx context.Context) error |
43 | 43 | ||
44 | // ValidateFunc is a function for extended validation. This is optional | ||
45 | // and should be used when individual field validation is not enough. | ||
46 | ValidateFunc func(*ResourceData) ([]string, []error) | ||
47 | |||
44 | stopCtx context.Context | 48 | stopCtx context.Context |
45 | stopCtxCancel context.CancelFunc | 49 | stopCtxCancel context.CancelFunc |
46 | stopOnce sync.Once | 50 | stopOnce sync.Once |
@@ -117,8 +121,30 @@ func (p *Provisioner) Stop() error { | |||
117 | return nil | 121 | return nil |
118 | } | 122 | } |
119 | 123 | ||
120 | func (p *Provisioner) Validate(c *terraform.ResourceConfig) ([]string, []error) { | 124 | func (p *Provisioner) Validate(config *terraform.ResourceConfig) ([]string, []error) { |
121 | return schemaMap(p.Schema).Validate(c) | 125 | if err := p.InternalValidate(); err != nil { |
126 | return nil, []error{fmt.Errorf( | ||
127 | "Internal validation of the provisioner failed! This is always a bug\n"+ | ||
128 | "with the provisioner itself, and not a user issue. Please report\n"+ | ||
129 | "this bug:\n\n%s", err)} | ||
130 | } | ||
131 | w := []string{} | ||
132 | e := []error{} | ||
133 | if p.Schema != nil { | ||
134 | w2, e2 := schemaMap(p.Schema).Validate(config) | ||
135 | w = append(w, w2...) | ||
136 | e = append(e, e2...) | ||
137 | } | ||
138 | if p.ValidateFunc != nil { | ||
139 | data := &ResourceData{ | ||
140 | schema: p.Schema, | ||
141 | config: config, | ||
142 | } | ||
143 | w2, e2 := p.ValidateFunc(data) | ||
144 | w = append(w, w2...) | ||
145 | e = append(e, e2...) | ||
146 | } | ||
147 | return w, e | ||
122 | } | 148 | } |
123 | 149 | ||
124 | // Apply implementation of terraform.ResourceProvisioner interface. | 150 | // Apply implementation of terraform.ResourceProvisioner interface. |
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go index 32d1721..632672a 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/schema.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/schema.go | |||
@@ -1373,8 +1373,8 @@ func (m schemaMap) validateObject( | |||
1373 | k string, | 1373 | k string, |
1374 | schema map[string]*Schema, | 1374 | schema map[string]*Schema, |
1375 | c *terraform.ResourceConfig) ([]string, []error) { | 1375 | c *terraform.ResourceConfig) ([]string, []error) { |
1376 | raw, _ := c.GetRaw(k) | 1376 | raw, _ := c.Get(k) |
1377 | if _, ok := raw.(map[string]interface{}); !ok { | 1377 | if _, ok := raw.(map[string]interface{}); !ok && !c.IsComputed(k) { |
1378 | return nil, []error{fmt.Errorf( | 1378 | return nil, []error{fmt.Errorf( |
1379 | "%s: expected object, got %s", | 1379 | "%s: expected object, got %s", |
1380 | k, reflect.ValueOf(raw).Kind())} | 1380 | k, reflect.ValueOf(raw).Kind())} |