controller

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Base64DecodeFunc = function.New(&function.Spec{
	Params: []function.Parameter{
		{
			Name:        "str",
			Type:        cty.String,
			AllowMarked: true,
		},
	},
	Type: function.StaticReturnType(cty.String),
	Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
		str, strMarks := args[0].Unmark()
		s := str.AsString()
		sDec, err := base64.StdEncoding.DecodeString(s)
		if err != nil {
			return cty.UnknownVal(cty.String), fmt.Errorf("failed to decode base64 data %s", s)
		}
		if !utf8.Valid(sDec) {
			log.Printf("[DEBUG] the result of decoding the provided string is not valid UTF-8: %s", s)
			return cty.UnknownVal(cty.String), fmt.Errorf("the result of decoding the provided string is not valid UTF-8")
		}
		return cty.StringVal(string(sDec)).WithMarks(strMarks), nil
	},
})
View Source
var Base64EncodeFunc = function.New(&function.Spec{
	Params: []function.Parameter{
		{
			Name: "str",
			Type: cty.String,
		},
	},
	Type: function.StaticReturnType(cty.String),
	Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
		return cty.StringVal(base64.StdEncoding.EncodeToString([]byte(args[0].AsString()))), nil
	},
})

Functions

This section is empty.

Types

type APICallbacks

type APICallbacks struct {
	// contains filtered or unexported fields
}

APICallbacks providers callbacks that work on API resources.

func NewAPICallbacks

func NewAPICallbacks(m ctrl.Manager, of xpresource.ManagedKind, opts ...APICallbacksOption) *APICallbacks

NewAPICallbacks returns a new APICallbacks.

func (*APICallbacks) Create

func (ac *APICallbacks) Create(name string) terraform.CallbackFn

Create makes sure the error is saved in async operation condition.

func (*APICallbacks) Destroy

func (ac *APICallbacks) Destroy(name string) terraform.CallbackFn

Destroy makes sure the error is saved in async operation condition.

func (*APICallbacks) Update

func (ac *APICallbacks) Update(name string) terraform.CallbackFn

Update makes sure the error is saved in async operation condition.

type APICallbacksOption

type APICallbacksOption func(callbacks *APICallbacks)

APICallbacksOption represents a configurable option for the APICallbacks

func WithEventHandler

func WithEventHandler(e *handler.EventHandler) APICallbacksOption

WithEventHandler sets the EventHandler for the APICallbacks so that the APICallbacks instance can requeue reconcile requests in the context of the asynchronous operations.

func WithStatusUpdates

func WithStatusUpdates(enabled bool) APICallbacksOption

WithStatusUpdates sets whether the LastAsyncOperation status condition is enabled. If set to false, APICallbacks will not use the LastAsyncOperation status condition for reporting ongoing async operations or errors. Error conditions will still be reported as usual in the `Synced` status condition.

type APISecretClient

type APISecretClient struct {
	// contains filtered or unexported fields
}

APISecretClient is a client for getting k8s secrets

func (*APISecretClient) GetSecretData

func (a *APISecretClient) GetSecretData(ctx context.Context, ref *xpv1.SecretReference) (map[string][]byte, error)

GetSecretData gets and returns data for the referenced secret

func (*APISecretClient) GetSecretValue

func (a *APISecretClient) GetSecretValue(ctx context.Context, sel xpv1.SecretKeySelector) ([]byte, error)

GetSecretValue gets and returns value for key of the referenced secret

type CallbackProvider

type CallbackProvider interface {
	Create(name string) terraform.CallbackFn
	Update(name string) terraform.CallbackFn
	Destroy(name string) terraform.CallbackFn
}

CallbackProvider provides functions that can be called with the result of async operations.

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

Connector initializes the external client with credentials and other configuration parameters.

func NewConnector

func NewConnector(kube client.Client, ws Store, sf terraform.SetupFn, cfg *config.Resource, opts ...Option) *Connector

NewConnector returns a new Connector object.

func (*Connector) Connect

Connect makes sure the underlying client is ready to issue requests to the provider API.

type OperationTrackerFinalizer

type OperationTrackerFinalizer struct {
	xpresource.Finalizer
	OperationStore TrackerCleaner
}

OperationTrackerFinalizer removes the operation tracker from the workspace store and only then calls RemoveFinalizer of the underlying Finalizer.

func NewOperationTrackerFinalizer

func NewOperationTrackerFinalizer(tc TrackerCleaner, af xpresource.Finalizer) *OperationTrackerFinalizer

NewOperationTrackerFinalizer returns a new OperationTrackerFinalizer.

func (*OperationTrackerFinalizer) AddFinalizer

func (nf *OperationTrackerFinalizer) AddFinalizer(ctx context.Context, obj xpresource.Object) error

AddFinalizer to the supplied Managed resource.

func (*OperationTrackerFinalizer) RemoveFinalizer

func (nf *OperationTrackerFinalizer) RemoveFinalizer(ctx context.Context, obj xpresource.Object) error

RemoveFinalizer removes the workspace from workspace store before removing the finalizer.

type Option

type Option func(*Connector)

Option allows you to configure Connector.

func WithCallbackProvider

func WithCallbackProvider(ac CallbackProvider) Option

WithCallbackProvider configures the controller to use async variant of the functions of the Terraform client and run given callbacks once those operations are completed.

func WithConnectorEventHandler

func WithConnectorEventHandler(e *handler.EventHandler) Option

WithConnectorEventHandler configures the EventHandler so that the external clients can requeue reconciliation requests.

func WithLogger

func WithLogger(l logging.Logger) Option

WithLogger configures a logger for the Connector.

type ProviderSharer

type ProviderSharer interface {
	UseProvider(inuse terraform.InUse, attachmentConfig string)
}

ProviderSharer shares a native provider process with the receiver.

type Resource

type Resource interface {
	Apply(ctx context.Context, s *tf.InstanceState, d *tf.InstanceDiff, meta interface{}) (*tf.InstanceState, tfdiag.Diagnostics)
	RefreshWithoutUpgrade(ctx context.Context, s *tf.InstanceState, meta interface{}) (*tf.InstanceState, tfdiag.Diagnostics)
}

type Store

type Store interface {
	Workspace(ctx context.Context, c resource.SecretClient, tr resource.Terraformed, ts terraform.Setup, cfg *config.Resource) (*terraform.Workspace, error)
}

Store is where we can get access to the Terraform workspace of given resource.

type TerraformPluginFrameworkAsyncConnector

type TerraformPluginFrameworkAsyncConnector struct {
	*TerraformPluginFrameworkConnector
	// contains filtered or unexported fields
}

TerraformPluginFrameworkAsyncConnector is a managed reconciler Connecter implementation for reconciling Terraform plugin framework based resources.

func (*TerraformPluginFrameworkAsyncConnector) Connect

type TerraformPluginFrameworkAsyncOption

type TerraformPluginFrameworkAsyncOption func(connector *TerraformPluginFrameworkAsyncConnector)

TerraformPluginFrameworkAsyncOption represents a configuration option for a TerraformPluginFrameworkAsyncConnector object.

func WithTerraformPluginFrameworkAsyncCallbackProvider

func WithTerraformPluginFrameworkAsyncCallbackProvider(ac CallbackProvider) TerraformPluginFrameworkAsyncOption

WithTerraformPluginFrameworkAsyncCallbackProvider configures the controller to use async variant of the functions of the Terraform client and run given callbacks once those operations are completed.

func WithTerraformPluginFrameworkAsyncConnectorEventHandler

func WithTerraformPluginFrameworkAsyncConnectorEventHandler(e *handler.EventHandler) TerraformPluginFrameworkAsyncOption

WithTerraformPluginFrameworkAsyncConnectorEventHandler configures the EventHandler so that the Terraform Plugin Framework external clients can requeue reconciliation requests.

func WithTerraformPluginFrameworkAsyncLogger

func WithTerraformPluginFrameworkAsyncLogger(l logging.Logger) TerraformPluginFrameworkAsyncOption

WithTerraformPluginFrameworkAsyncLogger configures a logger for the TerraformPluginFrameworkAsyncConnector.

func WithTerraformPluginFrameworkAsyncManagementPolicies

func WithTerraformPluginFrameworkAsyncManagementPolicies(isManagementPoliciesEnabled bool) TerraformPluginFrameworkAsyncOption

WithTerraformPluginFrameworkAsyncManagementPolicies configures whether the client should handle management policies.

func WithTerraformPluginFrameworkAsyncMetricRecorder

func WithTerraformPluginFrameworkAsyncMetricRecorder(r *metrics.MetricRecorder) TerraformPluginFrameworkAsyncOption

WithTerraformPluginFrameworkAsyncMetricRecorder configures a metrics.MetricRecorder for the TerraformPluginFrameworkAsyncConnector.

type TerraformPluginFrameworkConnector

type TerraformPluginFrameworkConnector struct {
	// contains filtered or unexported fields
}

TerraformPluginFrameworkConnector is an external client, with credentials and other configuration parameters, for Terraform Plugin Framework resources. You can use NewTerraformPluginFrameworkConnector to construct.

func NewTerraformPluginFrameworkConnector

NewTerraformPluginFrameworkConnector creates a new TerraformPluginFrameworkConnector with given options.

func (*TerraformPluginFrameworkConnector) Connect

Connect makes sure the underlying client is ready to issue requests to the provider API.

type TerraformPluginFrameworkConnectorOption

type TerraformPluginFrameworkConnectorOption func(connector *TerraformPluginFrameworkConnector)

TerraformPluginFrameworkConnectorOption allows you to configure TerraformPluginFrameworkConnector.

func WithTerraformPluginFrameworkLogger

func WithTerraformPluginFrameworkLogger(l logging.Logger) TerraformPluginFrameworkConnectorOption

WithTerraformPluginFrameworkLogger configures a logger for the TerraformPluginFrameworkConnector.

func WithTerraformPluginFrameworkManagementPolicies

func WithTerraformPluginFrameworkManagementPolicies(isManagementPoliciesEnabled bool) TerraformPluginFrameworkConnectorOption

WithTerraformPluginFrameworkManagementPolicies configures whether the client should handle management policies.

func WithTerraformPluginFrameworkMetricRecorder

func WithTerraformPluginFrameworkMetricRecorder(r *metrics.MetricRecorder) TerraformPluginFrameworkConnectorOption

WithTerraformPluginFrameworkMetricRecorder configures a metrics.MetricRecorder for the TerraformPluginFrameworkConnectorOption.

type TerraformPluginSDKConnector

type TerraformPluginSDKConnector struct {
	// contains filtered or unexported fields
}

func NewTerraformPluginSDKConnector

func NewTerraformPluginSDKConnector(kube client.Client, sf terraform.SetupFn, cfg *config.Resource, ots *orig.OperationTrackerStore, opts ...TerraformPluginSDKOption) *TerraformPluginSDKConnector

NewTerraformPluginSDKConnector initializes a new TerraformPluginSDKConnector

func (*TerraformPluginSDKConnector) Connect

type TerraformPluginSDKOption

type TerraformPluginSDKOption func(connector *TerraformPluginSDKConnector)

TerraformPluginSDKOption allows you to configure TerraformPluginSDKConnector.

func WithTerraformPluginSDKLogger

func WithTerraformPluginSDKLogger(l logging.Logger) TerraformPluginSDKOption

WithTerraformPluginSDKLogger configures a logger for the TerraformPluginSDKConnector.

func WithTerraformPluginSDKManagementPolicies

func WithTerraformPluginSDKManagementPolicies(isManagementPoliciesEnabled bool) TerraformPluginSDKOption

WithTerraformPluginSDKManagementPolicies configures whether the client should handle management policies.

func WithTerraformPluginSDKMetricRecorder

func WithTerraformPluginSDKMetricRecorder(r *metrics.MetricRecorder) TerraformPluginSDKOption

WithTerraformPluginSDKMetricRecorder configures a metrics.MetricRecorder for the TerraformPluginSDKConnector.

type TrackerCleaner

type TrackerCleaner interface {
	RemoveTracker(obj xpresource.Object) error
}

TrackerCleaner is the interface for the common finalizer of both Terraform plugin SDK and framework managed resources.

type Workspace

Workspace is the set of methods that are needed for the controller to work.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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