Skip to content

Commit 76812a9

Browse files
authored
Merge pull request crossplane-contrib#2232 from anagarlau/fix/rds-port
fix(rds): add port to status and connection details from either spec or aws default
2 parents 32600bf + f7e037e commit 76812a9

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

.golangci.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
run:
22
timeout: 30m
33

4-
skip-files:
4+
exclude-files:
55
- "zz_generated\\..+\\.go$"
66

77
output:
@@ -21,11 +21,14 @@ linters-settings:
2121
# [deprecated] comma-separated list of pairs of the form pkg:regex
2222
# the regex is used to ignore names within pkg. (default "fmt:.*").
2323
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
24-
ignore: fmt:.*,io/ioutil:^Read.*
24+
#ignore: fmt:.*,io/ioutil:^Read.*
25+
exclude-functions:
26+
- fmt.*
27+
- io/ioutil:^Read.*
2528

2629
govet:
2730
# report about shadowed variables
28-
check-shadowing: false
31+
shadow: false
2932

3033
gofmt:
3134
# simplify code: gofmt with `-s` option, true by default
@@ -112,7 +115,6 @@ linters-settings:
112115

113116
linters:
114117
enable:
115-
- megacheck
116118
- govet
117119
- gocyclo
118120
- gocritic
@@ -125,15 +127,14 @@ linters:
125127
- misspell
126128
- nakedret
127129
- nolintlint
130+
- gosimple
131+
- staticcheck
132+
- unused
128133

129134
disable:
130135
# These linters are all deprecated as of golangci-lint v1.49.0. We disable
131136
# them explicitly to avoid the linter logging deprecation warnings.
132-
- deadcode
133-
- varcheck
134-
- scopelint
135-
- structcheck
136-
- interfacer
137+
- megacheck
137138

138139
presets:
139140
- bugs

apis/rds/generator-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ resources:
3434
from:
3535
operation: DescribeDBClusters
3636
path: DBClusters.KmsKeyId
37+
Port:
38+
is_read_only: true
39+
from:
40+
operation: DescribeDBClusters
41+
path: DBClusters.Port
3742
DBInstanceRoleAssociation:
3843
exceptions:
3944
errors:

apis/rds/v1alpha1/zz_db_cluster.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/rds/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/crds/rds.aws.crossplane.io_dbclusters.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,10 @@ spec:
18851885
18861886
This setting is only for non-Aurora Multi-AZ DB clusters.
18871887
type: boolean
1888+
port:
1889+
description: The port that the database engine is listening on.
1890+
format: int64
1891+
type: integer
18881892
readReplicaIdentifiers:
18891893
description: |-
18901894
Contains one or more identifiers of the read replicas associated with this

pkg/controller/rds/dbcluster/setup.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func (e *custom) postObserve(ctx context.Context, cr *svcapitypes.DBCluster, res
108108
}
109109

110110
cr.Status.AtProvider.KMSKeyID = resp.DBClusters[0].KmsKeyId
111+
cr.Status.AtProvider.Port = resp.DBClusters[0].Port
111112

112113
switch pointer.StringValue(resp.DBClusters[0].Status) {
113114
case "available", "storage-optimization", "backing-up":
@@ -125,14 +126,10 @@ func (e *custom) postObserve(ctx context.Context, cr *svcapitypes.DBCluster, res
125126
obs.ConnectionDetails = managed.ConnectionDetails{
126127
xpv1.ResourceCredentialsSecretEndpointKey: []byte(pointer.StringValue(cr.Status.AtProvider.Endpoint)),
127128
xpv1.ResourceCredentialsSecretUserKey: []byte(pointer.StringValue(cr.Spec.ForProvider.MasterUsername)),
128-
xpv1.ResourceCredentialsSecretPortKey: []byte(strconv.FormatInt(pointer.Int64Value(cr.Spec.ForProvider.Port), 10)),
129+
xpv1.ResourceCredentialsSecretPortKey: []byte(strconv.FormatInt(pointer.Int64Value(cr.Status.AtProvider.Port), 10)),
129130
"readerEndpoint": []byte(pointer.StringValue(cr.Status.AtProvider.ReaderEndpoint)),
130131
}
131132

132-
if pointer.Int64Value(cr.Spec.ForProvider.Port) > 0 {
133-
obs.ConnectionDetails[xpv1.ResourceCredentialsSecretPortKey] = []byte(strconv.FormatInt(pointer.Int64Value(cr.Spec.ForProvider.Port), 10))
134-
}
135-
136133
pw, err := dbinstance.GetDesiredPassword(ctx, e.kube, cr)
137134
if err != nil {
138135
return obs, errors.Wrap(err, dbinstance.ErrGetCachedPassword)

0 commit comments

Comments
 (0)