action

package
v1.16.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2025 License: MPL-2.0 Imports: 4 Imported by: 2

Documentation

Overview

TODO:Actions: Eventual package docs for actions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	// Schema should return the schema for this action.
	Schema(context.Context, SchemaRequest, *SchemaResponse)

	// Metadata should return the full name of the action, such as examplecloud_do_thing.
	Metadata(context.Context, MetadataRequest, *MetadataResponse)

	// Invoke is called to run the logic of the action and update linked resources if applicable.
	// Config, linked resource planned state, and linked resource prior state values should
	// be read from the InvokeRequest and new linked resource state values set on the InvokeResponse.
	//
	// The [InvokeResponse.SendProgress] function can be called in the Invoke method to immediately
	// report progress events related to the invocation of the action to Terraform.
	Invoke(context.Context, InvokeRequest, *InvokeResponse)
}

type ActionWithConfigure

type ActionWithConfigure interface {
	Action

	// Configure enables provider-level data or clients to be set in the
	// provider-defined Action type.
	Configure(context.Context, ConfigureRequest, *ConfigureResponse)
}

ActionWithConfigure is an interface type that extends Action to include a method which the framework will automatically call so provider developers have the opportunity to setup any necessary provider-level data or clients in the Action type.

type ActionWithModifyPlan

type ActionWithModifyPlan interface {
	Action

	// ModifyPlan is called when the provider has an opportunity to modify
	// the plan for an action: once during the plan phase, and once
	// during the apply phase with any unknown values from configuration
	// filled in with their final values.
	//
	// Actions do not have computed attributes that can be modified during the plan,
	// but linked and lifecycle actions can modify the plan of linked resources.
	//
	// All action schema types can use the plan as an opportunity to raise early
	// diagnostics to practitioners, such as validation errors.
	ModifyPlan(context.Context, ModifyPlanRequest, *ModifyPlanResponse)
}

ActionWithModifyPlan represents an action with a ModifyPlan function.

type ConfigureRequest

type ConfigureRequest struct {
	// ProviderData is the data set in the
	// [provider.ConfigureResponse.ActionData] field. This data is
	// provider-specifc and therefore can contain any necessary remote system
	// clients, custom provider data, or anything else pertinent to the
	// functionality of the Action.
	//
	// This data is only set after the ConfigureProvider RPC has been called
	// by Terraform.
	ProviderData any
}

ConfigureRequest represents a request for the provider to configure an action, i.e., set provider-level data or clients. An instance of this request struct is supplied as an argument to the Action type Configure method.

type ConfigureResponse

type ConfigureResponse struct {
	// Diagnostics report errors or warnings related to configuring of the
	// Datasource. An empty slice indicates a successful operation with no
	// warnings or errors generated.
	Diagnostics diag.Diagnostics
}

ConfigureResponse represents a response to a ConfigureRequest. An instance of this response struct is supplied as an argument to the Action type Configure method.

type Deferred

type Deferred struct {
	// Reason is the reason for deferring the change.
	Reason DeferredReason
}

Deferred is used to indicate to Terraform that a change needs to be deferred for a reason.

NOTE: This functionality is related to deferred action support, which is currently experimental and is subject to change or break without warning. It is not protected by version compatibility guarantees.

type DeferredReason

type DeferredReason int32

DeferredReason represents different reasons for deferring a change.

NOTE: This functionality is related to deferred action support, which is currently experimental and is subject to change or break without warning. It is not protected by version compatibility guarantees.

const (
	// DeferredReasonUnknown is used to indicate an invalid `DeferredReason`.
	// Provider developers should not use it.
	DeferredReasonUnknown DeferredReason = 0

	// DeferredReasonActionConfigUnknown is used to indicate that the action configuration
	// is partially unknown and the real values need to be known before the change can be planned.
	DeferredReasonActionConfigUnknown DeferredReason = 1

	// DeferredReasonProviderConfigUnknown is used to indicate that the provider configuration
	// is partially unknown and the real values need to be known before the change can be planned.
	DeferredReasonProviderConfigUnknown DeferredReason = 2

	// DeferredReasonAbsentPrereq is used to indicate that a hard dependency has not been satisfied.
	DeferredReasonAbsentPrereq DeferredReason = 3
)

func (DeferredReason) String

func (d DeferredReason) String() string

type InvokeProgressEvent

type InvokeProgressEvent struct {
	// Message is the string that will be presented to the practitioner either via the console
	// or an external system like HCP Terraform.
	Message string
}

InvokeProgressEvent is the event returned to Terraform while an action is being invoked.

type InvokeRequest

type InvokeRequest struct {
	// Config is the configuration the user supplied for the action.
	Config tfsdk.Config
}

InvokeRequest represents a request for the provider to invoke the action and update the requested action's linked resources.

type InvokeResponse

type InvokeResponse struct {
	// Diagnostics report errors or warnings related to invoking the action or updating
	// the state of the requested action's linked resources. Returning an empty slice
	// indicates a successful invocation with no warnings or errors
	// generated.
	Diagnostics diag.Diagnostics

	// SendProgress will immediately send a progress update to Terraform core during action invocation.
	// This function is provided by the framework and can be called multiple times while action logic is running.
	//
	// TODO:Actions: More documentation about when you should use this / when you shouldn't
	SendProgress func(event InvokeProgressEvent)
}

InvokeResponse represents a response to an InvokeRequest. An instance of this response struct is supplied as an argument to the action's Invoke function, in which the provider should set values on the InvokeResponse as appropriate.

type MetadataRequest

type MetadataRequest struct {
	// ProviderTypeName is the string returned from
	// [provider.MetadataResponse.TypeName], if the Provider type implements
	// the Metadata method. This string should prefix the Action type name
	// with an underscore in the response.
	ProviderTypeName string
}

MetadataRequest represents a request for the Action to return metadata, such as its type name. An instance of this request struct is supplied as an argument to the Action type Metadata method.

type MetadataResponse

type MetadataResponse struct {
	// TypeName should be the full action type, including the provider
	// type prefix and an underscore. For example, examplecloud_thing.
	TypeName string
}

MetadataResponse represents a response to a MetadataRequest. An instance of this response struct is supplied as an argument to the Action type Metadata method.

type ModifyPlanClientCapabilities

type ModifyPlanClientCapabilities struct {
	// DeferralAllowed indicates whether the Terraform client initiating
	// the request allows a deferral response.
	//
	// NOTE: This functionality is related to deferred action support, which is currently experimental and is subject
	// to change or break without warning. It is not protected by version compatibility guarantees.
	DeferralAllowed bool
}

ModifyPlanClientCapabilities allows Terraform to publish information regarding optionally supported protocol features for the PlanAction RPC, such as forward-compatible Terraform behavior changes.

type ModifyPlanRequest

type ModifyPlanRequest struct {
	// Config is the configuration the user supplied for the action.
	//
	// This configuration may contain unknown values if a user uses
	// interpolation or other functionality that would prevent Terraform
	// from knowing the value at request time.
	Config tfsdk.Config

	// ClientCapabilities defines optionally supported protocol features for the
	// PlanAction RPC, such as forward-compatible Terraform behavior changes.
	ClientCapabilities ModifyPlanClientCapabilities
}

ModifyPlanRequest represents a request for the provider to modify the planned new state that Terraform has generated for any linked resources.

type ModifyPlanResponse

type ModifyPlanResponse struct {
	// Diagnostics report errors or warnings related to determining the
	// planned state of the requested action's linked resources. Returning an empty slice
	// indicates a successful plan modification with no warnings or errors
	// generated.
	Diagnostics diag.Diagnostics

	// Deferred indicates that Terraform should defer planning this
	// action until a follow-up apply operation.
	//
	// This field can only be set if
	// `(action.ModifyPlanRequest).ClientCapabilities.DeferralAllowed` is true.
	//
	// NOTE: This functionality is related to deferred action support, which is currently experimental and is subject
	// to change or break without warning. It is not protected by version compatibility guarantees.
	Deferred *Deferred
}

ModifyPlanResponse represents a response to a ModifyPlanRequest. An instance of this response struct is supplied as an argument to the action's ModifyPlan function, in which the provider should modify the Plan of any linked resources as appropriate.

type SchemaRequest

type SchemaRequest struct{}

SchemaRequest represents a request for the Action to return its schema. An instance of this request struct is supplied as an argument to the Action type Schema method.

type SchemaResponse

type SchemaResponse struct {

	// Schema is the schema of the action.
	//
	// There are three different types of actions, which define how a practitioner can trigger an action,
	// as well as what effect the action can have on the state.
	//   - [schema.UnlinkedSchema] actions are actions that cannot cause changes to resource states.
	//   - [schema.LifecycleSchema] actions are actions that can cause changes to exactly one resource state.
	//   - [schema.LinkedSchema] actions are actions that can cause changes to one or more resource states.
	Schema schema.SchemaType

	// Diagnostics report errors or warnings related to retrieving the action schema.
	// An empty slice indicates success, with no warnings or errors generated.
	Diagnostics diag.Diagnostics
}

SchemaResponse represents a response to a SchemaRequest. An instance of this response struct is supplied as an argument to the Action type Schema method.

Directories

Path Synopsis
Package schema contains all available schema functionality for actions.
Package schema contains all available schema functionality for actions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL