diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/schema/provider.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/helper/schema/provider.go | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/provider.go b/vendor/github.com/hashicorp/terraform/helper/schema/provider.go index fb28b41..6cd325d 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/provider.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/provider.go | |||
@@ -9,6 +9,7 @@ import ( | |||
9 | 9 | ||
10 | "github.com/hashicorp/go-multierror" | 10 | "github.com/hashicorp/go-multierror" |
11 | "github.com/hashicorp/terraform/config" | 11 | "github.com/hashicorp/terraform/config" |
12 | "github.com/hashicorp/terraform/config/configschema" | ||
12 | "github.com/hashicorp/terraform/terraform" | 13 | "github.com/hashicorp/terraform/terraform" |
13 | ) | 14 | ) |
14 | 15 | ||
@@ -58,7 +59,7 @@ type Provider struct { | |||
58 | 59 | ||
59 | meta interface{} | 60 | meta interface{} |
60 | 61 | ||
61 | // a mutex is required because TestReset can directly repalce the stopCtx | 62 | // a mutex is required because TestReset can directly replace the stopCtx |
62 | stopMu sync.Mutex | 63 | stopMu sync.Mutex |
63 | stopCtx context.Context | 64 | stopCtx context.Context |
64 | stopCtxCancel context.CancelFunc | 65 | stopCtxCancel context.CancelFunc |
@@ -185,6 +186,29 @@ func (p *Provider) TestReset() error { | |||
185 | return nil | 186 | return nil |
186 | } | 187 | } |
187 | 188 | ||
189 | // GetSchema implementation of terraform.ResourceProvider interface | ||
190 | func (p *Provider) GetSchema(req *terraform.ProviderSchemaRequest) (*terraform.ProviderSchema, error) { | ||
191 | resourceTypes := map[string]*configschema.Block{} | ||
192 | dataSources := map[string]*configschema.Block{} | ||
193 | |||
194 | for _, name := range req.ResourceTypes { | ||
195 | if r, exists := p.ResourcesMap[name]; exists { | ||
196 | resourceTypes[name] = r.CoreConfigSchema() | ||
197 | } | ||
198 | } | ||
199 | for _, name := range req.DataSources { | ||
200 | if r, exists := p.DataSourcesMap[name]; exists { | ||
201 | dataSources[name] = r.CoreConfigSchema() | ||
202 | } | ||
203 | } | ||
204 | |||
205 | return &terraform.ProviderSchema{ | ||
206 | Provider: schemaMap(p.Schema).CoreConfigSchema(), | ||
207 | ResourceTypes: resourceTypes, | ||
208 | DataSources: dataSources, | ||
209 | }, nil | ||
210 | } | ||
211 | |||
188 | // Input implementation of terraform.ResourceProvider interface. | 212 | // Input implementation of terraform.ResourceProvider interface. |
189 | func (p *Provider) Input( | 213 | func (p *Provider) Input( |
190 | input terraform.UIInput, | 214 | input terraform.UIInput, |
@@ -227,7 +251,7 @@ func (p *Provider) Configure(c *terraform.ResourceConfig) error { | |||
227 | 251 | ||
228 | // Get a ResourceData for this configuration. To do this, we actually | 252 | // Get a ResourceData for this configuration. To do this, we actually |
229 | // generate an intermediary "diff" although that is never exposed. | 253 | // generate an intermediary "diff" although that is never exposed. |
230 | diff, err := sm.Diff(nil, c) | 254 | diff, err := sm.Diff(nil, c, nil, p.meta) |
231 | if err != nil { | 255 | if err != nil { |
232 | return err | 256 | return err |
233 | } | 257 | } |
@@ -269,7 +293,7 @@ func (p *Provider) Diff( | |||
269 | return nil, fmt.Errorf("unknown resource type: %s", info.Type) | 293 | return nil, fmt.Errorf("unknown resource type: %s", info.Type) |
270 | } | 294 | } |
271 | 295 | ||
272 | return r.Diff(s, c) | 296 | return r.Diff(s, c, p.meta) |
273 | } | 297 | } |
274 | 298 | ||
275 | // Refresh implementation of terraform.ResourceProvider interface. | 299 | // Refresh implementation of terraform.ResourceProvider interface. |
@@ -305,6 +329,10 @@ func (p *Provider) Resources() []terraform.ResourceType { | |||
305 | result = append(result, terraform.ResourceType{ | 329 | result = append(result, terraform.ResourceType{ |
306 | Name: k, | 330 | Name: k, |
307 | Importable: resource.Importer != nil, | 331 | Importable: resource.Importer != nil, |
332 | |||
333 | // Indicates that a provider is compiled against a new enough | ||
334 | // version of core to support the GetSchema method. | ||
335 | SchemaAvailable: true, | ||
308 | }) | 336 | }) |
309 | } | 337 | } |
310 | 338 | ||
@@ -382,7 +410,7 @@ func (p *Provider) ReadDataDiff( | |||
382 | return nil, fmt.Errorf("unknown data source: %s", info.Type) | 410 | return nil, fmt.Errorf("unknown data source: %s", info.Type) |
383 | } | 411 | } |
384 | 412 | ||
385 | return r.Diff(nil, c) | 413 | return r.Diff(nil, c, p.meta) |
386 | } | 414 | } |
387 | 415 | ||
388 | // RefreshData implementation of terraform.ResourceProvider interface. | 416 | // RefreshData implementation of terraform.ResourceProvider interface. |
@@ -410,6 +438,10 @@ func (p *Provider) DataSources() []terraform.DataSource { | |||
410 | for _, k := range keys { | 438 | for _, k := range keys { |
411 | result = append(result, terraform.DataSource{ | 439 | result = append(result, terraform.DataSource{ |
412 | Name: k, | 440 | Name: k, |
441 | |||
442 | // Indicates that a provider is compiled against a new enough | ||
443 | // version of core to support the GetSchema method. | ||
444 | SchemaAvailable: true, | ||
413 | }) | 445 | }) |
414 | } | 446 | } |
415 | 447 | ||