github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/legacy/terraform/resource_provisioner.go (about)

     1  package terraform
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/internal/configs/configschema"
     5  	"github.com/hashicorp/terraform/internal/provisioners"
     6  )
     7  
     8  // ResourceProvisioner is an interface that must be implemented by any
     9  // resource provisioner: the thing that initializes resources in
    10  // a Terraform configuration.
    11  type ResourceProvisioner interface {
    12  	// GetConfigSchema returns the schema for the provisioner type's main
    13  	// configuration block. This is called prior to Validate to enable some
    14  	// basic structural validation to be performed automatically and to allow
    15  	// the configuration to be properly extracted from potentially-ambiguous
    16  	// configuration file formats.
    17  	GetConfigSchema() (*configschema.Block, error)
    18  
    19  	// Validate is called once at the beginning with the raw
    20  	// configuration (no interpolation done) and can return a list of warnings
    21  	// and/or errors.
    22  	//
    23  	// This is called once per resource.
    24  	//
    25  	// This should not assume any of the values in the resource configuration
    26  	// are valid since it is possible they have to be interpolated still.
    27  	// The primary use case of this call is to check that the required keys
    28  	// are set and that the general structure is correct.
    29  	Validate(*ResourceConfig) ([]string, []error)
    30  
    31  	// Apply runs the provisioner on a specific resource and returns an error.
    32  	// Instead of a diff, the ResourceConfig is provided since provisioners
    33  	// only run after a resource has been newly created.
    34  	Apply(UIOutput, *InstanceState, *ResourceConfig) error
    35  
    36  	// Stop is called when the provisioner should halt any in-flight actions.
    37  	//
    38  	// This can be used to make a nicer Ctrl-C experience for Terraform.
    39  	// Even if this isn't implemented to do anything (just returns nil),
    40  	// Terraform will still cleanly stop after the currently executing
    41  	// graph node is complete. However, this API can be used to make more
    42  	// efficient halts.
    43  	//
    44  	// Stop doesn't have to and shouldn't block waiting for in-flight actions
    45  	// to complete. It should take any action it wants and return immediately
    46  	// acknowledging it has received the stop request. Terraform core will
    47  	// automatically not make any further API calls to the provider soon
    48  	// after Stop is called (technically exactly once the currently executing
    49  	// graph nodes are complete).
    50  	//
    51  	// The error returned, if non-nil, is assumed to mean that signaling the
    52  	// stop somehow failed and that the user should expect potentially waiting
    53  	// a longer period of time.
    54  	Stop() error
    55  }
    56  
    57  // ResourceProvisionerCloser is an interface that provisioners that can close
    58  // connections that aren't needed anymore must implement.
    59  type ResourceProvisionerCloser interface {
    60  	Close() error
    61  }
    62  
    63  // ResourceProvisionerFactory is a function type that creates a new instance
    64  // of a resource provisioner.
    65  type ResourceProvisionerFactory func() (ResourceProvisioner, error)
    66  
    67  // ProvisionerFactory is a function type that creates a new instance
    68  // of a provisioners.Interface.
    69  type ProvisionerFactory = provisioners.Factory