resourceoverrides

package
v1.103.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 14 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(ctx 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(ctx 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 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 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 ResourceOverride

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

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 GetComputeBackendServiceResourceOverrides added in v1.90.0

func GetComputeBackendServiceResourceOverrides() 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 GetSQLInstanceResourceOverrides

func GetSQLInstanceResourceOverrides() ResourceOverrides

func GetStorageBucketResourceOverrides

func GetStorageBucketResourceOverrides() ResourceOverrides

type ResourceOverridesHandler

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

func NewResourceOverridesHandler

func NewResourceOverridesHandler() *ResourceOverridesHandler

func (*ResourceOverridesHandler) CRDDecorate

func (*ResourceOverridesHandler) ConfigValidate

func (*ResourceOverridesHandler) HasConfigValidate

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

func (*ResourceOverridesHandler) HasOverrides

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

func (*ResourceOverridesHandler) PostActuationTransform

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

func (*ResourceOverridesHandler) PreActuationTransform

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

func (*ResourceOverridesHandler) PreTerraformExport added in v1.99.0

func (*ResourceOverridesHandler) Register

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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