Documentation ¶
Index ¶
- type ApplyResult
- type CallbackFn
- type FileProducer
- type FileProducerOption
- type NoOpProviderRunner
- type Operation
- type PlanResult
- type ProviderConfiguration
- type ProviderRequirement
- type ProviderRunner
- type RefreshResult
- type Setup
- type SetupFn
- type SharedGRPCRunnerOption
- type SharedProvider
- type StoreCleaner
- type Workspace
- func (w *Workspace) Apply(ctx context.Context) (ApplyResult, error)
- func (w *Workspace) ApplyAsync(callback CallbackFn) error
- func (w *Workspace) Destroy(ctx context.Context) error
- func (w *Workspace) DestroyAsync(callback CallbackFn) error
- func (w *Workspace) Plan(ctx context.Context) (PlanResult, error)
- func (w *Workspace) Refresh(ctx context.Context) (RefreshResult, error)
- type WorkspaceFinalizer
- type WorkspaceOption
- type WorkspaceStore
- type WorkspaceStoreOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplyResult ¶
ApplyResult contains the state after the apply operation.
type CallbackFn ¶
CallbackFn is the type of accepted function that can be called after an async operation is completed.
type FileProducer ¶
type FileProducer struct { Resource resource.Terraformed Setup Setup Dir string Config *config.Resource // contains filtered or unexported fields }
FileProducer exist to serve as cache for the data that is costly to produce every time like parameters and observation maps.
func NewFileProducer ¶
func NewFileProducer(ctx context.Context, client resource.SecretClient, dir string, tr resource.Terraformed, ts Setup, cfg *config.Resource, opts ...FileProducerOption) (*FileProducer, error)
NewFileProducer returns a new FileProducer.
func (*FileProducer) WriteMainTF ¶
func (fp *FileProducer) WriteMainTF() error
WriteMainTF writes the content main configuration file that has the desired state configuration for Terraform.
func (*FileProducer) WriteTFState ¶
func (fp *FileProducer) WriteTFState(ctx context.Context) error
WriteTFState writes the Terraform state that should exist in the filesystem to start any Terraform operation.
type FileProducerOption ¶
type FileProducerOption func(*FileProducer)
FileProducerOption allows you to configure FileProducer
func WithFileSystem ¶
func WithFileSystem(fs afero.Fs) FileProducerOption
WithFileSystem configures the filesystem to use. Used mostly for testing.
type NoOpProviderRunner ¶
type NoOpProviderRunner struct{}
NoOpProviderRunner is a no-op ProviderRunner
func NewNoOpProviderRunner ¶
func NewNoOpProviderRunner() NoOpProviderRunner
NewNoOpProviderRunner constructs a new NoOpProviderRunner
func (NoOpProviderRunner) Start ¶
func (NoOpProviderRunner) Start() (string, error)
Start takes no action
type Operation ¶
type Operation struct { Type string // contains filtered or unexported fields }
Operation is the representation of a single Terraform CLI operation.
func (*Operation) IsEnded ¶
IsEnded returns whether the operation has ended, regardless of its result.
type PlanResult ¶
PlanResult returns a summary of comparison between desired and current state of the resource.
type ProviderConfiguration ¶
type ProviderConfiguration map[string]interface{}
ProviderConfiguration holds the setup configuration body
type ProviderRequirement ¶
ProviderRequirement holds values for the Terraform HCL setup requirements
type ProviderRunner ¶
ProviderRunner is the interface for running Terraform native provider processes in the shared gRPC server mode
type RefreshResult ¶
RefreshResult contains information about the current state of the resource.
type Setup ¶
type Setup struct { Version string Requirement ProviderRequirement Configuration ProviderConfiguration Env []string }
Setup holds values for the Terraform version and setup requirements and configuration body
type SetupFn ¶
SetupFn is a function that returns Terraform setup which contains provider requirement, configuration and Terraform version.
type SharedGRPCRunnerOption ¶
type SharedGRPCRunnerOption func(runner *SharedProvider)
SharedGRPCRunnerOption lets you configure the shared gRPC runner.
func WithNativeProviderArgs ¶
func WithNativeProviderArgs(args ...string) SharedGRPCRunnerOption
WithNativeProviderArgs are the arguments to be passed to the native provider
func WithNativeProviderExecutor ¶
func WithNativeProviderExecutor(e exec.Interface) SharedGRPCRunnerOption
WithNativeProviderExecutor sets the process executor to be used
func WithProtocolVersion ¶
func WithProtocolVersion(protocolVersion int) SharedGRPCRunnerOption
WithProtocolVersion sets the gRPC protocol version in use between the Terraform CLI and the native provider.
type SharedProvider ¶
type SharedProvider struct {
// contains filtered or unexported fields
}
SharedProvider runs the configured native provider plugin using the supplied command-line args
func NewSharedProvider ¶
func NewSharedProvider(l logging.Logger, nativeProviderPath, nativeProviderName string, opts ...SharedGRPCRunnerOption) *SharedProvider
NewSharedProvider instantiates a SharedProvider with an OS executor using the supplied logger
func (*SharedProvider) Start ¶
func (sr *SharedProvider) Start() (string, error)
Start starts a shared gRPC server if not already running A logger, native provider's path and command-line arguments to be passed to it must have been properly configured. Returns any errors encountered and the reattachment configuration for the native provider.
type StoreCleaner ¶
type StoreCleaner interface {
Remove(obj xpresource.Object) error
}
StoreCleaner is the interface that the workspace finalizer needs to work with.
type Workspace ¶
type Workspace struct { // LastOperation contains information about the last operation performed. LastOperation *Operation // contains filtered or unexported fields }
Workspace runs Terraform operations in its directory and holds the information about their statuses.
func NewWorkspace ¶
func NewWorkspace(dir string, opts ...WorkspaceOption) *Workspace
NewWorkspace returns a new Workspace object that operates in the given directory.
func (*Workspace) Apply ¶
func (w *Workspace) Apply(ctx context.Context) (ApplyResult, error)
Apply makes a blocking terraform apply call.
func (*Workspace) ApplyAsync ¶
func (w *Workspace) ApplyAsync(callback CallbackFn) error
ApplyAsync makes a terraform apply call without blocking and calls the given function once that apply call finishes.
func (*Workspace) DestroyAsync ¶
func (w *Workspace) DestroyAsync(callback CallbackFn) error
DestroyAsync makes a non-blocking terraform destroy call. It doesn't accept a callback because destroy operations are not time sensitive as ApplyAsync where you might need to store the server-side computed information as soon as possible.
type WorkspaceFinalizer ¶
type WorkspaceFinalizer struct { xpresource.Finalizer Store StoreCleaner }
WorkspaceFinalizer removes the workspace from the workspace store and only then calls RemoveFinalizer of the underlying Finalizer.
func NewWorkspaceFinalizer ¶
func NewWorkspaceFinalizer(ws StoreCleaner, af xpresource.Finalizer) *WorkspaceFinalizer
NewWorkspaceFinalizer returns a new WorkspaceFinalizer.
func (*WorkspaceFinalizer) AddFinalizer ¶
func (wf *WorkspaceFinalizer) AddFinalizer(ctx context.Context, obj xpresource.Object) error
AddFinalizer to the supplied Managed resource.
func (*WorkspaceFinalizer) RemoveFinalizer ¶
func (wf *WorkspaceFinalizer) RemoveFinalizer(ctx context.Context, obj xpresource.Object) error
RemoveFinalizer removes the workspace from workspace store before removing the finalizer.
type WorkspaceOption ¶
type WorkspaceOption func(*Workspace)
WorkspaceOption allows you to configure Workspace objects.
func WithAferoFs ¶
func WithAferoFs(fs afero.Fs) WorkspaceOption
WithAferoFs lets you set the fs of WorkspaceStore.
func WithExecutor ¶
func WithExecutor(e k8sExec.Interface) WorkspaceOption
WithExecutor sets the executor of Workspace.
func WithLastOperation ¶
func WithLastOperation(lo *Operation) WorkspaceOption
WithLastOperation sets the Last Operation of Workspace.
func WithLogger ¶
func WithLogger(l logging.Logger) WorkspaceOption
WithLogger sets the logger of Workspace.
type WorkspaceStore ¶
type WorkspaceStore struct {
// contains filtered or unexported fields
}
WorkspaceStore allows you to manage multiple Terraform workspaces.
func NewWorkspaceStore ¶
func NewWorkspaceStore(l logging.Logger, opts ...WorkspaceStoreOption) *WorkspaceStore
NewWorkspaceStore returns a new WorkspaceStore.
func (*WorkspaceStore) Remove ¶
func (ws *WorkspaceStore) Remove(obj xpresource.Object) error
Remove deletes the workspace directory from the filesystem and erases its record from the store.
func (*WorkspaceStore) Workspace ¶
func (ws *WorkspaceStore) Workspace(ctx context.Context, c resource.SecretClient, tr resource.Terraformed, ts Setup, cfg *config.Resource) (*Workspace, error)
Workspace makes sure the Terraform workspace for the given resource is ready to be used and returns the Workspace object configured to work in that workspace folder in the filesystem.
type WorkspaceStoreOption ¶
type WorkspaceStoreOption func(*WorkspaceStore)
WorkspaceStoreOption lets you configure the workspace store.
func WithFs ¶
func WithFs(fs afero.Fs) WorkspaceStoreOption
WithFs lets you set the fs of WorkspaceStore. Used mostly for testing.
func WithProviderRunner ¶
func WithProviderRunner(pr ProviderRunner) WorkspaceStoreOption
WithProviderRunner sets the ProviderRunner to be used.