terraform: ResourceProvider (shadow) CloseShadow closes all shadow
values
This commit is contained in:
parent
47f4343bf5
commit
62162427f4
|
@ -2,6 +2,7 @@ package terraform
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
|
@ -175,11 +176,33 @@ type shadowResourceProviderShared struct {
|
||||||
Refresh shadow.KeyedValue
|
Refresh shadow.KeyedValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *shadowResourceProviderShared) Close() error {
|
||||||
|
closers := []io.Closer{
|
||||||
|
&p.CloseErr, &p.Input, &p.Validate,
|
||||||
|
&p.Configure, &p.Apply, &p.Diff,
|
||||||
|
&p.Refresh,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, c := range closers {
|
||||||
|
// This should never happen, but we don't panic because a panic
|
||||||
|
// could affect the real behavior of Terraform and a shadow should
|
||||||
|
// never be able to do that.
|
||||||
|
if err := c.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (p *shadowResourceProviderShadow) CloseShadow() error {
|
func (p *shadowResourceProviderShadow) CloseShadow() error {
|
||||||
// For now, just return the error. What we need to do in the future
|
result := p.Error
|
||||||
// is marked the provider as "closed" so that any subsequent calls
|
if err := p.Shared.Close(); err != nil {
|
||||||
// will fail out.
|
result = multierror.Append(result, fmt.Errorf(
|
||||||
return p.Error
|
"close error: %s", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *shadowResourceProviderShadow) Resources() []ResourceType {
|
func (p *shadowResourceProviderShadow) Resources() []ResourceType {
|
||||||
|
|
Loading…
Reference in New Issue