mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
0b1dbf31a3
Currently Terraform is leaking goroutines and with that memory. I know strictly speaking this maybe isn’t a real concern for Terraform as it’s mostly used as a short running command line executable. But there are a few of us out there that are using Terraform in some long running processes and then this starts to become a problem. Next to that it’s of course good programming practise to clean up resources when they're not needed anymore. So even for the standard command line use case, this seems an improvement in resource management. Personally I see no downsides as the primary connection to the plugin is kept alive (the plugin is not killed) and only unused connections that will never be used again are closed to free up any related goroutines and memory.
35 lines
1.4 KiB
Go
35 lines
1.4 KiB
Go
package terraform
|
|
|
|
// ResourceProvisioner is an interface that must be implemented by any
|
|
// resource provisioner: the thing that initializes resources in
|
|
// a Terraform configuration.
|
|
type ResourceProvisioner interface {
|
|
// Validate is called once at the beginning with the raw
|
|
// configuration (no interpolation done) and can return a list of warnings
|
|
// and/or errors.
|
|
//
|
|
// This is called once per resource.
|
|
//
|
|
// This should not assume any of the values in the resource configuration
|
|
// are valid since it is possible they have to be interpolated still.
|
|
// The primary use case of this call is to check that the required keys
|
|
// are set and that the general structure is correct.
|
|
Validate(*ResourceConfig) ([]string, []error)
|
|
|
|
// Apply runs the provisioner on a specific resource and returns the new
|
|
// resource state along with an error. Instead of a diff, the ResourceConfig
|
|
// is provided since provisioners only run after a resource has been
|
|
// newly created.
|
|
Apply(UIOutput, *InstanceState, *ResourceConfig) error
|
|
}
|
|
|
|
// ResourceProvisionerCloser is an interface that provisioners that can close
|
|
// connections that aren't needed anymore must implement.
|
|
type ResourceProvisionerCloser interface {
|
|
Close() error
|
|
}
|
|
|
|
// ResourceProvisionerFactory is a function type that creates a new instance
|
|
// of a resource provisioner.
|
|
type ResourceProvisionerFactory func() (ResourceProvisioner, error)
|