controller

package
v1.1.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 43 Imported by: 520

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 AsyncTracker

type AsyncTracker struct {
	LastOperation *terraform.Operation
	// contains filtered or unexported fields
}

func NewAsyncTracker

func NewAsyncTracker(opts ...AsyncTrackerOption) *AsyncTracker

func (*AsyncTracker) GetTfID

func (a *AsyncTracker) GetTfID() string

func (*AsyncTracker) GetTfState

func (a *AsyncTracker) GetTfState() *tfsdk.InstanceState

func (*AsyncTracker) HasState

func (a *AsyncTracker) HasState() bool

func (*AsyncTracker) IsDeleted

func (a *AsyncTracker) IsDeleted() bool

IsDeleted returns whether the associated external resource has logically been deleted.

func (*AsyncTracker) SetDeleted

func (a *AsyncTracker) SetDeleted(deleted bool)

SetDeleted sets the logical deletion status of the associated external resource.

func (*AsyncTracker) SetTfState

func (a *AsyncTracker) SetTfState(state *tfsdk.InstanceState)

type AsyncTrackerOption

type AsyncTrackerOption func(manager *AsyncTracker)

func WithAsyncTrackerLogger

func WithAsyncTrackerLogger(l logging.Logger) AsyncTrackerOption

WithAsyncTrackerLogger sets the logger of AsyncTracker.

type CallbackFn

type CallbackFn func(error, context.Context) error

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 ESSOptions

type ESSOptions struct {
	TLSConfig     *tls.Config
	TLSSecretName *string
}

ESSOptions for External Secret Stores.

type NoForkAsyncConnector

type NoForkAsyncConnector struct {
	*NoForkConnector
	// contains filtered or unexported fields
}

func (*NoForkAsyncConnector) Connect

type NoForkAsyncOption

type NoForkAsyncOption func(connector *NoForkAsyncConnector)

func WithNoForkAsyncCallbackProvider

func WithNoForkAsyncCallbackProvider(ac CallbackProvider) NoForkAsyncOption

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

func WithNoForkAsyncConnectorEventHandler

func WithNoForkAsyncConnectorEventHandler(e *handler.EventHandler) NoForkAsyncOption

WithNoForkAsyncConnectorEventHandler configures the EventHandler so that the no-fork external clients can requeue reconciliation requests.

func WithNoForkAsyncLogger

func WithNoForkAsyncLogger(l logging.Logger) NoForkAsyncOption

WithNoForkAsyncLogger configures a logger for the NoForkAsyncConnector.

func WithNoForkAsyncManagementPolicies

func WithNoForkAsyncManagementPolicies(isManagementPoliciesEnabled bool) NoForkAsyncOption

WithNoForkAsyncManagementPolicies configures whether the client should handle management policies.

func WithNoForkAsyncMetricRecorder

func WithNoForkAsyncMetricRecorder(r *metrics.MetricRecorder) NoForkAsyncOption

WithNoForkAsyncMetricRecorder configures a metrics.MetricRecorder for the NoForkAsyncConnector.

type NoForkConnector

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

func (*NoForkConnector) Connect

type NoForkFinalizer

type NoForkFinalizer struct {
	xpresource.Finalizer
	OperationStore TrackerCleaner
}

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

func NewNoForkFinalizer

func NewNoForkFinalizer(tc TrackerCleaner, af xpresource.Finalizer) *NoForkFinalizer

NewNoForkFinalizer returns a new NoForkFinalizer.

func (*NoForkFinalizer) AddFinalizer

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

AddFinalizer to the supplied Managed resource.

func (*NoForkFinalizer) RemoveFinalizer

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

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

type NoForkOption

type NoForkOption func(connector *NoForkConnector)

NoForkOption allows you to configure NoForkConnector.

func WithNoForkLogger

func WithNoForkLogger(l logging.Logger) NoForkOption

WithNoForkLogger configures a logger for the NoForkConnector.

func WithNoForkManagementPolicies

func WithNoForkManagementPolicies(isManagementPoliciesEnabled bool) NoForkOption

WithNoForkManagementPolicies configures whether the client should handle management policies.

func WithNoForkMetricRecorder

func WithNoForkMetricRecorder(r *metrics.MetricRecorder) NoForkOption

WithNoForkMetricRecorder configures a metrics.MetricRecorder for the NoForkConnector.

type OperationTrackerStore

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

func NewOperationStore

func NewOperationStore(l logging.Logger) *OperationTrackerStore

func (*OperationTrackerStore) RemoveTracker

func (ops *OperationTrackerStore) RemoveTracker(obj xpresource.Object) error

func (*OperationTrackerStore) Tracker

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 Options

type Options struct {
	controller.Options

	// Provider contains all resource configurations of the provider which can
	// be used to pick the related one. Since the selection is done in runtime,
	// we need to pass everything and generated code will pick the one.
	Provider *config.Provider

	// WorkspaceStore will be used to pick/initialize the workspace the specific CR
	// instance should use.
	WorkspaceStore *terraform.WorkspaceStore

	OperationTrackerStore *OperationTrackerStore

	// SetupFn contains the provider-specific initialization logic, such as
	// preparing the auth token for Terraform CLI.
	SetupFn terraform.SetupFn

	// SecretStoreConfigGVK is the GroupVersionKind for the Secret StoreConfig
	// resource. Setting this enables External Secret Stores for the controller
	// by adding connection.DetailsManager as a ConnectionPublisher.
	SecretStoreConfigGVK *schema.GroupVersionKind

	// ESSOptions for External Secret Stores.
	ESSOptions *ESSOptions

	// PollJitter adds the specified jitter to the configured reconcile period
	// of the up-to-date resources in managed.Reconciler.
	PollJitter time.Duration
}

Options contains incriminating options for a given Upjet controller instance.

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, diag.Diagnostics)
	RefreshWithoutUpgrade(ctx context.Context, s *tf.InstanceState, meta interface{}) (*tf.InstanceState, diag.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 TrackerCleaner

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

TrackerCleaner is the interface that the no-fork finalizer needs to work with.

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