aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go')
-rw-r--r--vendor/github.com/hashicorp/terraform/helper/schema/provisioner.go30
1 files changed, 28 insertions, 2 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
120func (p *Provisioner) Validate(c *terraform.ResourceConfig) ([]string, []error) { 124func (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.