resourceoverrides

package
v1.116.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func EnsureReferenceFieldIsMultiKind

func EnsureReferenceFieldIsMultiKind(crd *apiextensions.CustomResourceDefinition, parentPath []string, referenceFieldName string, supportedKinds []string) error

EnsureReferenceFieldIsMultiKind adds the required `kind` field under the reference field if the `kind` field doesn't exist.

func FavorAuthoritativeFieldOverLegacyField

func FavorAuthoritativeFieldOverLegacyField(r *k8s.Resource, legacyFieldPath, fieldPath []string) error

FavorAuthoritativeFieldOverLegacyField favor the value of the authoritative field if it's set; otherwise, it takes the value from the legacy field and populate it into the authoritative field and then prune the legacy field. If the legacy field is specified, this function will also mark the authoritative field as managed fields.

func FavorReferenceArrayFieldOverNonReferenceArrayField

func FavorReferenceArrayFieldOverNonReferenceArrayField(r *k8s.Resource, nonReferenceFieldPath, referenceFieldPath []string) error

FavorReferenceArrayFieldOverNonReferenceArrayField favor the value of the reference array field if it's set; otherwise, it takes the value from the non-reference array field, populates it into the 'external' subfield of the items in the reference field, and then prune the non-reference field.

func FavorReferenceFieldOverNonReferenceFieldUnderSlice

func FavorReferenceFieldOverNonReferenceFieldUnderSlice(r *k8s.Resource, pathUpToSlice, nonReferenceFieldPath, referenceFieldPath []string) error

FavorReferenceFieldOverNonReferenceFieldUnderSlice returns an error if both fields are set; otherwise, take the value from the non-reference field and populate it into the "external" field in the reference field, and then prune the non-reference field.

func KeepTopLevelFieldOptionalWithDefault

func KeepTopLevelFieldOptionalWithDefault(crd *apiextensions.CustomResourceDefinition, defaultValue interface{}, field string) error

KeepTopLevelFieldOptionalWithDefault decorates the input CRD to modify the given top field as optional with the default.

func PreserveMutuallyExclusiveNonReferenceField

func PreserveMutuallyExclusiveNonReferenceField(crd *apiextensions.CustomResourceDefinition, parentPath []string, referenceFieldName, nonReferenceFieldName string) error

PreserveMutuallyExclusiveNonReferenceField adds back the non-ref field to keep the CRD backwards compatible.

func PreserveUserSpecifiedLegacyArrayField

func PreserveUserSpecifiedLegacyArrayField(original, reconciled *k8s.Resource, path ...string) error

PreserveUserSpecifiedLegacyArrayField adds the user specified legacy array field back to the reconciled resource. The reason to preserve the legacy array field is because that users may be confused when the objects they try to create are different from what they get back.

func PreserveUserSpecifiedLegacyField

func PreserveUserSpecifiedLegacyField(original, reconciled *k8s.Resource, path ...string) error

PreserveUserSpecifiedLegacyField adds the user specified legacy field back to the reconciled resource. The reason to preserve the legacy field is because that users may be confused when the objects they try to create are different from what they get back.

func PreserveUserSpecifiedLegacyFieldUnderSlice

func PreserveUserSpecifiedLegacyFieldUnderSlice(original, reconciled *k8s.Resource, upToSlicePath []string, path []string) error

PreserveUserSpecifiedLegacyFieldUnderSlice iterates through the specified slice/array field in the reconciled and original resource, and adds the user-specified non-reference field(s) back into the reconciled resource. The reason to preserve the non-reference field is that users may be confused when the objects they try to create are different from what they get back. Note: This function assumed that the order of items in the slice are the same in the original and reconciled resources.

func PruneDefaultedAuthoritativeArrayFieldIfOnlyLegacyArrayFieldSpecified

func PruneDefaultedAuthoritativeArrayFieldIfOnlyLegacyArrayFieldSpecified(original, reconciled *k8s.Resource, legacyFieldPath, fieldPath []string) error

PruneDefaultedAuthoritativeArrayFieldIfOnlyLegacyArrayFieldSpecified prunes the defaulted authoritative array field from the reconciled resource (post-actuation) if only the legacy array field is specified in the original spec. Populating the new authoritative array field into spec along with the legacy array field will cause confusion if users only modify the legacy array field in their configuration without being aware of the defaulted field in k8s object.

func PruneDefaultedAuthoritativeFieldIfOnlyLegacyFieldSpecified

func PruneDefaultedAuthoritativeFieldIfOnlyLegacyFieldSpecified(original, reconciled *k8s.Resource, legacyFieldPath, fieldPath []string) error

PruneDefaultedAuthoritativeFieldIfOnlyLegacyFieldSpecified prune the defaulted authoritative field from the reconciled resource (post-actuation) if only the legacy field is specified in the original spec. Populating the new authoritative field into spec along with the legacy field will cause confusion if users only modify the legacy field in their configuration without being aware of the defaulted field in k8s object.

func PruneDefaultedAuthoritativeFieldIfOnlyLegacyFieldSpecifiedUnderSlice

func PruneDefaultedAuthoritativeFieldIfOnlyLegacyFieldSpecifiedUnderSlice(original, reconciled *k8s.Resource, pathUpToSlice, nonReferenceFieldPath, referenceFieldPath []string) error

PruneDefaultedAuthoritativeFieldIfOnlyLegacyFieldSpecifiedUnderSlice iterates through the specified slice/array field in the reconciled and original resource, and prune the defaulted reference field from the reconciled resource (post-actuation) if only the non-reference field is specified in the original spec. Populating the new reference field into spec along with the non-reference field will cause confusion if users only modify the non-reference field in their configuration without being aware of the defaulted field in k8s object. Note: This function assumed that the order of items in the slice are the same in the original and reconciled resources.

func PruneNoOpsField

func PruneNoOpsField(r *k8s.Resource, path ...string) error

PruneNoOpsField removes the no-ops field from spec if specified given the field path. It doesn't work for sub-fields in the parent field of array type.

Types

type CRDDecorate

type CRDDecorate func(crd *apiextensions.CustomResourceDefinition) error

CRDDecorate decorates the given CRD to ensure that its schemas are authored correctly. It could be used to preserve legacy fields, to mark fields optional with defaults, etc.

type ConfigValidate

type ConfigValidate func(r *unstructured.Unstructured) error

ConfigValidate validates the input configuration in the webhook.

type IAMCustomRole added in v1.99.0

type IAMCustomRole struct {
}

func (*IAMCustomRole) PreTerraformExport added in v1.99.0

func (h *IAMCustomRole) PreTerraformExport(_ context.Context, op *operations.TerraformExport) error

type LoggingLogSink added in v1.101.0

type LoggingLogSink struct {
}

func (*LoggingLogSink) CRDDecorate added in v1.101.0

func (*LoggingLogSink) PreTerraformExport added in v1.101.0

func (h *LoggingLogSink) PreTerraformExport(_ context.Context, op *operations.TerraformExport) error

type PostActuationTransform

type PostActuationTransform func(original, reconciled *k8s.Resource, tfState *terraform.InstanceState, dclState *unstructured.Unstructured) error

PostActuationTransform transform the reconciled resource object. A typical example of post-actuation transformations is to preserve the user specified fields.

type PostUpdateStatusTransform added in v1.106.0

type PostUpdateStatusTransform func(r *k8s.Resource) error

PostUpdateStatusTransform transforms the resource object after its status is being updated.

type PreActuationTransform

type PreActuationTransform func(r *k8s.Resource) error

PreActuationTransform transforms the original spec to the golden format that the resource actuator can understand. For example, it could be used to fetch value from the legacy field and place it to the field that the resource actuator actually understands and supports.

type PreTerraformApply added in v1.111.0

type PreTerraformApply func(ctx context.Context, op *operations.PreTerraformApply) error

PreTerraformApply transforms the object just before we try to apply it with terraform. A typical example of a transformation is to change fields to work around terraform bugs.

type PreTerraformExport added in v1.99.0

type PreTerraformExport func(ctx context.Context, op *operations.TerraformExport) error

PreTerraformExport transforms the exported terraform prior to writing it. A typical example of a transformation is to map our internal terraform types to real types.

type ROHandler added in v1.114.0

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

func NewResourceOverridesHandler

func NewResourceOverridesHandler() *ROHandler

func (*ROHandler) CRDDecorate added in v1.114.0

func (*ROHandler) ConfigValidate added in v1.114.0

func (h *ROHandler) ConfigValidate(r *unstructured.Unstructured) error

func (*ROHandler) HasConfigValidate added in v1.114.0

func (h *ROHandler) HasConfigValidate(kind string) bool

func (*ROHandler) HasOverrides added in v1.114.0

func (h *ROHandler) HasOverrides(kind string) bool

func (*ROHandler) PostActuationTransform added in v1.114.0

func (h *ROHandler) PostActuationTransform(original, post *k8s.Resource, tfState *terraform.InstanceState, dclState *unstructured.Unstructured) error

func (*ROHandler) PostUpdateStatusTransform added in v1.114.0

func (h *ROHandler) PostUpdateStatusTransform(r *k8s.Resource) error

func (*ROHandler) PreActuationTransform added in v1.114.0

func (h *ROHandler) PreActuationTransform(r *k8s.Resource) error

func (*ROHandler) PreTerraformApply added in v1.114.0

func (h *ROHandler) PreTerraformApply(ctx context.Context, gvk schema.GroupVersionKind, op *operations.PreTerraformApply) error

func (*ROHandler) PreTerraformExport added in v1.114.0

func (h *ROHandler) PreTerraformExport(ctx context.Context, gvk schema.GroupVersionKind, op *operations.TerraformExport) error

func (*ROHandler) Register added in v1.114.0

func (h *ROHandler) Register(ro ResourceOverrides)

type ResourceOverride

type ResourceOverride struct {
	CRDDecorate               CRDDecorate
	ConfigValidate            ConfigValidate
	PreActuationTransform     PreActuationTransform
	PostActuationTransform    PostActuationTransform
	PreTerraformApply         PreTerraformApply
	PreTerraformExport        PreTerraformExport
	PostUpdateStatusTransform PostUpdateStatusTransform
}

ResourceOverride holds all pieces of changes needed, i.e. decoration, transformation and validation to author a resource-specific behavior override. Since one particular resource kind could have multiple overrides, each ResourceOverride should be logically orthogonal to each other and neutral to order of execution.

type ResourceOverrides

type ResourceOverrides struct {
	Kind      string
	Overrides []ResourceOverride
}

func GetAlloyDBInstanceResourceOverrides added in v1.115.0

func GetAlloyDBInstanceResourceOverrides() ResourceOverrides

func GetComputeBackendServiceResourceOverrides added in v1.90.0

func GetComputeBackendServiceResourceOverrides() ResourceOverrides

func GetComputeForwardingRuleResourceOverrides added in v1.111.0

func GetComputeForwardingRuleResourceOverrides() ResourceOverrides

func GetComputeInstanceResourceOverrides

func GetComputeInstanceResourceOverrides() ResourceOverrides

func GetContainerClusterResourceOverrides

func GetContainerClusterResourceOverrides() ResourceOverrides

func GetDNSRecordSetOverrides

func GetDNSRecordSetOverrides() ResourceOverrides

func GetIAMCustomRoleResourceOverrides added in v1.99.0

func GetIAMCustomRoleResourceOverrides() ResourceOverrides

func GetLoggingLogSinkResourceOverrides

func GetLoggingLogSinkResourceOverrides() ResourceOverrides

func GetRedisInstanceResourceOverrides added in v1.108.0

func GetRedisInstanceResourceOverrides() ResourceOverrides

func GetRunServiceResourceOverrides added in v1.110.0

func GetRunServiceResourceOverrides() ResourceOverrides

func GetSQLInstanceResourceOverrides

func GetSQLInstanceResourceOverrides() ResourceOverrides

func GetStorageBucketResourceOverrides

func GetStorageBucketResourceOverrides() ResourceOverrides

func GetVPCAccessConnectorResourceOverrides added in v1.106.0

func GetVPCAccessConnectorResourceOverrides() ResourceOverrides

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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