resource

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 20 Imported by: 1,221

Documentation

Index

Constants

View Source
const (
	TypeLastAsyncOperation = "LastAsyncOperation"
	TypeAsyncOperation     = "AsyncOperation"

	ReasonApplyFailure       xpv1.ConditionReason = "ApplyFailure"
	ReasonDestroyFailure     xpv1.ConditionReason = "DestroyFailure"
	ReasonAsyncCreateFailure xpv1.ConditionReason = "AsyncCreateFailure"
	ReasonAsyncUpdateFailure xpv1.ConditionReason = "AsyncUpdateFailure"
	ReasonAsyncDeleteFailure xpv1.ConditionReason = "AsyncDeleteFailure"
	ReasonSuccess            xpv1.ConditionReason = "Success"
	ReasonOngoing            xpv1.ConditionReason = "Ongoing"
	ReasonFinished           xpv1.ConditionReason = "Finished"
	ReasonResourceUpToDate   xpv1.ConditionReason = "UpToDate"
)

Condition constants.

View Source
const (
	// AnnotationKeyPrivateRawAttribute is the key that points to private attribute
	// of the Terraform State. It's non-sensitive and used by provider to store
	// arbitrary metadata, usually details about schema version.
	AnnotationKeyPrivateRawAttribute = "upjet.crossplane.io/provider-meta"

	// AnnotationKeyTestResource is used for marking an MR as test for automated tests
	AnnotationKeyTestResource = "upjet.upbound.io/test"

	// CNameWildcard can be used as the canonical name of a value filter option
	// that will apply to all fields of a struct
	CNameWildcard = ""
)

Variables

This section is empty.

Functions

func AsyncOperationFinishedCondition

func AsyncOperationFinishedCondition() xpv1.Condition

AsyncOperationFinishedCondition returns the condition TypeAsyncOperation Finished if the operation was finished

func AsyncOperationOngoingCondition

func AsyncOperationOngoingCondition() xpv1.Condition

AsyncOperationOngoingCondition returns the condition TypeAsyncOperation Ongoing if the operation is still running

func ExtractParamPath

func ExtractParamPath(sourceAttr string, isObservation bool) xpref.ExtractValueFn

ExtractParamPath extracts the value of `sourceAttr` from `spec.forProvider` allowing nested parameters. If `isObservation` is set, then referenced param is retrieved from the status, if not, it's extracted from the spec. An example argument to ExtractParamPath is `key`, if `spec.forProvider.key` is to be extracted from the referred resource.

func ExtractResourceID

func ExtractResourceID() xpref.ExtractValueFn

ExtractResourceID extracts the value of `status.atProvider.id` from a Terraformed resource. If mr is not a Terraformed resource, returns an empty string.

func GetConnectionDetails

func GetConnectionDetails(attr map[string]any, tr Terraformed, cfg *config.Resource) (managed.ConnectionDetails, error)

GetConnectionDetails returns connection details including the sensitive Terraform attributes and additions connection details configured.

func GetSensitiveAttributes

func GetSensitiveAttributes(from map[string]any, mapping map[string]string) (map[string][]byte, error)

GetSensitiveAttributes returns strings matching provided field paths in the input data. See the unit tests for examples.

func GetSensitiveObservation

func GetSensitiveObservation(ctx context.Context, client SecretClient, from *v1.SecretReference, into map[string]any) error

GetSensitiveObservation will return sensitive information as terraform state attributes by reading them from connection details.

func GetSensitiveParameters

func GetSensitiveParameters(ctx context.Context, client SecretClient, from runtime.Object, into map[string]any, mapping map[string]string) error

GetSensitiveParameters will collect sensitive information as terraform state attributes by following secret references in the spec.

func GetTerraformIgnoreChanges

func GetTerraformIgnoreChanges(forProvider, initProvider map[string]any) []string

GetTerraformIgnoreChanges returns a sorted Terraform `ignore_changes` lifecycle meta-argument expression by looking for differences between the `initProvider` and `forProvider` maps. The ignored fields are the ones that are present in initProvider, but not in forProvider.

func IsTest

func IsTest(mg xpresource.Managed) bool

IsTest returns true if the managed resource has upjet.upbound.io/test= "true" annotation

func LastAsyncOperationCondition

func LastAsyncOperationCondition(err error) xpv1.Condition

LastAsyncOperationCondition returns the condition depending on the content of the error.

func SetCriticalAnnotations

func SetCriticalAnnotations(tr metav1.Object, cfg *config.Resource, tfstate map[string]any, privateRaw string) (bool, error)

SetCriticalAnnotations sets the critical annotations of the resource and reports whether there has been a change.

func SetUpToDateCondition

func SetUpToDateCondition(mg xpresource.Managed, upToDate bool)

SetUpToDateCondition sets UpToDate condition if the resource is a test resource and up-to-date

func UpToDateCondition

func UpToDateCondition() xpv1.Condition

UpToDateCondition returns the condition TypeAsyncOperation Ongoing if the operation is still running

Types

type GenericLateInitializer

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

GenericLateInitializer performs late-initialization of a Terraformed resource.

func NewGenericLateInitializer

func NewGenericLateInitializer(opts ...GenericLateInitializerOption) *GenericLateInitializer

NewGenericLateInitializer constructs a new GenericLateInitializer with the supplied options

func (*GenericLateInitializer) LateInitialize

func (li *GenericLateInitializer) LateInitialize(desiredObject, observedObject any) (changed bool, err error)

LateInitialize Copy unset (nil) values from responseObject to crObject Both crObject and responseObject must be pointers to structs. Otherwise, an error will be returned. Returns `true` if at least one field has been stored from source `responseObject` into a corresponding field of target `crObject`.

type GenericLateInitializerOption

type GenericLateInitializerOption func(l *GenericLateInitializer)

GenericLateInitializerOption are options that control the late-initialization behavior of a Terraformed resource.

func WithNameFilter

func WithNameFilter(cname string) GenericLateInitializerOption

WithNameFilter returns a GenericLateInitializer that causes to skip initialization of the field with the specified canonical name

func WithZeroElemPtrFilter

func WithZeroElemPtrFilter(cName string) GenericLateInitializerOption

WithZeroElemPtrFilter returns a GenericLateInitializerOption that causes to skip initialization of a pointer field with a zero-valued element

func WithZeroValueJSONOmitEmptyFilter

func WithZeroValueJSONOmitEmptyFilter(cName string) GenericLateInitializerOption

WithZeroValueJSONOmitEmptyFilter returns a GenericLateInitializerOption that causes to skip initialization of a zero-valued field that has omitempty JSON tag

type LateInitializer

type LateInitializer interface {
	// LateInitialize this Terraformed resource using its observed tfState.
	// returns True if the there are any spec changes for the resource.
	LateInitialize(attrs []byte) (bool, error)
}

LateInitializer late-initializes the managed resource from observed Terraform state.

type MetadataProvider

type MetadataProvider interface {
	GetTerraformResourceType() string
	GetTerraformSchemaVersion() int
	GetConnectionDetailsMapping() map[string]string
}

MetadataProvider provides Terraform metadata for the Terraform managed resource.

type NameFilter

type NameFilter func(string) bool

NameFilter defines a late-initialization filter on CR field canonical names. Fields with matching cnames will not be processed during late-initialization

type Observable

type Observable interface {
	GetObservation() (map[string]any, error)
	SetObservation(map[string]any) error
	GetID() string
}

Observable structs can get and set observations in the form of Terraform JSON.

type Parameterizable

type Parameterizable interface {
	GetParameters() (map[string]any, error)
	SetParameters(map[string]any) error
	GetInitParameters() (map[string]any, error)
	GetMergedParameters(shouldMergeInitProvider bool) (map[string]any, error)
}

Parameterizable structs can get and set parameters of the managed resource using map form of Terraform JSON.

type SecretClient

type SecretClient interface {
	GetSecretData(ctx context.Context, ref *v1.SecretReference) (map[string][]byte, error)
	GetSecretValue(ctx context.Context, sel v1.SecretKeySelector) ([]byte, error)
}

SecretClient is the client to get sensitive data from kubernetes secrets

type Terraformed

Terraformed is a Kubernetes object representing a concrete terraform managed resource.

type ValueFilter

type ValueFilter func(string, reflect.StructField, reflect.Value) bool

ValueFilter defines a late-initialization filter on CR field values. Fields with matching values will not be processed during late-initialization

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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