Skip to content

Commit

Permalink
fix(database): revert breaking field removal part of crossplane-contr…
Browse files Browse the repository at this point in the history
…ib#1835

Signed-off-by: Charel Baum (external expert on behalf of DB Netz AG) <charel.baum-extern@deutschebahn.com>
  • Loading branch information
Charel Baum (external expert on behalf of DB Netz AG) authored and threadproc committed Sep 1, 2023
1 parent 95d5375 commit 8a08a4e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
26 changes: 26 additions & 0 deletions apis/database/v1beta1/rdsinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ type ProcessorFeature struct {
Value string `json:"value"`
}

// CloudwatchLogsExportConfiguration is the configuration setting for the log types to be enabled for export to CloudWatch
// Logs for a specific DB instance or DB cluster.
// The EnableLogTypes and DisableLogTypes arrays determine which logs will be
// exported (or not exported) to CloudWatch Logs. The values within these arrays
// depend on the DB engine being used. For more information, see Publishing
// Database Logs to Amazon CloudWatch Logs (http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.html#USER_LogAccess.Procedural.UploadtoCloudWatch)
// in the Amazon RDS User Guide.
// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/CloudwatchLogsExportConfiguration
type CloudwatchLogsExportConfiguration struct {
// DisableLogTypes is the list of log types to disable.
// +immutable
DisableLogTypes []string `json:"disableLogTypes,omitempty"`

// EnableLogTypes is the list of log types to enable.
// +immutable
EnableLogTypes []string `json:"enableLogTypes,omitempty"`
} // TODO: remove deprecated field + code. Mapping to EnableCloudwatchLogsExports while in deprecation.

// ScalingConfiguration contains the scaling configuration of an Aurora Serverless DB cluster.
// For more information, see Using Amazon Aurora Serverless (http://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.html)
// in the Amazon Aurora User Guide.
Expand Down Expand Up @@ -774,6 +792,14 @@ type RDSInstanceParameters struct {
// +optional
ApplyModificationsImmediately *bool `json:"applyModificationsImmediately,omitempty"`

// Deprecated: This field will be removed. Use `enableCloudwatchLogsExports` instead.
// CloudwatchLogsExportConfiguration is the configuration setting for the log types to be enabled for export to CloudWatch
// Logs for a specific DB instance.
// +immutable
// +optional
CloudwatchLogsExportConfiguration *CloudwatchLogsExportConfiguration `json:"cloudwatchLogsExportConfiguration,omitempty"`
// TODO: remove deprecated field + code. Mapping to EnableCloudwatchLogsExports while in deprecation.

// DBParameterGroupName is the name of the DB parameter group to associate with this DB instance. If
// this argument is omitted, the default DBParameterGroup for the specified
// engine is used.
Expand Down
30 changes: 30 additions & 0 deletions apis/database/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions package/crds/database.aws.crossplane.io_rdsinstances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@ spec:
engines, Amazon Aurora Not applicable. The character set is
managed by the DB cluster. For more information, see CreateDBCluster.
type: string
cloudwatchLogsExportConfiguration:
description: 'Deprecated: This field will be removed. Use `enableCloudwatchLogsExports`
instead. CloudwatchLogsExportConfiguration is the configuration
setting for the log types to be enabled for export to CloudWatch
Logs for a specific DB instance.'
properties:
disableLogTypes:
description: DisableLogTypes is the list of log types to disable.
items:
type: string
type: array
enableLogTypes:
description: EnableLogTypes is the list of log types to enable.
items:
type: string
type: array
type: object
copyTagsToSnapshot:
description: CopyTagsToSnapshot should be true to copy all tags
from the DB instance to snapshots of the DB instance, and otherwise
Expand Down
7 changes: 7 additions & 0 deletions pkg/clients/database/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,11 @@ func LateInitialize(in *v1beta1.RDSInstanceParameters, db *rdstypes.DBInstance)
}
}
}
// TODO: remove deprecated field + code. Mapping to EnableCloudwatchLogsExports while in deprecation.
// nolint:staticcheck
if len(in.EnableCloudwatchLogsExports) == 0 && in.CloudwatchLogsExportConfiguration != nil {
in.EnableCloudwatchLogsExports = in.CloudwatchLogsExportConfiguration.EnableLogTypes
}
}

// IsUpToDate checks whether there is a change in any of the modifiable fields.
Expand All @@ -676,6 +681,8 @@ func IsUpToDate(ctx context.Context, kube client.Client, r *v1beta1.RDSInstance,
cmpopts.IgnoreFields(v1beta1.RDSInstanceParameters{}, "MasterPasswordSecretRef"),
cmpopts.IgnoreFields(v1beta1.RDSInstanceParameters{}, "OptionGroupName"),
cmpopts.IgnoreFields(v1beta1.RDSInstanceParameters{}, "EnableCloudwatchLogsExports"),
// TODO: remove deprecated field + code. Mapping to EnableCloudwatchLogsExports while in deprecation.
cmpopts.IgnoreFields(v1beta1.RDSInstanceParameters{}, "CloudwatchLogsExportConfiguration"),
)

engineVersionChanged := !isEngineVersionUpToDate(r, db)
Expand Down

0 comments on commit 8a08a4e

Please sign in to comment.