add checks for timeouts attributes and blocks
Don't overwrite anything the provider defined, in order to maintain existing behavior. Change strings to pre-defined constants
This commit is contained in:
parent
e38a5a769d
commit
f153720a36
|
@ -172,48 +172,52 @@ func (r *Resource) CoreConfigSchema() *configschema.Block {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert configured timeout values into the schema
|
_, timeoutsAttr := block.Attributes[TimeoutsConfigKey]
|
||||||
if r.Timeouts != nil {
|
_, timeoutsBlock := block.BlockTypes[TimeoutsConfigKey]
|
||||||
|
|
||||||
|
// Insert configured timeout values into the schema, as long as the schema
|
||||||
|
// didn't define anything else by that name.
|
||||||
|
if r.Timeouts != nil && !timeoutsAttr && !timeoutsBlock {
|
||||||
timeouts := configschema.Block{
|
timeouts := configschema.Block{
|
||||||
Attributes: map[string]*configschema.Attribute{},
|
Attributes: map[string]*configschema.Attribute{},
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Timeouts.Create != nil {
|
if r.Timeouts.Create != nil {
|
||||||
timeouts.Attributes["create"] = &configschema.Attribute{
|
timeouts.Attributes[TimeoutCreate] = &configschema.Attribute{
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Timeouts.Read != nil {
|
if r.Timeouts.Read != nil {
|
||||||
timeouts.Attributes["read"] = &configschema.Attribute{
|
timeouts.Attributes[TimeoutRead] = &configschema.Attribute{
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Timeouts.Update != nil {
|
if r.Timeouts.Update != nil {
|
||||||
timeouts.Attributes["update"] = &configschema.Attribute{
|
timeouts.Attributes[TimeoutUpdate] = &configschema.Attribute{
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Timeouts.Delete != nil {
|
if r.Timeouts.Delete != nil {
|
||||||
timeouts.Attributes["delete"] = &configschema.Attribute{
|
timeouts.Attributes[TimeoutDelete] = &configschema.Attribute{
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Timeouts.Default != nil {
|
if r.Timeouts.Default != nil {
|
||||||
timeouts.Attributes["default"] = &configschema.Attribute{
|
timeouts.Attributes[TimeoutDefault] = &configschema.Attribute{
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
block.BlockTypes["timeouts"] = &configschema.NestedBlock{
|
block.BlockTypes[TimeoutsConfigKey] = &configschema.NestedBlock{
|
||||||
Nesting: configschema.NestingSingle,
|
Nesting: configschema.NestingSingle,
|
||||||
Block: timeouts,
|
Block: timeouts,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue