From bfe676a4722fa4a45dec30c6e3895099da5069df Mon Sep 17 00:00:00 2001 From: "Charel Baum (external expert on behalf of DB Netz AG)" Date: Thu, 17 Aug 2023 16:36:43 +0200 Subject: [PATCH] fix(database): revert breaking field removal part of #1835 Signed-off-by: Charel Baum (external expert on behalf of DB Netz AG) --- apis/database/v1beta1/rdsinstance_types.go | 26 ++++++++++++++++ .../database/v1beta1/zz_generated.deepcopy.go | 30 +++++++++++++++++++ ...tabase.aws.crossplane.io_rdsinstances.yaml | 17 +++++++++++ pkg/clients/database/rds.go | 7 +++++ 4 files changed, 80 insertions(+) diff --git a/apis/database/v1beta1/rdsinstance_types.go b/apis/database/v1beta1/rdsinstance_types.go index 0f64a172d8..8582e4e86e 100644 --- a/apis/database/v1beta1/rdsinstance_types.go +++ b/apis/database/v1beta1/rdsinstance_types.go @@ -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. @@ -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. diff --git a/apis/database/v1beta1/zz_generated.deepcopy.go b/apis/database/v1beta1/zz_generated.deepcopy.go index 4da7f38d27..f9714ff9ea 100644 --- a/apis/database/v1beta1/zz_generated.deepcopy.go +++ b/apis/database/v1beta1/zz_generated.deepcopy.go @@ -41,6 +41,31 @@ func (in *AvailabilityZone) DeepCopy() *AvailabilityZone { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudwatchLogsExportConfiguration) DeepCopyInto(out *CloudwatchLogsExportConfiguration) { + *out = *in + if in.DisableLogTypes != nil { + in, out := &in.DisableLogTypes, &out.DisableLogTypes + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.EnableLogTypes != nil { + in, out := &in.EnableLogTypes, &out.EnableLogTypes + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudwatchLogsExportConfiguration. +func (in *CloudwatchLogsExportConfiguration) DeepCopy() *CloudwatchLogsExportConfiguration { + if in == nil { + return nil + } + out := new(CloudwatchLogsExportConfiguration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DBInstanceStatusInfo) DeepCopyInto(out *DBInstanceStatusInfo) { *out = *in @@ -791,6 +816,11 @@ func (in *RDSInstanceParameters) DeepCopyInto(out *RDSInstanceParameters) { *out = new(bool) **out = **in } + if in.CloudwatchLogsExportConfiguration != nil { + in, out := &in.CloudwatchLogsExportConfiguration, &out.CloudwatchLogsExportConfiguration + *out = new(CloudwatchLogsExportConfiguration) + (*in).DeepCopyInto(*out) + } if in.DBParameterGroupName != nil { in, out := &in.DBParameterGroupName, &out.DBParameterGroupName *out = new(string) diff --git a/package/crds/database.aws.crossplane.io_rdsinstances.yaml b/package/crds/database.aws.crossplane.io_rdsinstances.yaml index f1e8ed1483..3f898d826b 100644 --- a/package/crds/database.aws.crossplane.io_rdsinstances.yaml +++ b/package/crds/database.aws.crossplane.io_rdsinstances.yaml @@ -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 diff --git a/pkg/clients/database/rds.go b/pkg/clients/database/rds.go index 5116584e77..509e5cad14 100644 --- a/pkg/clients/database/rds.go +++ b/pkg/clients/database/rds.go @@ -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. @@ -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)