diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go b/vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go index 856c675..476192e 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go | |||
@@ -43,7 +43,7 @@ type Provisioner struct { | |||
43 | 43 | ||
44 | // ValidateFunc is a function for extended validation. This is optional | 44 | // ValidateFunc is a function for extended validation. This is optional |
45 | // and should be used when individual field validation is not enough. | 45 | // and should be used when individual field validation is not enough. |
46 | ValidateFunc func(*ResourceData) ([]string, []error) | 46 | ValidateFunc func(*terraform.ResourceConfig) ([]string, []error) |
47 | 47 | ||
48 | stopCtx context.Context | 48 | stopCtx context.Context |
49 | stopCtxCancel context.CancelFunc | 49 | stopCtxCancel context.CancelFunc |
@@ -121,32 +121,6 @@ func (p *Provisioner) Stop() error { | |||
121 | return nil | 121 | return nil |
122 | } | 122 | } |
123 | 123 | ||
124 | func (p *Provisioner) Validate(config *terraform.ResourceConfig) ([]string, []error) { | ||
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 | ||
148 | } | ||
149 | |||
150 | // Apply implementation of terraform.ResourceProvisioner interface. | 124 | // Apply implementation of terraform.ResourceProvisioner interface. |
151 | func (p *Provisioner) Apply( | 125 | func (p *Provisioner) Apply( |
152 | o terraform.UIOutput, | 126 | o terraform.UIOutput, |
@@ -204,3 +178,27 @@ func (p *Provisioner) Apply( | |||
204 | ctx = context.WithValue(ctx, ProvRawStateKey, s) | 178 | ctx = context.WithValue(ctx, ProvRawStateKey, s) |
205 | return p.ApplyFunc(ctx) | 179 | return p.ApplyFunc(ctx) |
206 | } | 180 | } |
181 | |||
182 | // Validate implements the terraform.ResourceProvisioner interface. | ||
183 | func (p *Provisioner) Validate(c *terraform.ResourceConfig) (ws []string, es []error) { | ||
184 | if err := p.InternalValidate(); err != nil { | ||
185 | return nil, []error{fmt.Errorf( | ||
186 | "Internal validation of the provisioner failed! This is always a bug\n"+ | ||
187 | "with the provisioner itself, and not a user issue. Please report\n"+ | ||
188 | "this bug:\n\n%s", err)} | ||
189 | } | ||
190 | |||
191 | if p.Schema != nil { | ||
192 | w, e := schemaMap(p.Schema).Validate(c) | ||
193 | ws = append(ws, w...) | ||
194 | es = append(es, e...) | ||
195 | } | ||
196 | |||
197 | if p.ValidateFunc != nil { | ||
198 | w, e := p.ValidateFunc(c) | ||
199 | ws = append(ws, w...) | ||
200 | es = append(es, e...) | ||
201 | } | ||
202 | |||
203 | return ws, es | ||
204 | } | ||