From 0973cd57197ccadc326412d41ec020875921830c Mon Sep 17 00:00:00 2001 From: Simon Wakenhut Date: Wed, 2 Oct 2024 13:56:35 +0200 Subject: [PATCH] chore: Bump AWS SDK versions Signed-off-by: Simon Wakenhut --- go.mod | 69 +++---- go.sum | 168 ++++++++---------- pkg/clients/acmpca/certificateauthority.go | 9 +- .../acmpca/certificateauthority_test.go | 7 +- pkg/clients/database/rds.go | 36 ++-- pkg/clients/database/rds_test.go | 118 +++--------- pkg/clients/ec2/internetgateway.go | 2 +- pkg/clients/ec2/subnet.go | 2 +- .../elasticache/convert/zz_converter.go | 39 +++- pkg/clients/elasticache/elasticache.go | 33 ++-- pkg/clients/elasticache/elasticache_test.go | 36 ++-- pkg/clients/elasticloadbalancing/elb/elb.go | 9 +- .../elasticloadbalancing/elb/elb_test.go | 3 +- pkg/clients/redshift/redshift.go | 40 +++-- pkg/clients/redshift/redshift_test.go | 45 +++-- pkg/clients/s3/bucket.go | 2 +- .../certificateauthority/controller_test.go | 5 +- .../cache/replicationgroup/managed_test.go | 17 +- .../database/rdsinstance/rdsinstance.go | 2 +- .../database/rdsinstance/rdsinstance_test.go | 27 +-- .../ec2/securitygrouprule/controller_test.go | 72 ++++---- pkg/controller/ec2/subnet/controller.go | 2 +- .../elasticloadbalancing/elb/controller.go | 8 +- .../elb/controller_test.go | 2 +- .../rds/dbclusterparametergroup/setup.go | 2 +- pkg/controller/rds/dbparametergroup/setup.go | 2 +- .../redshift/cluster/controller_test.go | 73 +++++--- pkg/controller/s3/bucket/CORSConfig.go | 7 +- pkg/controller/s3/bucket/CORSConfig_test.go | 3 +- pkg/controller/s3/bucket/lifecycleConfig.go | 24 +-- .../s3/bucket/lifecycleConfig_test.go | 13 +- .../s3/bucket/notificationConfig_test.go | 97 +++++----- pkg/controller/s3/bucket/publicAccessBlock.go | 25 +-- .../s3/bucket/publicAccessBlock_test.go | 11 +- pkg/controller/s3/bucket/replicationConfig.go | 13 +- .../s3/bucket/replicationConfig_test.go | 43 ++--- pkg/controller/s3/bucket/sseConfig.go | 5 +- pkg/utils/connect/aws/config.go | 18 +- pkg/utils/connect/aws/config_test.go | 4 +- 39 files changed, 529 insertions(+), 564 deletions(-) diff --git a/go.mod b/go.mod index fe605551ff..d7b167a328 100644 --- a/go.mod +++ b/go.mod @@ -5,30 +5,30 @@ go 1.21 require ( github.com/aws-controllers-k8s/code-generator v0.26.1 github.com/aws/aws-sdk-go v1.44.334 - github.com/aws/aws-sdk-go-v2 v1.19.0 - github.com/aws/aws-sdk-go-v2/config v1.11.1 - github.com/aws/aws-sdk-go-v2/credentials v1.6.5 - github.com/aws/aws-sdk-go-v2/service/acm v1.16.0 - github.com/aws/aws-sdk-go-v2/service/acmpca v1.12.0 - github.com/aws/aws-sdk-go-v2/service/cloudformation v1.30.1 - github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.17.3 - github.com/aws/aws-sdk-go-v2/service/ec2 v1.26.0 - github.com/aws/aws-sdk-go-v2/service/ecr v1.12.0 - github.com/aws/aws-sdk-go-v2/service/eks v1.22.1 - github.com/aws/aws-sdk-go-v2/service/elasticache v1.16.0 - github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.10.0 - github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.10.0 - github.com/aws/aws-sdk-go-v2/service/iam v1.14.0 - github.com/aws/aws-sdk-go-v2/service/lambda v1.21.1 - github.com/aws/aws-sdk-go-v2/service/rds v1.39.0 - github.com/aws/aws-sdk-go-v2/service/redshift v1.17.0 - github.com/aws/aws-sdk-go-v2/service/route53 v1.15.0 - github.com/aws/aws-sdk-go-v2/service/route53resolver v1.10.2 - github.com/aws/aws-sdk-go-v2/service/s3 v1.22.0 - github.com/aws/aws-sdk-go-v2/service/sns v1.13.0 - github.com/aws/aws-sdk-go-v2/service/sqs v1.14.0 - github.com/aws/aws-sdk-go-v2/service/sts v1.12.0 - github.com/aws/smithy-go v1.13.5 + github.com/aws/aws-sdk-go-v2 v1.31.0 + github.com/aws/aws-sdk-go-v2/config v1.27.39 + github.com/aws/aws-sdk-go-v2/credentials v1.17.37 + github.com/aws/aws-sdk-go-v2/service/acm v1.29.3 + github.com/aws/aws-sdk-go-v2/service/acmpca v1.36.3 + github.com/aws/aws-sdk-go-v2/service/cloudformation v1.54.3 + github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.45.3 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.179.2 + github.com/aws/aws-sdk-go-v2/service/ecr v1.35.3 + github.com/aws/aws-sdk-go-v2/service/eks v1.49.3 + github.com/aws/aws-sdk-go-v2/service/elasticache v1.41.3 + github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.27.3 + github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.38.3 + github.com/aws/aws-sdk-go-v2/service/iam v1.36.3 + github.com/aws/aws-sdk-go-v2/service/lambda v1.62.1 + github.com/aws/aws-sdk-go-v2/service/rds v1.86.0 + github.com/aws/aws-sdk-go-v2/service/redshift v1.47.3 + github.com/aws/aws-sdk-go-v2/service/route53 v1.44.3 + github.com/aws/aws-sdk-go-v2/service/route53resolver v1.31.3 + github.com/aws/aws-sdk-go-v2/service/s3 v1.63.3 + github.com/aws/aws-sdk-go-v2/service/sns v1.32.3 + github.com/aws/aws-sdk-go-v2/service/sqs v1.35.3 + github.com/aws/aws-sdk-go-v2/service/sts v1.31.3 + github.com/aws/smithy-go v1.21.0 github.com/crossplane/crossplane-runtime v1.16.0 github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 github.com/evanphx/json-patch v5.6.0+incompatible @@ -59,15 +59,18 @@ require ( github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/aws-controllers-k8s/pkg v0.0.4 // indirect - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.0.0 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.8.2 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.2 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.5.0 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.9.2 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.7.0 // indirect + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect + github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.18 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.20 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.18 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.23.3 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.3 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect diff --git a/go.sum b/go.sum index cbfe0fd21e..4f5b879fc1 100644 --- a/go.sum +++ b/go.sum @@ -79,98 +79,78 @@ github.com/aws-controllers-k8s/runtime v0.26.0 h1:XKqygFzHSBtM74Ov9IroZbyCVeYei9 github.com/aws-controllers-k8s/runtime v0.26.0/go.mod h1:jizDzKikL09cueIuA9ZxoZ+4pfn5U7oKW5s/ZAqOA6E= github.com/aws/aws-sdk-go v1.44.334 h1:h2bdbGb//fez6Sv6PaYv868s9liDeoYM6hYsAqTB4MU= github.com/aws/aws-sdk-go v1.44.334/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.10.0/go.mod h1:U/EyyVvKtzmFeQQcca7eBotKdlpcP2zzU6bXBYcf7CE= -github.com/aws/aws-sdk-go-v2 v1.11.2/go.mod h1:SQfA+m2ltnu1cA0soUkj4dRSsmITiVQUJvBIZjzfPyQ= -github.com/aws/aws-sdk-go-v2 v1.16.2/go.mod h1:ytwTPBG6fXTZLxxeeCCWj2/EMYp/xDUgX+OET6TLNNU= -github.com/aws/aws-sdk-go-v2 v1.16.7/go.mod h1:6CpKuLXg2w7If3ABZCl/qZ6rEgwtjZTn4eAf4RcEyuw= -github.com/aws/aws-sdk-go-v2 v1.16.16/go.mod h1:SwiyXi/1zTUZ6KIAmLK5V5ll8SiURNUYOqTerZPaF9k= -github.com/aws/aws-sdk-go-v2 v1.17.1/go.mod h1:JLnGeGONAyi2lWXI1p0PCIOIy333JMVK1U7Hf0aRFLw= -github.com/aws/aws-sdk-go-v2 v1.17.3/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2 v1.19.0 h1:klAT+y3pGFBU/qVf1uzwttpBbiuozJYWzNLHioyDJ+k= -github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.0.0 h1:yVUAwvJC/0WNPbyl0nA3j1L6CW1CN8wBubCRqtG7JLI= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.0.0/go.mod h1:Xn6sxgRuIDflLRJFj5Ev7UxABIkNbccFPV/p8itDReM= -github.com/aws/aws-sdk-go-v2/config v1.11.1 h1:KXSjb7ZMLRtjxClFptukTYibiOqJS9NwBO+9WD3UMto= -github.com/aws/aws-sdk-go-v2/config v1.11.1/go.mod h1:VvfkzUhVtntSg1JfGFMSKS0CyiTZd3NqBxK5af4zsME= -github.com/aws/aws-sdk-go-v2/credentials v1.6.5 h1:ZrsO2js2v4T95rsCIWoAb/ck5+U1kwkizGdZHY+ni3s= -github.com/aws/aws-sdk-go-v2/credentials v1.6.5/go.mod h1:HWSOnsnqVMbLcWUmom6AN1cqhcLzLJ62AObW28CbYbU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.8.2 h1:KiN5TPOLrEjbGCvdTQR4t0U4T87vVwALZ5Bg3jpMqPY= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.8.2/go.mod h1:dF2F6tXEOgmW5X1ZFO/EPtWrcm7XkW07KNcJUGNtt4s= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.2/go.mod h1:SgKKNBIoDC/E1ZCDhhMW3yalWjwuLjMcpLzsM/QQnWo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9/go.mod h1:AnVH5pvai0pAF4lXRq0bmhbes1u9R8wTE+g+183bZNM= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14/go.mod h1:kdjrMwHwrC3+FsKhNcCMJ7tUVj/8uSD5CZXeQ4wV6fM= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.23/go.mod h1:2DFxAQ9pfIRy0imBCJv+vZ2X6RKxves6fbnEuSry6b4= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25/go.mod h1:Zb29PYkf42vVYQY6pvSyJCJcFHlPIiY+YKdPtwnvMkY= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27/go.mod h1:a1/UpzeyBBerajpnP5nGZa9mGzsBn5cOKxm6NWQsvoI= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 h1:hMUCiE3Zi5AHrRNGf5j985u0WyqI6r2NULhUfo0N/No= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35/go.mod h1:ipR5PvpSPqIqL5Mi82BxLnfMkHVbmco8kUwO2xrCi0M= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.0.2/go.mod h1:xT4XX6w5Sa3dhg50JrYyy3e4WPYo/+WjY/BXtqXVunU= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.3/go.mod h1:ssOhaLpRlh88H3UmEcsBoVKq309quMvm3Ds8e9d4eJM= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8/go.mod h1:ZIV8GYoC6WLBW5KGs+o4rsc65/ozd+eQ0L31XF5VDwk= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.17/go.mod h1:pRwaTYCJemADaqCbUAxltMoHKata7hmB5PjEXeu0kfg= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19/go.mod h1:6Q0546uHDp421okhmmGfbxzq2hBqbXFNpi4k+Q1JnQA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.21/go.mod h1:+Gxn8jYn5k9ebfHEqlhrMirFjSW0v0C9fI+KN5vk2kE= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 h1:yOpYx+FTBdpk/g+sBU6Cb1H0U/TLEcYYp66mYqsPpcc= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29/go.mod h1:M/eUABlDbw2uVrdAn+UsI6M727qp2fxkp8K0ejcBDUY= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.2 h1:IQup8Q6lorXeiA/rK72PeToWoWK8h7VAPgHNWdSrtgE= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.2/go.mod h1:VITe/MdW6EMXPb0o0txu/fsonXbMHUU2OC2Qp7ivU4o= -github.com/aws/aws-sdk-go-v2/service/acm v1.16.0 h1:puhPHuHlBJM6S5fTM4W1WI8vM/zjmqdyy0Gzgx9NUe8= -github.com/aws/aws-sdk-go-v2/service/acm v1.16.0/go.mod h1:LR3qi788mHzUYfv2MNs+xwbvig6QlrPYVOhKv/Ae5M0= -github.com/aws/aws-sdk-go-v2/service/acmpca v1.12.0 h1:JL8J0ji+JK0t7JUUNtZg8atEUThdzk0KCgXY4a+7UXE= -github.com/aws/aws-sdk-go-v2/service/acmpca v1.12.0/go.mod h1:AcCVrQKCGEWqfC1837nKJW2H5GdYseVfmGwhDjtcX3M= -github.com/aws/aws-sdk-go-v2/service/cloudformation v1.30.1 h1:MHKSdt+ECxOWD98MYj/Ocy4GS8GgAjgEDSPaiTaXP6U= -github.com/aws/aws-sdk-go-v2/service/cloudformation v1.30.1/go.mod h1:laKFhtn8EH6gcPl7KEQ4kcuSYcQF1tqUm82ENxMwlMk= -github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.17.3 h1:xtwjqxVDO9tAmoUXVfJyMKFLVJlosjKrFLLuW4V8VO0= -github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.17.3/go.mod h1:flSX+qf2r/mLgwTavyT/Gjs4dFtHcBmjMcVp/AqpSgc= -github.com/aws/aws-sdk-go-v2/service/ec2 v1.26.0 h1:Q++veaxis1Dg7is9yi+aEPsIBRAgdkUxoIvyud7jOyo= -github.com/aws/aws-sdk-go-v2/service/ec2 v1.26.0/go.mod h1:cIbz+b70nxJafXf9lT07Xj03pef6CsVdYTCCR0DQEQc= -github.com/aws/aws-sdk-go-v2/service/ecr v1.12.0 h1:oDIFK9jio/g88kjEihtkxt2IKelm7LjE75hX4x7rxoU= -github.com/aws/aws-sdk-go-v2/service/ecr v1.12.0/go.mod h1:IoE3h7WVE1zmlQzUHEYJ5JtfrF4g3rCG8mPz+fsp0+s= -github.com/aws/aws-sdk-go-v2/service/eks v1.22.1 h1:f07Bk+xMm0Q8PCzvrBg8Bd6m67CTvZSxQWB0H7ZEJOU= -github.com/aws/aws-sdk-go-v2/service/eks v1.22.1/go.mod h1:YoafRRQM4SnTFwb49e4LCAel6n99q2DMxkeAfbgvq8s= -github.com/aws/aws-sdk-go-v2/service/elasticache v1.16.0 h1:IQbmNCQvPs7LyfdTFTxXsSXp0JS13f0BB3PC9w0VwDI= -github.com/aws/aws-sdk-go-v2/service/elasticache v1.16.0/go.mod h1:6O2ce+L9zaOcKzEYG+vGJHSgDVcz+ucETuwNvkKTzeQ= -github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.10.0 h1:kSyYDcteNkn6x5gGIqNZy/iVsDYzh0SUAFG56TsfDdg= -github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.10.0/go.mod h1:dCzl6Xr3MPAATrjdxRBTE602B/jVrujl7CDfbzu2wks= -github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.10.0 h1:8EWNW3a2FOsCN7I/+fALSTU7CUiUva7b7jMPOWEzTts= -github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.10.0/go.mod h1:8KcTCMET0MiKk9zDLOcGqPqLljtFDzcvCogytSuz324= -github.com/aws/aws-sdk-go-v2/service/iam v1.14.0 h1:j4rKVLd4ASdTCWqCxt/p99S6BpA6bjWdAk48yOL6NnQ= -github.com/aws/aws-sdk-go-v2/service/iam v1.14.0/go.mod h1:O13Qz5IqQmrLCQYw8l4luBDLNxOIlCAYUS0i+0ySOTk= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.5.0 h1:lPLbw4Gn59uoKqvOfSnkJr54XWk5Ak1NK20ZEiSWb3U= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.5.0/go.mod h1:80NaCIH9YU3rzTTs/J/ECATjXuRqzo/wB6ukO6MZ0XY= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.5.2/go.mod h1:FgR1tCsn8C6+Hf+N5qkfrE4IXvUL1RgW87sunJ+5J4I= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21 h1:5C6XgTViSb0bunmU57b3CT+MhxULqHH2721FVA+/kDM= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21/go.mod h1:lRToEJsn+DRA9lW4O9L9+/3hjTkUzlzyzHqn8MTds5k= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.9.2 h1:GnPGH1FGc4fkn0Jbm/8r2+nPOwSJjYPyHSqFSvY1ii8= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.9.2/go.mod h1:eDUYjOYt4Uio7xfHi5jOsO393ZG8TSfZB92a3ZNadWM= -github.com/aws/aws-sdk-go-v2/service/lambda v1.21.1 h1:xS9qXT9z7w59VoK4XI3rxe+GkpDRHgVd4lxapEJW7bE= -github.com/aws/aws-sdk-go-v2/service/lambda v1.21.1/go.mod h1:1/klj5RfSVnRVLC6qnZYnJqL8RcKhi4KHDm5BwnilOY= -github.com/aws/aws-sdk-go-v2/service/rds v1.39.0 h1:SnusHwHQWMZxlS5gvRfzsg1Odq7gWl3STP4aUIqzRGE= -github.com/aws/aws-sdk-go-v2/service/rds v1.39.0/go.mod h1:Ume9NHqT871hUdxIRojWtWsPFyCswQmSjHHhyGot7v0= -github.com/aws/aws-sdk-go-v2/service/redshift v1.17.0 h1:MhHapcuStJuX86Pk9+H6d3pk46xUpdV48NkEItRMyOc= -github.com/aws/aws-sdk-go-v2/service/redshift v1.17.0/go.mod h1:MFxHzFKSXjT0CUjOpTaeeuqxcP6+uuQMvzkhTEdIEUM= -github.com/aws/aws-sdk-go-v2/service/route53 v1.15.0 h1:TtL2aQTyJ/6HOpySI81wUcz5CaLNLCblBEprVYemK/g= -github.com/aws/aws-sdk-go-v2/service/route53 v1.15.0/go.mod h1:UslaPoP9fD1ayK7ywpkIE9ft5gOEhPVJkT66D4OvSrM= -github.com/aws/aws-sdk-go-v2/service/route53resolver v1.10.2 h1:s/s1fJ9r8MKGKOX7dPjfYosuxlGQCKx5EpWjhJfIFAE= -github.com/aws/aws-sdk-go-v2/service/route53resolver v1.10.2/go.mod h1:PC9M9N+FMOYRgqdohQybDyBbfdj7rdK7xt7/IyfphV4= -github.com/aws/aws-sdk-go-v2/service/s3 v1.22.0 h1:J78RE/YNohCGbUyIbc3hr+UwnttfOn2dJUkNfvDkT30= -github.com/aws/aws-sdk-go-v2/service/s3 v1.22.0/go.mod h1:lQ5AeEW2XWzu8hwQ3dCqZFWORQ3RntO0Kq135Xd9VCo= -github.com/aws/aws-sdk-go-v2/service/sns v1.13.0 h1:4nUAjFOrn3879YnSV8HJXcmK8BhBf9W9DUYG0OG3ROY= -github.com/aws/aws-sdk-go-v2/service/sns v1.13.0/go.mod h1:ioTOCJnuDbEBqucork8ySl7X/PtPUKs2/b0pIKb1C3g= -github.com/aws/aws-sdk-go-v2/service/sqs v1.14.0 h1:8Jq7KQDOK81r4VPKuufMCNZ5ngQjMgNnLxYKJaZvg3s= -github.com/aws/aws-sdk-go-v2/service/sqs v1.14.0/go.mod h1:gOsepb5p+dWNJqP37uG78TR3cO0zYlGFLJT9zCCaaX8= -github.com/aws/aws-sdk-go-v2/service/sso v1.7.0 h1:E4fxAg/UE8a6yiLZYv8/EP0uXKPPRImiMau4ift6S/g= -github.com/aws/aws-sdk-go-v2/service/sso v1.7.0/go.mod h1:KnIpszaIdwI33tmc/W/GGXyn22c1USYxA/2KyvoeDY0= -github.com/aws/aws-sdk-go-v2/service/sts v1.12.0 h1:7g0252k2TF3eA1DtfkTQB/tqI41YvbUPaolwTR0/ITc= -github.com/aws/aws-sdk-go-v2/service/sts v1.12.0/go.mod h1:UV2N5HaPfdbDpkgkz4sRzWCvQswZjdO1FfqCWl0t7RA= -github.com/aws/smithy-go v1.8.1/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/aws/smithy-go v1.9.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= -github.com/aws/smithy-go v1.12.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/aws/smithy-go v1.13.3/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/aws/smithy-go v1.13.4/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= -github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/aws-sdk-go-v2 v1.31.0 h1:3V05LbxTSItI5kUqNwhJrrrY1BAXxXt0sN0l72QmG5U= +github.com/aws/aws-sdk-go-v2 v1.31.0/go.mod h1:ztolYtaEUtdpf9Wftr31CJfLVjOnD/CVRkKOOYgF8hA= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5 h1:xDAuZTn4IMm8o1LnBZvmrL8JA1io4o3YWNXgohbf20g= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5/go.mod h1:wYSv6iDS621sEFLfKvpPE2ugjTuGlAG7iROg0hLOkfc= +github.com/aws/aws-sdk-go-v2/config v1.27.39 h1:FCylu78eTGzW1ynHcongXK9YHtoXD5AiiUqq3YfJYjU= +github.com/aws/aws-sdk-go-v2/config v1.27.39/go.mod h1:wczj2hbyskP4LjMKBEZwPRO1shXY+GsQleab+ZXT2ik= +github.com/aws/aws-sdk-go-v2/credentials v1.17.37 h1:G2aOH01yW8X373JK419THj5QVqu9vKEwxSEsGxihoW0= +github.com/aws/aws-sdk-go-v2/credentials v1.17.37/go.mod h1:0ecCjlb7htYCptRD45lXJ6aJDQac6D2NlKGpZqyTG6A= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 h1:C/d03NAmh8C4BZXhuRNboF/DqhBkBCeDiJDcaqIT5pA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14/go.mod h1:7I0Ju7p9mCIdlrfS+JCgqcYD0VXz/N4yozsox+0o078= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 h1:kYQ3H1u0ANr9KEKlGs/jTLrBFPo8P8NaH/w7A01NeeM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18/go.mod h1:r506HmK5JDUh9+Mw4CfGJGSSoqIiLCndAuqXuhbv67Y= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 h1:Z7IdFUONvTcvS7YuhtVxN99v2cCoHRXOS4mTr0B/pUc= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18/go.mod h1:DkKMmksZVVyat+Y+r1dEOgJEfUeA7UngIHWeKsi0yNc= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.18 h1:OWYvKL53l1rbsUmW7bQyJVsYU/Ii3bbAAQIIFNbM0Tk= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.18/go.mod h1:CUx0G1v3wG6l01tUB+j7Y8kclA8NSqK4ef0YG79a4cg= +github.com/aws/aws-sdk-go-v2/service/acm v1.29.3 h1:EpXx6a8u5ZnhBuUr9yj8sEQv67jYkC8/TuRvS8TG248= +github.com/aws/aws-sdk-go-v2/service/acm v1.29.3/go.mod h1:pyj5IBRLA+w27gR7KJY/4lSWoP4XOsyOVsXKAMvWE3s= +github.com/aws/aws-sdk-go-v2/service/acmpca v1.36.3 h1:zyilUf52S7oS/jc0Kwsf38UsRdH9MW98kk7/KWQfL+A= +github.com/aws/aws-sdk-go-v2/service/acmpca v1.36.3/go.mod h1:i+aP0us0oDFVPP86a/xf3tR0uqWv/FYdlMGn2DQ4MTk= +github.com/aws/aws-sdk-go-v2/service/cloudformation v1.54.3 h1:kVbtKOK6sNCqPsXE/7xN93pD090XETITuBNHrrPQsvk= +github.com/aws/aws-sdk-go-v2/service/cloudformation v1.54.3/go.mod h1:85xWVAzH8I6dCauQy7j1nt8CbSELPzGQj45chIZ/qMA= +github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.45.3 h1:MGNJDvz+5wf1CeBNvdmm2Fs1VEtppI07OqxQkOAtVVg= +github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.45.3/go.mod h1:h5enb9YgyDSRi4uGwhSJ89n3iTr32JH71pSkS9T2llI= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.179.2 h1:rGBv2N0zWvNTKnxOfbBH4mNM8WMdDNkaxdqtz152G40= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.179.2/go.mod h1:W6sNzs5T4VpZn1Vy+FMKw8s24vt5k6zPJXcNOK0asBo= +github.com/aws/aws-sdk-go-v2/service/ecr v1.35.3 h1:8/vARxqd0Pn2Gqhp+8PxxTm3HttUMR1i1vBBj7MNFfc= +github.com/aws/aws-sdk-go-v2/service/ecr v1.35.3/go.mod h1:oRaGEExKI6Pqcow+Tt7wpJf73/Srcj/CUJv5Eb9QFhg= +github.com/aws/aws-sdk-go-v2/service/eks v1.49.3 h1:4Aq01bwq1RnyMLAgx/6kB8cqvfLlQet5cWY3MVhlsqU= +github.com/aws/aws-sdk-go-v2/service/eks v1.49.3/go.mod h1:QUjwO93Ri00egMAeWw75dviZBM5pECLx0KNeNaBtTIM= +github.com/aws/aws-sdk-go-v2/service/elasticache v1.41.3 h1:hYP4kYiY2RQ8QDXBkIe9xD6B/fDTlGV3inxusAmpXzQ= +github.com/aws/aws-sdk-go-v2/service/elasticache v1.41.3/go.mod h1:EaaOoWGtdLYKuknbTnluNoN+qUUl6uZ6I7+Uwww9nBg= +github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.27.3 h1:6GwGMmJD+KxJ11vqvKX2jtcyfvurkp33SVp6OxYrIJg= +github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.27.3/go.mod h1:A6rhNF3Qz6pn97WX3DcIK7g6ODOCYR7t698ptify9eM= +github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.38.3 h1:Tcyl8egpRWLz/ch9Pmn4kX75WsleGmnq+Kro9IqU3wA= +github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.38.3/go.mod h1:V/sx2Ja18AlrvTGQsilx8CAH0CPm+hpKdT9RbSpceik= +github.com/aws/aws-sdk-go-v2/service/iam v1.36.3 h1:dV9iimLEHKYAz2qTi+tGAD9QCnAG2pLD7HUEHB7m4mI= +github.com/aws/aws-sdk-go-v2/service/iam v1.36.3/go.mod h1:HSvujsK8xeEHMIB18oMXjSfqaN9cVqpo/MtHJIksQRk= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 h1:QFASJGfT8wMXtuP3D5CRmMjARHv9ZmzFUMJznHDOY3w= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5/go.mod h1:QdZ3OmoIjSX+8D1OPAzPxDfjXASbBMDsz9qvtyIhtik= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.20 h1:rTWjG6AvWekO2B1LHeM3ktU7MqyX9rzWQ7hgzneZW7E= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.20/go.mod h1:RGW2DDpVc8hu6Y6yG8G5CHVmVOAn1oV8rNKOHRJyswg= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 h1:Xbwbmk44URTiHNx6PNo0ujDE6ERlsCKJD3u1zfnzAPg= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20/go.mod h1:oAfOFzUB14ltPZj1rWwRc3d/6OgD76R8KlvU3EqM9Fg= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.18 h1:eb+tFOIl9ZsUe2259/BKPeniKuz4/02zZFH/i4Nf8Rg= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.18/go.mod h1:GVCC2IJNJTmdlyEsSmofEy7EfJncP7DNnXDzRjJ5Keg= +github.com/aws/aws-sdk-go-v2/service/lambda v1.62.1 h1:Psp52CBlJtOVDyI4UMCAfovD4spGvdqapsBJxWZe470= +github.com/aws/aws-sdk-go-v2/service/lambda v1.62.1/go.mod h1:mivSaHqW3Atf5TDU1YyujR+HMv+snxCMoYaVd9d30O4= +github.com/aws/aws-sdk-go-v2/service/rds v1.86.0 h1:XIlc5PiPNJROSs8R4p50IKavXSqjuhIJ0C3JL0KJ2KQ= +github.com/aws/aws-sdk-go-v2/service/rds v1.86.0/go.mod h1:lhiPj6RvoJHWG2STp+k5az55YqGgFLBzkKYdYHgUh9g= +github.com/aws/aws-sdk-go-v2/service/redshift v1.47.3 h1:TRJP6RflPN5A4yRpyXgznsJTJMT46tKigNAKzd7owic= +github.com/aws/aws-sdk-go-v2/service/redshift v1.47.3/go.mod h1:Zco+4iYqPF1u1FXTB0fHaRNRKPi82yw1AHPqJM5pI7A= +github.com/aws/aws-sdk-go-v2/service/route53 v1.44.3 h1:vYmafsIZWxc0EkIovYfjyfekHJogJjnIUXso5o7YPIA= +github.com/aws/aws-sdk-go-v2/service/route53 v1.44.3/go.mod h1:l2ABSKg3AibEJeR/l60cfeGU54UqF3VTgd51pq+vYhU= +github.com/aws/aws-sdk-go-v2/service/route53resolver v1.31.3 h1:kKooBzPdbErEYGYtC4eUyfewKUKEKgWRcRYyGovVoOQ= +github.com/aws/aws-sdk-go-v2/service/route53resolver v1.31.3/go.mod h1:1t0dDWBVPyLQWH3uVw2PBZymRKPUQIlwyHWBbElvjcs= +github.com/aws/aws-sdk-go-v2/service/s3 v1.63.3 h1:3zt8qqznMuAZWDTDpcwv9Xr11M/lVj2FsRR7oYBt0OA= +github.com/aws/aws-sdk-go-v2/service/s3 v1.63.3/go.mod h1:NLTqRLe3pUNu3nTEHI6XlHLKYmc8fbHUdMxAB6+s41Q= +github.com/aws/aws-sdk-go-v2/service/sns v1.32.3 h1:LC5JBrEAdJ0SSRLfNcLzOLsfoc3xO/BAsHiUNcQfDI4= +github.com/aws/aws-sdk-go-v2/service/sns v1.32.3/go.mod h1:ZO606Jfatw51c8q29gHVVCnufg2dq3MnmkNLlTZFrkE= +github.com/aws/aws-sdk-go-v2/service/sqs v1.35.3 h1:Lcs658WFW235QuUfpAdxd8RCy8Va2VUA7/U9iIrcjcY= +github.com/aws/aws-sdk-go-v2/service/sqs v1.35.3/go.mod h1:WuGxWQhu2LXoPGA2HBIbotpwhM6T4hAz0Ip/HjdxfJg= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.3 h1:rs4JCczF805+FDv2tRhZ1NU0RB2H6ryAvsWPanAr72Y= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.3/go.mod h1:XRlMvmad0ZNL+75C5FYdMvbbLkd6qiqz6foR1nA1PXY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.3 h1:S7EPdMVZod8BGKQQPTBK+FcX9g7bKR7c4+HxWqHP7Vg= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.3/go.mod h1:FnvDM4sfa+isJ3kDXIzAB9GAwVSzFzSy97uZ3IsHo4E= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.3 h1:VzudTFrDCIDakXtemR7l6Qzt2+JYsVqo2MxBPt5k8T8= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.3/go.mod h1:yMWe0F+XG0DkRZK5ODZhG7BEFYhLXi2dqGsv6tX0cgI= +github.com/aws/smithy-go v1.21.0 h1:H7L8dtDRk0P1Qm6y0ji7MCYMQObJ5R9CRpyPhRUkLYA= +github.com/aws/smithy-go v1.21.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -395,11 +375,7 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= diff --git a/pkg/clients/acmpca/certificateauthority.go b/pkg/clients/acmpca/certificateauthority.go index de93a0f99c..cddb669d0a 100644 --- a/pkg/clients/acmpca/certificateauthority.go +++ b/pkg/clients/acmpca/certificateauthority.go @@ -24,6 +24,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/acmpca" "github.com/aws/aws-sdk-go-v2/service/acmpca/types" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/acmpca/v1beta1" "github.com/crossplane-contrib/provider-aws/pkg/utils/pointer" @@ -100,7 +101,7 @@ func GenerateRevocationConfiguration(p *v1beta1.RevocationConfiguration) *types. m := &types.RevocationConfiguration{ CrlConfiguration: &types.CrlConfiguration{ CustomCname: p.CustomCname, - Enabled: p.Enabled, + Enabled: &p.Enabled, ExpirationInDays: p.ExpirationInDays, S3BucketName: p.S3BucketName, }, @@ -127,7 +128,7 @@ func LateInitializeCertificateAuthority(in *v1beta1.CertificateAuthorityParamete in.Status = pointer.ToOrNilIfZeroValue(string(certificateAuthority.Status)) } - if certificateAuthority.RevocationConfiguration.CrlConfiguration.Enabled { + if ptr.Deref(certificateAuthority.RevocationConfiguration.CrlConfiguration.Enabled, false) { if in.RevocationConfiguration.ExpirationInDays == nil && certificateAuthority.RevocationConfiguration.CrlConfiguration.ExpirationInDays != nil { in.RevocationConfiguration.ExpirationInDays = certificateAuthority.RevocationConfiguration.CrlConfiguration.ExpirationInDays } @@ -145,7 +146,7 @@ func LateInitializeCertificateAuthority(in *v1beta1.CertificateAuthorityParamete // IsCertificateAuthorityUpToDate checks whether there is a change in any of the modifiable fields. func IsCertificateAuthorityUpToDate(p *v1beta1.CertificateAuthority, cd types.CertificateAuthority, tags []types.Tag) bool { //nolint:gocyclo - if cd.RevocationConfiguration.CrlConfiguration.Enabled { + if ptr.Deref(cd.RevocationConfiguration.CrlConfiguration.Enabled, false) { if !strings.EqualFold(aws.ToString(p.Spec.ForProvider.RevocationConfiguration.CustomCname), aws.ToString(cd.RevocationConfiguration.CrlConfiguration.CustomCname)) { return false } @@ -154,7 +155,7 @@ func IsCertificateAuthorityUpToDate(p *v1beta1.CertificateAuthority, cd types.Ce return false } - if p.Spec.ForProvider.RevocationConfiguration.Enabled != cd.RevocationConfiguration.CrlConfiguration.Enabled { + if p.Spec.ForProvider.RevocationConfiguration.Enabled != ptr.Deref(cd.RevocationConfiguration.CrlConfiguration.Enabled, false) { return false } diff --git a/pkg/clients/acmpca/certificateauthority_test.go b/pkg/clients/acmpca/certificateauthority_test.go index d1da9f56b2..855fc0df7c 100644 --- a/pkg/clients/acmpca/certificateauthority_test.go +++ b/pkg/clients/acmpca/certificateauthority_test.go @@ -24,6 +24,7 @@ import ( "github.com/aws/smithy-go/document" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/acmpca/v1beta1" "github.com/crossplane-contrib/provider-aws/pkg/utils/pointer" @@ -195,7 +196,7 @@ func TestGenerateRevocationConfiguration(t *testing.T) { out: &types.RevocationConfiguration{ CrlConfiguration: &types.CrlConfiguration{ CustomCname: pointer.ToOrNilIfZeroValue(customCname), - Enabled: revocationConfigurationEnabled, + Enabled: &revocationConfigurationEnabled, S3BucketName: pointer.ToOrNilIfZeroValue(s3BucketName), }, }, @@ -239,7 +240,7 @@ func TestLateInitializeCertificateAuthority(t *testing.T) { }, RevocationConfiguration: &types.RevocationConfiguration{ CrlConfiguration: &types.CrlConfiguration{ - Enabled: false, + Enabled: ptr.To(false), }, }, }, @@ -285,7 +286,7 @@ func TestIsCertificateAuthorityUpToDate(t *testing.T) { CrlConfiguration: &types.CrlConfiguration{ CustomCname: pointer.ToOrNilIfZeroValue(customCname), S3BucketName: pointer.ToOrNilIfZeroValue(s3BucketName), - Enabled: true, + Enabled: ptr.To(true), }, }, Status: types.CertificateAuthorityStatus(status), diff --git a/pkg/clients/database/rds.go b/pkg/clients/database/rds.go index 4c98f5280b..10d18e7e1b 100644 --- a/pkg/clients/database/rds.go +++ b/pkg/clients/database/rds.go @@ -301,7 +301,7 @@ func GenerateRestoreRDSInstanceToPointInTimeInput(name string, p *v1beta1.RDSIns TargetDBInstanceIdentifier: aws.String(name), RestoreTime: restoreTime, - UseLatestRestorableTime: p.RestoreFrom.PointInTime.UseLatestRestorableTime, + UseLatestRestorableTime: &p.RestoreFrom.PointInTime.UseLatestRestorableTime, SourceDBInstanceAutomatedBackupsArn: p.RestoreFrom.PointInTime.SourceDBInstanceAutomatedBackupsArn, SourceDBInstanceIdentifier: p.RestoreFrom.PointInTime.SourceDBInstanceIdentifier, SourceDbiResourceId: p.RestoreFrom.PointInTime.SourceDbiResourceID, @@ -399,8 +399,8 @@ func GenerateModifyDBInstanceInput(name string, p *v1beta1.RDSInstanceParameters m := &rds.ModifyDBInstanceInput{ DBInstanceIdentifier: aws.String(name), AllocatedStorage: pointer.ToIntAsInt32Ptr(p.AllocatedStorage), - AllowMajorVersionUpgrade: aws.ToBool(p.AllowMajorVersionUpgrade), - ApplyImmediately: aws.ToBool(p.ApplyModificationsImmediately), + AllowMajorVersionUpgrade: p.AllowMajorVersionUpgrade, + ApplyImmediately: p.ApplyModificationsImmediately, AutoMinorVersionUpgrade: p.AutoMinorVersionUpgrade, BackupRetentionPeriod: pointer.ToIntAsInt32Ptr(p.BackupRetentionPeriod), CACertificateIdentifier: p.CACertificateIdentifier, @@ -455,12 +455,12 @@ func GenerateModifyDBInstanceInput(name string, p *v1beta1.RDSInstanceParameters // rds.DBInstance. func GenerateObservation(db rdstypes.DBInstance) v1beta1.RDSInstanceObservation { //nolint:gocyclo o := v1beta1.RDSInstanceObservation{ - AllocatedStorage: int(db.AllocatedStorage), + AllocatedStorage: int(ptr.Deref(db.AllocatedStorage, 0)), AWSBackupRecoveryPointARN: aws.ToString(db.AwsBackupRecoveryPointArn), - BackupRetentionPeriod: int(db.BackupRetentionPeriod), + BackupRetentionPeriod: int(ptr.Deref(db.BackupRetentionPeriod, 0)), DBInstanceStatus: aws.ToString(db.DBInstanceStatus), DBInstanceArn: aws.ToString(db.DBInstanceArn), - DBInstancePort: int(db.DbInstancePort), + DBInstancePort: int(ptr.Deref(db.DbInstancePort, 0)), DBResourceID: aws.ToString(db.DbiResourceId), EnabledCloudwatchLogsExports: db.EnabledCloudwatchLogsExports, EnhancedMonitoringResourceArn: aws.ToString(db.EnhancedMonitoringResourceArn), @@ -534,7 +534,7 @@ func GenerateObservation(db rdstypes.DBInstance) v1beta1.RDSInstanceObservation o.Endpoint = v1beta1.Endpoint{ Address: aws.ToString(db.Endpoint.Address), HostedZoneID: aws.ToString(db.Endpoint.HostedZoneId), - Port: int(db.Endpoint.Port), + Port: int(ptr.Deref(db.Endpoint.Port, 0)), } } if len(db.OptionGroupMemberships) != 0 { @@ -583,7 +583,7 @@ func GenerateObservation(db rdstypes.DBInstance) v1beta1.RDSInstanceObservation Message: aws.ToString(val.Message), Status: aws.ToString(val.Status), StatusType: aws.ToString(val.StatusType), - Normal: val.Normal, + Normal: ptr.Deref(val.Normal, false), } } } @@ -608,17 +608,17 @@ func LateInitialize(in *v1beta1.RDSInstanceParameters, db *rdstypes.DBInstance) in.DBInstanceClass = pointer.LateInitializeValueFromPtr(in.DBInstanceClass, db.DBInstanceClass) in.Engine = pointer.LateInitializeValueFromPtr(in.Engine, db.Engine) - in.AllocatedStorage = pointer.LateInitializeIntFrom32Ptr(in.AllocatedStorage, &db.AllocatedStorage) - in.AutoMinorVersionUpgrade = pointer.LateInitialize(in.AutoMinorVersionUpgrade, ptr.To(db.AutoMinorVersionUpgrade)) + in.AllocatedStorage = pointer.LateInitializeIntFrom32Ptr(in.AllocatedStorage, db.AllocatedStorage) + in.AutoMinorVersionUpgrade = pointer.LateInitialize(in.AutoMinorVersionUpgrade, db.AutoMinorVersionUpgrade) in.AvailabilityZone = pointer.LateInitialize(in.AvailabilityZone, db.AvailabilityZone) - in.BackupRetentionPeriod = pointer.LateInitializeIntFromInt32Ptr(in.BackupRetentionPeriod, &db.BackupRetentionPeriod) + in.BackupRetentionPeriod = pointer.LateInitializeIntFromInt32Ptr(in.BackupRetentionPeriod, db.BackupRetentionPeriod) in.CACertificateIdentifier = pointer.LateInitialize(in.CACertificateIdentifier, db.CACertificateIdentifier) in.CharacterSetName = pointer.LateInitialize(in.CharacterSetName, db.CharacterSetName) - in.CopyTagsToSnapshot = pointer.LateInitialize(in.CopyTagsToSnapshot, ptr.To(db.CopyTagsToSnapshot)) + in.CopyTagsToSnapshot = pointer.LateInitialize(in.CopyTagsToSnapshot, db.CopyTagsToSnapshot) in.DBClusterIdentifier = pointer.LateInitialize(in.DBClusterIdentifier, db.DBClusterIdentifier) in.DBName = pointer.LateInitialize(in.DBName, db.DBName) - in.DeletionProtection = pointer.LateInitialize(in.DeletionProtection, ptr.To(db.DeletionProtection)) - in.EnableIAMDatabaseAuthentication = pointer.LateInitialize(in.EnableIAMDatabaseAuthentication, ptr.To(db.IAMDatabaseAuthenticationEnabled)) + in.DeletionProtection = pointer.LateInitialize(in.DeletionProtection, db.DeletionProtection) + in.EnableIAMDatabaseAuthentication = pointer.LateInitialize(in.EnableIAMDatabaseAuthentication, db.IAMDatabaseAuthenticationEnabled) in.EnablePerformanceInsights = pointer.LateInitialize(in.EnablePerformanceInsights, db.PerformanceInsightsEnabled) in.IOPS = pointer.LateInitializeIntFrom32Ptr(in.IOPS, db.Iops) in.KMSKeyID = pointer.LateInitialize(in.KMSKeyID, db.KmsKeyId) @@ -627,14 +627,14 @@ func LateInitialize(in *v1beta1.RDSInstanceParameters, db *rdstypes.DBInstance) in.MaxAllocatedStorage = pointer.LateInitializeIntFrom32Ptr(in.MaxAllocatedStorage, db.MaxAllocatedStorage) in.MonitoringInterval = pointer.LateInitializeIntFrom32Ptr(in.MonitoringInterval, db.MonitoringInterval) in.MonitoringRoleARN = pointer.LateInitialize(in.MonitoringRoleARN, db.MonitoringRoleArn) - in.MultiAZ = pointer.LateInitialize(in.MultiAZ, ptr.To(db.MultiAZ)) + in.MultiAZ = pointer.LateInitialize(in.MultiAZ, db.MultiAZ) in.PerformanceInsightsKMSKeyID = pointer.LateInitialize(in.PerformanceInsightsKMSKeyID, db.PerformanceInsightsKMSKeyId) in.PerformanceInsightsRetentionPeriod = pointer.LateInitializeIntFrom32Ptr(in.PerformanceInsightsRetentionPeriod, db.PerformanceInsightsRetentionPeriod) in.PreferredBackupWindow = pointer.LateInitialize(in.PreferredBackupWindow, db.PreferredBackupWindow) in.PreferredMaintenanceWindow = pointer.LateInitialize(in.PreferredMaintenanceWindow, db.PreferredMaintenanceWindow) in.PromotionTier = pointer.LateInitializeIntFrom32Ptr(in.PromotionTier, db.PromotionTier) - in.PubliclyAccessible = pointer.LateInitialize(in.PubliclyAccessible, ptr.To(db.PubliclyAccessible)) - in.StorageEncrypted = pointer.LateInitialize(in.StorageEncrypted, ptr.To(db.StorageEncrypted)) + in.PubliclyAccessible = pointer.LateInitialize(in.PubliclyAccessible, db.PubliclyAccessible) + in.StorageEncrypted = pointer.LateInitialize(in.StorageEncrypted, db.StorageEncrypted) in.StorageThroughput = pointer.LateInitializeIntFrom32Ptr(in.StorageThroughput, db.StorageThroughput) in.StorageType = pointer.LateInitialize(in.StorageType, db.StorageType) in.Timezone = pointer.LateInitialize(in.Timezone, db.Timezone) @@ -643,7 +643,7 @@ func LateInitialize(in *v1beta1.RDSInstanceParameters, db *rdstypes.DBInstance) // some reason. See the bug here: // https://github.com/aws/aws-sdk-java/issues/924#issuecomment-658089792 if db.Endpoint != nil { - in.Port = pointer.LateInitializeIntFrom32Ptr(in.Port, &db.Endpoint.Port) + in.Port = pointer.LateInitializeIntFrom32Ptr(in.Port, db.Endpoint.Port) } if len(in.DBSecurityGroups) == 0 && len(db.DBSecurityGroups) != 0 { diff --git a/pkg/clients/database/rds_test.go b/pkg/clients/database/rds_test.go index 750e0cd043..824e3b5ebb 100644 --- a/pkg/clients/database/rds_test.go +++ b/pkg/clients/database/rds_test.go @@ -58,7 +58,6 @@ var ( enabledCloudwatchExports = []string{"test"} enabledCloudwatchExportsNone = []string{} engine = "5.6.41" - falseFlag = false iamRole = "iamRole" instanceClass = "class" kmsID = "kms" @@ -113,7 +112,7 @@ func TestCreatePatch(t *testing.T) { "SameFields": { args: args{ db: &rdstypes.DBInstance{ - AllocatedStorage: allocatedStorage, + AllocatedStorage: &allocatedStorage, CharacterSetName: &characterSetName, DBName: &dbName, }, @@ -130,7 +129,7 @@ func TestCreatePatch(t *testing.T) { "DifferentFields": { args: args{ db: &rdstypes.DBInstance{ - AllocatedStorage: allocatedStorage, + AllocatedStorage: &allocatedStorage, CharacterSetName: &characterSetName, DBName: &dbName, AvailabilityZone: ptr.To("az1"), @@ -153,7 +152,7 @@ func TestCreatePatch(t *testing.T) { args: args{ db: &rdstypes.DBInstance{ AvailabilityZone: ptr.To("az1"), - MultiAZ: true, + MultiAZ: ptr.To(true), }, p: &v1beta1.RDSInstanceParameters{ AvailabilityZone: ptr.To("az2"), @@ -192,7 +191,7 @@ func TestIsUpToDate(t *testing.T) { "SameFields": { args: args{ db: rdstypes.DBInstance{ - AllocatedStorage: allocatedStorage, + AllocatedStorage: &allocatedStorage, CharacterSetName: &characterSetName, DBName: &dbName, }, @@ -211,7 +210,7 @@ func TestIsUpToDate(t *testing.T) { "IgnoreDeletionOptions": { args: args{ db: rdstypes.DBInstance{ - AllocatedStorage: allocatedStorage, + AllocatedStorage: &allocatedStorage, CharacterSetName: &characterSetName, DBName: &dbName, }, @@ -233,7 +232,7 @@ func TestIsUpToDate(t *testing.T) { "DifferentFields": { args: args{ db: rdstypes.DBInstance{ - AllocatedStorage: allocatedStorage, + AllocatedStorage: &allocatedStorage, CharacterSetName: &characterSetName, DBName: &dbName, }, @@ -468,7 +467,7 @@ func TestIsUpToDate(t *testing.T) { args: args{ db: rdstypes.DBInstance{ AvailabilityZone: ptr.To("az1"), - MultiAZ: true, + MultiAZ: ptr.To(true), }, r: v1beta1.RDSInstance{ Spec: v1beta1.RDSInstanceSpec{ @@ -784,7 +783,7 @@ func TestGenerateObservation(t *testing.T) { endpoint := rdstypes.Endpoint{ Address: &address, HostedZoneId: &zone, - Port: port32, + Port: &port32, } pendingModifiedValues := rdstypes.PendingModifiedValues{ AllocatedStorage: &storage32, @@ -818,9 +817,9 @@ func TestGenerateObservation(t *testing.T) { DBInstanceStatus: &status, DBInstanceArn: &arn, InstanceCreateTime: &createTime, - DbInstancePort: port32, + DbInstancePort: &port32, DbiResourceId: &resourceID, - BackupRetentionPeriod: retention32, + BackupRetentionPeriod: &retention32, EnabledCloudwatchLogsExports: enabledCloudwatchExports, EnhancedMonitoringResourceArn: &arn, PerformanceInsightsEnabled: &trueFlag, @@ -848,7 +847,7 @@ func TestGenerateObservation(t *testing.T) { Message: &status, Status: &status, StatusType: &status, - Normal: normal, + Normal: &normal, }}, VpcSecurityGroups: []rdstypes.VpcSecurityGroupMembership{{ Status: &status, @@ -922,7 +921,7 @@ func TestGenerateObservation(t *testing.T) { DBInstanceStatus: &status, DBInstanceArn: &arn, InstanceCreateTime: &createTime, - DbInstancePort: port32, + DbInstancePort: &port32, DbiResourceId: &resourceID, EnhancedMonitoringResourceArn: &arn, PerformanceInsightsEnabled: &trueFlag, @@ -946,7 +945,7 @@ func TestGenerateObservation(t *testing.T) { Message: &status, Status: &status, StatusType: &status, - Normal: normal, + Normal: &normal, }}, VpcSecurityGroups: []rdstypes.VpcSecurityGroupMembership{{ Status: &status, @@ -1050,19 +1049,19 @@ func TestLateInitialize(t *testing.T) { }{ "AllFields": { rds: rdstypes.DBInstance{ - AllocatedStorage: storage32, + AllocatedStorage: &storage32, DBInstanceClass: &instanceClass, Engine: &engine, - AutoMinorVersionUpgrade: trueFlag, + AutoMinorVersionUpgrade: &trueFlag, AvailabilityZone: &az, - BackupRetentionPeriod: storage32, + BackupRetentionPeriod: &storage32, CACertificateIdentifier: &name, CharacterSetName: &name, - CopyTagsToSnapshot: trueFlag, + CopyTagsToSnapshot: &trueFlag, DBClusterIdentifier: &clusterName, DBName: &name, - DeletionProtection: trueFlag, - IAMDatabaseAuthenticationEnabled: trueFlag, + DeletionProtection: &trueFlag, + IAMDatabaseAuthenticationEnabled: &trueFlag, PerformanceInsightsEnabled: &trueFlag, Iops: &storage32, KmsKeyId: &kmsID, @@ -1070,15 +1069,15 @@ func TestLateInitialize(t *testing.T) { MasterUsername: &username, MonitoringInterval: &monitoring32, MonitoringRoleArn: &arn, - MultiAZ: multiAZ, + MultiAZ: &multiAZ, PerformanceInsightsKMSKeyId: &kmsID, PerformanceInsightsRetentionPeriod: &retention32, - Endpoint: &rdstypes.Endpoint{Port: port32}, + Endpoint: &rdstypes.Endpoint{Port: &port32}, PreferredBackupWindow: &window, PreferredMaintenanceWindow: &window, PromotionTier: &tier32, - PubliclyAccessible: trueFlag, - StorageEncrypted: trueFlag, + PubliclyAccessible: &trueFlag, + StorageEncrypted: &trueFlag, StorageThroughput: &storage32, StorageType: &storageType, Timezone: &zone, @@ -1146,15 +1145,7 @@ func TestLateInitialize(t *testing.T) { }, params: v1beta1.RDSInstanceParameters{}, want: v1beta1.RDSInstanceParameters{ - DBSubnetGroupName: subnetGroup.DBSubnetGroupName, - AutoMinorVersionUpgrade: &falseFlag, - BackupRetentionPeriod: new(int), - CopyTagsToSnapshot: &falseFlag, - DeletionProtection: &falseFlag, - EnableIAMDatabaseAuthentication: &falseFlag, - MultiAZ: &falseFlag, - PubliclyAccessible: &falseFlag, - StorageEncrypted: &falseFlag, + DBSubnetGroupName: subnetGroup.DBSubnetGroupName, }, }, "SubnetGroupNameNotOverwritten": { @@ -1165,15 +1156,7 @@ func TestLateInitialize(t *testing.T) { DBSubnetGroupName: &existingName, }, want: v1beta1.RDSInstanceParameters{ - DBSubnetGroupName: &existingName, - AutoMinorVersionUpgrade: &falseFlag, - BackupRetentionPeriod: new(int), - CopyTagsToSnapshot: &falseFlag, - DeletionProtection: &falseFlag, - EnableIAMDatabaseAuthentication: &falseFlag, - MultiAZ: &falseFlag, - PubliclyAccessible: &falseFlag, - StorageEncrypted: &falseFlag, + DBSubnetGroupName: &existingName, }, }, "SecurityGroupNotOverwritten": { @@ -1185,15 +1168,6 @@ func TestLateInitialize(t *testing.T) { }, want: v1beta1.RDSInstanceParameters{ DBSecurityGroups: []string{"newGroup"}, - - AutoMinorVersionUpgrade: &falseFlag, - BackupRetentionPeriod: new(int), - CopyTagsToSnapshot: &falseFlag, - DeletionProtection: &falseFlag, - EnableIAMDatabaseAuthentication: &falseFlag, - MultiAZ: &falseFlag, - PubliclyAccessible: &falseFlag, - StorageEncrypted: &falseFlag, }, }, "ProcessorFeaturesNotOverwritten": { @@ -1214,15 +1188,6 @@ func TestLateInitialize(t *testing.T) { Name: existingName, Value: existingName, }}, - - AutoMinorVersionUpgrade: &falseFlag, - BackupRetentionPeriod: new(int), - CopyTagsToSnapshot: &falseFlag, - DeletionProtection: &falseFlag, - EnableIAMDatabaseAuthentication: &falseFlag, - MultiAZ: &falseFlag, - PubliclyAccessible: &falseFlag, - StorageEncrypted: &falseFlag, }, }, "VPCSecurityGroupIdsNotOverwritten": { @@ -1243,15 +1208,6 @@ func TestLateInitialize(t *testing.T) { Name: existingName, Value: existingName, }}, - - AutoMinorVersionUpgrade: &falseFlag, - BackupRetentionPeriod: new(int), - CopyTagsToSnapshot: &falseFlag, - DeletionProtection: &falseFlag, - EnableIAMDatabaseAuthentication: &falseFlag, - MultiAZ: &falseFlag, - PubliclyAccessible: &falseFlag, - StorageEncrypted: &falseFlag, }, }, "EngineVersion": { @@ -1263,30 +1219,12 @@ func TestLateInitialize(t *testing.T) { }, want: v1beta1.RDSInstanceParameters{ EngineVersion: &engine, - - AutoMinorVersionUpgrade: &falseFlag, - BackupRetentionPeriod: new(int), - CopyTagsToSnapshot: &falseFlag, - DeletionProtection: &falseFlag, - EnableIAMDatabaseAuthentication: &falseFlag, - MultiAZ: &falseFlag, - PubliclyAccessible: &falseFlag, - StorageEncrypted: &falseFlag, }, }, "EmptyInstance": { rds: rdstypes.DBInstance{}, params: v1beta1.RDSInstanceParameters{}, - want: v1beta1.RDSInstanceParameters{ - AutoMinorVersionUpgrade: &falseFlag, - BackupRetentionPeriod: new(int), - CopyTagsToSnapshot: &falseFlag, - DeletionProtection: &falseFlag, - EnableIAMDatabaseAuthentication: &falseFlag, - MultiAZ: &falseFlag, - PubliclyAccessible: &falseFlag, - StorageEncrypted: &falseFlag, - }, + want: v1beta1.RDSInstanceParameters{}, }, } @@ -1367,8 +1305,8 @@ func TestGenerateModifyDBInstanceInput(t *testing.T) { want: rds.ModifyDBInstanceInput{ DBInstanceIdentifier: &allFieldsName, AllocatedStorage: &storage32, - AllowMajorVersionUpgrade: trueFlag, - ApplyImmediately: trueFlag, + AllowMajorVersionUpgrade: &trueFlag, + ApplyImmediately: &trueFlag, AutoMinorVersionUpgrade: &trueFlag, BackupRetentionPeriod: &retention32, CACertificateIdentifier: &name, diff --git a/pkg/clients/ec2/internetgateway.go b/pkg/clients/ec2/internetgateway.go index 8a69208865..c73ec5899e 100644 --- a/pkg/clients/ec2/internetgateway.go +++ b/pkg/clients/ec2/internetgateway.go @@ -77,7 +77,7 @@ func LateInitializeIG(in *v1beta1.InternetGatewayParameters, ig *ec2types.Intern if ig == nil { return } - if ig.Attachments != nil && len(ig.Attachments) > 0 { + if len(ig.Attachments) > 0 { in.VPCID = pointer.LateInitialize(in.VPCID, ig.Attachments[0].VpcId) } if len(in.Tags) == 0 && len(ig.Tags) != 0 { diff --git a/pkg/clients/ec2/subnet.go b/pkg/clients/ec2/subnet.go index 24caf027e1..b7e2806388 100644 --- a/pkg/clients/ec2/subnet.go +++ b/pkg/clients/ec2/subnet.go @@ -68,7 +68,7 @@ func LateInitializeSubnet(in *v1beta1.SubnetParameters, s *ec2types.Subnet) { in.MapPublicIPOnLaunch = pointer.LateInitialize(in.MapPublicIPOnLaunch, s.MapPublicIpOnLaunch) in.VPCID = pointer.LateInitialize(in.VPCID, s.VpcId) - if s.Ipv6CidrBlockAssociationSet != nil && len(s.Ipv6CidrBlockAssociationSet) > 0 { + if len(s.Ipv6CidrBlockAssociationSet) > 0 { in.IPv6CIDRBlock = pointer.LateInitialize(in.IPv6CIDRBlock, s.Ipv6CidrBlockAssociationSet[0].Ipv6CidrBlock) } diff --git a/pkg/clients/elasticache/convert/zz_converter.go b/pkg/clients/elasticache/convert/zz_converter.go index 54e43bbe95..8d5468d6ce 100755 --- a/pkg/clients/elasticache/convert/zz_converter.go +++ b/pkg/clients/elasticache/convert/zz_converter.go @@ -32,7 +32,12 @@ func (c *ConverterImpl) DeepCopyAWSCacheCluster(source *types.CacheCluster) *typ } typesCacheCluster.AuthTokenEnabled = pBool2 typesCacheCluster.AuthTokenLastModifiedDate = c.pTimeTimeToPTimeTime((*source).AuthTokenLastModifiedDate) - typesCacheCluster.AutoMinorVersionUpgrade = (*source).AutoMinorVersionUpgrade + var pBool3 *bool + if (*source).AutoMinorVersionUpgrade != nil { + xbool3 := *(*source).AutoMinorVersionUpgrade + pBool3 = &xbool3 + } + typesCacheCluster.AutoMinorVersionUpgrade = pBool3 typesCacheCluster.CacheClusterCreateTime = c.pTimeTimeToPTimeTime((*source).CacheClusterCreateTime) var pString2 *string if (*source).CacheClusterId != nil { @@ -94,6 +99,7 @@ func (c *ConverterImpl) DeepCopyAWSCacheCluster(source *types.CacheCluster) *typ pString8 = &xstring8 } typesCacheCluster.EngineVersion = pString8 + typesCacheCluster.IpDiscovery = types.IpDiscovery((*source).IpDiscovery) var typesLogDeliveryConfigurationList []types.LogDeliveryConfiguration if (*source).LogDeliveryConfigurations != nil { typesLogDeliveryConfigurationList = make([]types.LogDeliveryConfiguration, len((*source).LogDeliveryConfigurations)) @@ -102,6 +108,7 @@ func (c *ConverterImpl) DeepCopyAWSCacheCluster(source *types.CacheCluster) *typ } } typesCacheCluster.LogDeliveryConfigurations = typesLogDeliveryConfigurationList + typesCacheCluster.NetworkType = types.NetworkType((*source).NetworkType) typesCacheCluster.NotificationConfiguration = c.pTypesNotificationConfigurationToPTypesNotificationConfiguration((*source).NotificationConfiguration) var pInt32 *int32 if (*source).NumCacheNodes != nil { @@ -134,7 +141,12 @@ func (c *ConverterImpl) DeepCopyAWSCacheCluster(source *types.CacheCluster) *typ pString12 = &xstring12 } typesCacheCluster.ReplicationGroupId = pString12 - typesCacheCluster.ReplicationGroupLogDeliveryEnabled = (*source).ReplicationGroupLogDeliveryEnabled + var pBool4 *bool + if (*source).ReplicationGroupLogDeliveryEnabled != nil { + xbool4 := *(*source).ReplicationGroupLogDeliveryEnabled + pBool4 = &xbool4 + } + typesCacheCluster.ReplicationGroupLogDeliveryEnabled = pBool4 var typesSecurityGroupMembershipList []types.SecurityGroupMembership if (*source).SecurityGroups != nil { typesSecurityGroupMembershipList = make([]types.SecurityGroupMembership, len((*source).SecurityGroups)) @@ -155,12 +167,13 @@ func (c *ConverterImpl) DeepCopyAWSCacheCluster(source *types.CacheCluster) *typ pString13 = &xstring13 } typesCacheCluster.SnapshotWindow = pString13 - var pBool3 *bool + var pBool5 *bool if (*source).TransitEncryptionEnabled != nil { - xbool3 := *(*source).TransitEncryptionEnabled - pBool3 = &xbool3 + xbool5 := *(*source).TransitEncryptionEnabled + pBool5 = &xbool5 } - typesCacheCluster.TransitEncryptionEnabled = pBool3 + typesCacheCluster.TransitEncryptionEnabled = pBool5 + typesCacheCluster.TransitEncryptionMode = types.TransitEncryptionMode((*source).TransitEncryptionMode) pTypesCacheCluster = &typesCacheCluster } return pTypesCacheCluster @@ -236,7 +249,12 @@ func (c *ConverterImpl) pTypesEndpointToPTypesEndpoint(source *types.Endpoint) * pString = &xstring } typesEndpoint.Address = pString - typesEndpoint.Port = (*source).Port + var pInt32 *int32 + if (*source).Port != nil { + xint32 := *(*source).Port + pInt32 = &xint32 + } + typesEndpoint.Port = pInt32 pTypesEndpoint = &typesEndpoint } return pTypesEndpoint @@ -314,6 +332,13 @@ func (c *ConverterImpl) pTypesPendingModifiedValuesToPTypesPendingModifiedValues pInt32 = &xint32 } typesPendingModifiedValues.NumCacheNodes = pInt32 + var pBool *bool + if (*source).TransitEncryptionEnabled != nil { + xbool := *(*source).TransitEncryptionEnabled + pBool = &xbool + } + typesPendingModifiedValues.TransitEncryptionEnabled = pBool + typesPendingModifiedValues.TransitEncryptionMode = types.TransitEncryptionMode((*source).TransitEncryptionMode) pTypesPendingModifiedValues = &typesPendingModifiedValues } return pTypesPendingModifiedValues diff --git a/pkg/clients/elasticache/elasticache.go b/pkg/clients/elasticache/elasticache.go index abd2402735..df80a6ff7b 100644 --- a/pkg/clients/elasticache/elasticache.go +++ b/pkg/clients/elasticache/elasticache.go @@ -31,6 +31,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/pkg/errors" + "k8s.io/utils/ptr" cachev1alpha1 "github.com/crossplane-contrib/provider-aws/apis/cache/v1alpha1" "github.com/crossplane-contrib/provider-aws/apis/cache/v1beta1" @@ -140,7 +141,7 @@ func NewCreateReplicationGroupInput(g v1beta1.ReplicationGroupParameters, id str func NewModifyReplicationGroupInput(g v1beta1.ReplicationGroupParameters, id string) *elasticache.ModifyReplicationGroupInput { return &elasticache.ModifyReplicationGroupInput{ ReplicationGroupId: aws.String(id), - ApplyImmediately: g.ApplyModificationsImmediately, + ApplyImmediately: &g.ApplyModificationsImmediately, AutomaticFailoverEnabled: g.AutomaticFailoverEnabled, CacheNodeType: aws.String(g.CacheNodeType), CacheParameterGroupName: g.CacheParameterGroupName, @@ -163,15 +164,15 @@ func NewModifyReplicationGroupInput(g v1beta1.ReplicationGroupParameters, id str // shard configuration modification input suitable for use with the AWS API. func NewModifyReplicationGroupShardConfigurationInput(g v1beta1.ReplicationGroupParameters, id string, rg elasticachetypes.ReplicationGroup) *elasticache.ModifyReplicationGroupShardConfigurationInput { input := &elasticache.ModifyReplicationGroupShardConfigurationInput{ - ApplyImmediately: g.ApplyModificationsImmediately, - NodeGroupCount: int32(*g.NumNodeGroups), + ApplyImmediately: &g.ApplyModificationsImmediately, + NodeGroupCount: pointer.ToIntAsInt32Ptr(g.NumNodeGroups), ReplicationGroupId: aws.String(id), } // For scale down we must name the nodes. This code picks the oldest rg // now, but there might be a better algorithm, such as the one with least // data - remove := len(rg.NodeGroups) - int(input.NodeGroupCount) + remove := len(rg.NodeGroups) - int(ptr.Deref(input.NodeGroupCount, 0)) for i := 0; i < remove; i++ { input.NodeGroupsToRemove = append(input.NodeGroupsToRemove, aws.ToString(rg.NodeGroups[i].NodeGroupId)) } @@ -207,7 +208,7 @@ func NewListTagsForResourceInput(arn *string) *elasticache.ListTagsForResourceIn // the number of replicaGroup cache clusters func NewDecreaseReplicaCountInput(replicationGroupID string, newReplicaCount *int32) *elasticache.DecreaseReplicaCountInput { return &elasticache.DecreaseReplicaCountInput{ - ApplyImmediately: true, // false is not supported by the API + ApplyImmediately: ptr.To(true), // false is not supported by the API ReplicationGroupId: &replicationGroupID, NewReplicaCount: newReplicaCount, } @@ -218,7 +219,7 @@ func NewDecreaseReplicaCountInput(replicationGroupID string, newReplicaCount *in // the number of replicaGroup cache clusters func NewIncreaseReplicaCountInput(replicationGroupID string, newReplicaCount *int32) *elasticache.IncreaseReplicaCountInput { return &elasticache.IncreaseReplicaCountInput{ - ApplyImmediately: true, // false is not supported by the API + ApplyImmediately: ptr.To(true), // false is not supported by the API ReplicationGroupId: &replicationGroupID, NewReplicaCount: newReplicaCount, } @@ -530,13 +531,13 @@ func generateNodeGroup(ng elasticachetypes.NodeGroup) v1beta1.NodeGroup { if ng.ReaderEndpoint != nil { r.ReaderEndpoint = v1beta1.Endpoint{ Address: pointer.StringValue(ng.ReaderEndpoint.Address), - Port: int(ng.ReaderEndpoint.Port), + Port: int(ptr.Deref(ng.ReaderEndpoint.Port, 0)), } } if ng.PrimaryEndpoint != nil { r.PrimaryEndpoint = v1beta1.Endpoint{ Address: pointer.StringValue(ng.PrimaryEndpoint.Address), - Port: int(ng.PrimaryEndpoint.Port), + Port: int(ptr.Deref(ng.PrimaryEndpoint.Port, 0)), } } if len(ng.NodeGroupMembers) != 0 { @@ -551,7 +552,7 @@ func generateNodeGroup(ng elasticachetypes.NodeGroup) v1beta1.NodeGroup { if m.ReadEndpoint != nil { r.NodeGroupMembers[i].ReadEndpoint = v1beta1.Endpoint{ Address: pointer.StringValue(m.ReadEndpoint.Address), - Port: int(m.ReadEndpoint.Port), + Port: int(ptr.Deref(m.ReadEndpoint.Port, 0)), } } @@ -568,7 +569,7 @@ func generateReplicationGroupPendingModifiedValues(in elasticachetypes.Replicati if in.Resharding != nil && in.Resharding.SlotMigration != nil { r.Resharding = v1beta1.ReshardingStatus{ SlotMigration: v1beta1.SlotMigration{ - ProgressPercentage: int(in.Resharding.SlotMigration.ProgressPercentage), + ProgressPercentage: int(ptr.Deref(in.Resharding.SlotMigration.ProgressPercentage, 0)), }, } } @@ -587,7 +588,7 @@ func newEndpoint(rg elasticachetypes.ReplicationGroup) v1beta1.Endpoint { default: return v1beta1.Endpoint{} } - return v1beta1.Endpoint{Address: pointer.StringValue(e.Address), Port: int(e.Port)} + return v1beta1.Endpoint{Address: pointer.StringValue(e.Address), Port: int(ptr.Deref(e.Port, 0))} } // ConnectionEndpoint returns the connection endpoint for a Replication Group. @@ -600,7 +601,7 @@ func ConnectionEndpoint(rg elasticachetypes.ReplicationGroup) managed.Connection rg.ConfigurationEndpoint.Address != nil { return managed.ConnectionDetails{ xpv1.ResourceCredentialsSecretEndpointKey: []byte(aws.ToString(rg.ConfigurationEndpoint.Address)), - xpv1.ResourceCredentialsSecretPortKey: []byte(strconv.Itoa(int(rg.ConfigurationEndpoint.Port))), + xpv1.ResourceCredentialsSecretPortKey: []byte(strconv.Itoa(int(ptr.Deref(rg.ConfigurationEndpoint.Port, 0)))), } } @@ -616,13 +617,13 @@ func ConnectionEndpoint(rg elasticachetypes.ReplicationGroup) managed.Connection rg.NodeGroups[0].PrimaryEndpoint.Address != nil { hasData = true cd[xpv1.ResourceCredentialsSecretEndpointKey] = []byte(aws.ToString(rg.NodeGroups[0].PrimaryEndpoint.Address)) - cd[xpv1.ResourceCredentialsSecretPortKey] = []byte(strconv.Itoa(int(rg.NodeGroups[0].PrimaryEndpoint.Port))) + cd[xpv1.ResourceCredentialsSecretPortKey] = []byte(strconv.Itoa(int(ptr.Deref(rg.NodeGroups[0].PrimaryEndpoint.Port, 0)))) } if rg.NodeGroups[0].ReaderEndpoint != nil && rg.NodeGroups[0].ReaderEndpoint.Address != nil { hasData = true cd["readerEndpoint"] = []byte(aws.ToString(rg.NodeGroups[0].ReaderEndpoint.Address)) - cd["readerPort"] = []byte(strconv.Itoa(int(rg.NodeGroups[0].ReaderEndpoint.Port))) + cd["readerPort"] = []byte(strconv.Itoa(int(ptr.Deref(rg.NodeGroups[0].ReaderEndpoint.Port, 0)))) } if hasData { return cd @@ -731,7 +732,7 @@ func GenerateModifyCacheClusterInput(p cachev1alpha1.CacheClusterParameters, id c := &elasticache.ModifyCacheClusterInput{ CacheClusterId: aws.String(id), AZMode: elasticachetypes.AZMode(aws.ToString(p.AZMode)), - ApplyImmediately: aws.ToBool(p.ApplyImmediately), + ApplyImmediately: p.ApplyImmediately, AuthToken: p.AuthToken, AuthTokenUpdateStrategy: elasticachetypes.AuthTokenUpdateStrategyType(aws.ToString(p.AuthTokenUpdateStrategy)), CacheNodeIdsToRemove: p.CacheNodeIDsToRemove, @@ -784,7 +785,7 @@ func GenerateClusterObservation(c elasticachetypes.CacheCluster) cachev1alpha1.C if v.Endpoint != nil { cacheNodes[i].Endpoint = &cachev1alpha1.Endpoint{ Address: aws.ToString(v.Endpoint.Address), - Port: int(v.Endpoint.Port), + Port: int(ptr.Deref(v.Endpoint.Port, 0)), } } } diff --git a/pkg/clients/elasticache/elasticache_test.go b/pkg/clients/elasticache/elasticache_test.go index dd17a28e8f..328b53c91a 100644 --- a/pkg/clients/elasticache/elasticache_test.go +++ b/pkg/clients/elasticache/elasticache_test.go @@ -239,7 +239,7 @@ func TestNewModifyReplicationGroupInput(t *testing.T) { params: replicationGroupParams(), want: &elasticache.ModifyReplicationGroupInput{ ReplicationGroupId: ptr.To(name), - ApplyImmediately: true, + ApplyImmediately: ptr.To(true), AutomaticFailoverEnabled: pointer.ToOrNilIfZeroValue(autoFailoverEnabled), CacheNodeType: pointer.ToOrNilIfZeroValue(cacheNodeType), CacheParameterGroupName: pointer.ToOrNilIfZeroValue(cacheParameterGroupName), @@ -264,7 +264,7 @@ func TestNewModifyReplicationGroupInput(t *testing.T) { ReplicationGroupDescription: description, }, want: &elasticache.ModifyReplicationGroupInput{ - ApplyImmediately: false, + ApplyImmediately: ptr.To(false), ReplicationGroupId: ptr.To(name), ReplicationGroupDescription: ptr.To(description), CacheNodeType: ptr.To(cacheNodeType), @@ -278,7 +278,7 @@ func TestNewModifyReplicationGroupInput(t *testing.T) { ReplicationGroupDescription: description, }, want: &elasticache.ModifyReplicationGroupInput{ - ApplyImmediately: false, + ApplyImmediately: ptr.To(false), ReplicationGroupId: ptr.To(name), ReplicationGroupDescription: ptr.To(description), CacheNodeType: ptr.To(cacheNodeType), @@ -315,8 +315,8 @@ func TestNewModifyReplicationGroupShardConfigurationInput(t *testing.T) { }, }, want: &elasticache.ModifyReplicationGroupShardConfigurationInput{ - ApplyImmediately: true, - NodeGroupCount: 2, + ApplyImmediately: ptr.To(true), + NodeGroupCount: ptr.To[int32](2), ReplicationGroupId: ptr.To(name), }, }, @@ -331,8 +331,8 @@ func TestNewModifyReplicationGroupShardConfigurationInput(t *testing.T) { }, }, want: &elasticache.ModifyReplicationGroupShardConfigurationInput{ - ApplyImmediately: true, - NodeGroupCount: 2, + ApplyImmediately: ptr.To(true), + NodeGroupCount: ptr.To[int32](2), NodeGroupsToRemove: []string{"ng-01"}, ReplicationGroupId: pointer.ToOrNilIfZeroValue(name), }, @@ -351,8 +351,8 @@ func TestNewModifyReplicationGroupShardConfigurationInput(t *testing.T) { }, }, want: &elasticache.ModifyReplicationGroupShardConfigurationInput{ - ApplyImmediately: false, - NodeGroupCount: 2, + ApplyImmediately: ptr.To(false), + NodeGroupCount: ptr.To[int32](2), NodeGroupsToRemove: []string{"ng-01"}, ReplicationGroupId: pointer.ToOrNilIfZeroValue(name), }, @@ -572,7 +572,7 @@ func TestGenerateObservation(t *testing.T) { clusterEnabled := true configurationEndpoint := &elasticachetypes.Endpoint{ Address: pointer.ToOrNilIfZeroValue("istanbul"), - Port: 34, + Port: ptr.To[int32](34), } memberClusters := []string{"member-1", "member-2"} status := "creating" @@ -583,11 +583,11 @@ func TestGenerateObservation(t *testing.T) { Status: pointer.ToOrNilIfZeroValue("creating"), PrimaryEndpoint: &elasticachetypes.Endpoint{ Address: pointer.ToOrNilIfZeroValue("random-12"), - Port: 124, + Port: ptr.To[int32](124), }, ReaderEndpoint: &elasticachetypes.Endpoint{ Address: pointer.ToOrNilIfZeroValue("random-12-ro"), - Port: 124, + Port: ptr.To[int32](124), }, NodeGroupMembers: []elasticachetypes.NodeGroupMember{ { @@ -597,7 +597,7 @@ func TestGenerateObservation(t *testing.T) { PreferredAvailabilityZone: pointer.ToOrNilIfZeroValue("us-east-1"), ReadEndpoint: &elasticachetypes.Endpoint{ Address: pointer.ToOrNilIfZeroValue("random-1"), - Port: 23, + Port: ptr.To[int32](23), }, }, }, @@ -609,7 +609,7 @@ func TestGenerateObservation(t *testing.T) { PrimaryClusterId: pointer.ToOrNilIfZeroValue("my-coolest-cluster"), Resharding: &elasticachetypes.ReshardingStatus{ SlotMigration: &elasticachetypes.SlotMigration{ - ProgressPercentage: percentage, + ProgressPercentage: &percentage, }, }, } @@ -634,7 +634,7 @@ func TestGenerateObservation(t *testing.T) { ClusterEnabled: clusterEnabled, ConfigurationEndpoint: v1beta1.Endpoint{ Address: *configurationEndpoint.Address, - Port: int(configurationEndpoint.Port), + Port: int(ptr.Deref(configurationEndpoint.Port, 0)), }, MemberClusters: memberClusters, NodeGroups: []v1beta1.NodeGroup{ @@ -683,7 +683,7 @@ func TestGenerateObservation(t *testing.T) { ClusterEnabled: false, ConfigurationEndpoint: v1beta1.Endpoint{ Address: *nodeGroups[0].PrimaryEndpoint.Address, - Port: int(nodeGroups[0].PrimaryEndpoint.Port), + Port: int(ptr.Deref(nodeGroups[0].PrimaryEndpoint.Port, 0)), }, MemberClusters: memberClusters, NodeGroups: []v1beta1.NodeGroup{ @@ -1112,7 +1112,7 @@ func TestConnectionEndpoint(t *testing.T) { ClusterEnabled: pointer.ToOrNilIfZeroValue(true), ConfigurationEndpoint: &elasticachetypes.Endpoint{ Address: pointer.ToOrNilIfZeroValue(host), - Port: int32(port), + Port: ptr.To[int32](int32(port)), }, }, want: managed.ConnectionDetails{ @@ -1133,7 +1133,7 @@ func TestConnectionEndpoint(t *testing.T) { NodeGroups: []elasticachetypes.NodeGroup{{ PrimaryEndpoint: &elasticachetypes.Endpoint{ Address: pointer.ToOrNilIfZeroValue(host), - Port: int32(port), + Port: ptr.To[int32](int32(port)), }}, }, }, diff --git a/pkg/clients/elasticloadbalancing/elb/elb.go b/pkg/clients/elasticloadbalancing/elb/elb.go index 4d700261bd..7b0a9910d9 100644 --- a/pkg/clients/elasticloadbalancing/elb/elb.go +++ b/pkg/clients/elasticloadbalancing/elb/elb.go @@ -29,6 +29,7 @@ import ( xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/elasticloadbalancing/v1alpha1" "github.com/crossplane-contrib/provider-aws/pkg/utils/jsonpatch" @@ -100,7 +101,7 @@ func LateInitializeELB(in *v1alpha1.ELBParameters, v *elbtypes.LoadBalancerDescr in.Listeners = make([]v1alpha1.Listener, len(v.ListenerDescriptions)) for k, l := range v.ListenerDescriptions { in.Listeners[k] = v1alpha1.Listener{ - InstancePort: l.Listener.InstancePort, + InstancePort: ptr.Deref(l.Listener.InstancePort, 0), InstanceProtocol: l.Listener.InstanceProtocol, LoadBalancerPort: l.Listener.LoadBalancerPort, Protocol: aws.ToString(l.Listener.Protocol), @@ -140,7 +141,7 @@ func GenerateELBObservation(e elbtypes.LoadBalancerDescription) v1alpha1.ELBObse descriptions := []v1alpha1.BackendServerDescription{} for _, v := range e.BackendServerDescriptions { descriptions = append(descriptions, v1alpha1.BackendServerDescription{ - InstancePort: v.InstancePort, + InstancePort: ptr.Deref(v.InstancePort, 0), PolicyNames: v.PolicyNames, }) } @@ -207,9 +208,9 @@ func BuildELBListeners(l []v1alpha1.Listener) []elbtypes.Listener { out := make([]elbtypes.Listener, len(l)) for i := range l { out[i] = elbtypes.Listener{ - InstancePort: aws.ToInt32(&l[i].InstancePort), + InstancePort: &l[i].InstancePort, InstanceProtocol: l[i].InstanceProtocol, - LoadBalancerPort: aws.ToInt32(&l[i].LoadBalancerPort), + LoadBalancerPort: l[i].LoadBalancerPort, Protocol: &l[i].Protocol, SSLCertificateId: l[i].SSLCertificateID, } diff --git a/pkg/clients/elasticloadbalancing/elb/elb_test.go b/pkg/clients/elasticloadbalancing/elb/elb_test.go index af2716a12b..5dfbac5e3f 100644 --- a/pkg/clients/elasticloadbalancing/elb/elb_test.go +++ b/pkg/clients/elasticloadbalancing/elb/elb_test.go @@ -25,6 +25,7 @@ import ( "github.com/aws/smithy-go/document" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/elasticloadbalancing/v1alpha1" ) @@ -39,7 +40,7 @@ var ( Protocol: "HTTP", } elbListener = elbtypes.Listener{ - InstancePort: int32(80), + InstancePort: ptr.To[int32](80), InstanceProtocol: aws.String("HTTP"), LoadBalancerPort: int32(80), Protocol: aws.String("HTTP"), diff --git a/pkg/clients/redshift/redshift.go b/pkg/clients/redshift/redshift.go index 0b20e64408..9d036315ad 100644 --- a/pkg/clients/redshift/redshift.go +++ b/pkg/clients/redshift/redshift.go @@ -30,6 +30,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/redshift/v1alpha1" "github.com/crossplane-contrib/provider-aws/pkg/utils/jsonpatch" @@ -55,36 +56,36 @@ func LateInitialize(in *v1alpha1.ClusterParameters, cl *redshifttypes.Cluster) { if cl == nil { return } - in.AllowVersionUpgrade = pointer.LateInitialize(in.AllowVersionUpgrade, &cl.AllowVersionUpgrade) - in.AutomatedSnapshotRetentionPeriod = pointer.LateInitialize(in.AutomatedSnapshotRetentionPeriod, &cl.AutomatedSnapshotRetentionPeriod) + in.AllowVersionUpgrade = pointer.LateInitialize(in.AllowVersionUpgrade, cl.AllowVersionUpgrade) + in.AutomatedSnapshotRetentionPeriod = pointer.LateInitialize(in.AutomatedSnapshotRetentionPeriod, cl.AutomatedSnapshotRetentionPeriod) in.AvailabilityZone = pointer.LateInitialize(in.AvailabilityZone, cl.AvailabilityZone) in.ClusterVersion = pointer.LateInitialize(in.ClusterVersion, cl.ClusterVersion) in.ClusterSubnetGroupName = pointer.LateInitialize(in.ClusterSubnetGroupName, cl.ClusterSubnetGroupName) in.DBName = pointer.LateInitialize(in.DBName, cl.DBName) - in.Encrypted = pointer.LateInitialize(in.Encrypted, &cl.Encrypted) - in.EnhancedVPCRouting = pointer.LateInitialize(in.EnhancedVPCRouting, &cl.EnhancedVpcRouting) + in.Encrypted = pointer.LateInitialize(in.Encrypted, cl.Encrypted) + in.EnhancedVPCRouting = pointer.LateInitialize(in.EnhancedVPCRouting, cl.EnhancedVpcRouting) in.KMSKeyID = pointer.LateInitialize(in.KMSKeyID, cl.KmsKeyId) in.MaintenanceTrackName = pointer.LateInitialize(in.MaintenanceTrackName, cl.MaintenanceTrackName) - in.ManualSnapshotRetentionPeriod = pointer.LateInitialize(in.ManualSnapshotRetentionPeriod, &cl.ManualSnapshotRetentionPeriod) + in.ManualSnapshotRetentionPeriod = pointer.LateInitialize(in.ManualSnapshotRetentionPeriod, cl.ManualSnapshotRetentionPeriod) in.MasterUsername = pointer.LateInitializeValueFromPtr(in.MasterUsername, cl.MasterUsername) in.NodeType = pointer.LateInitializeValueFromPtr(in.NodeType, cl.NodeType) - in.NumberOfNodes = pointer.LateInitialize(in.NumberOfNodes, &cl.NumberOfNodes) + in.NumberOfNodes = pointer.LateInitialize(in.NumberOfNodes, cl.NumberOfNodes) in.PreferredMaintenanceWindow = pointer.LateInitialize(in.PreferredMaintenanceWindow, cl.PreferredMaintenanceWindow) - in.PubliclyAccessible = pointer.LateInitialize(in.PubliclyAccessible, &cl.PubliclyAccessible) + in.PubliclyAccessible = pointer.LateInitialize(in.PubliclyAccessible, cl.PubliclyAccessible) in.SnapshotScheduleIdentifier = pointer.LateInitialize(in.SnapshotScheduleIdentifier, cl.SnapshotScheduleIdentifier) // If ClusterType is not provided by the user then set it to it's default value. // As redshift.Cluster type doesn't hold this info. if in.ClusterType == nil { - if cl.NumberOfNodes > 1 { + numNodes := ptr.Deref(cl.NumberOfNodes, 0) + if numNodes > 1 { in.ClusterType = aws.String("multi-node") - } - if cl.NumberOfNodes == 1 { + } else if numNodes == 1 { in.ClusterType = aws.String("single-node") } } if cl.Endpoint != nil { - in.Port = pointer.LateInitialize(in.Port, &cl.Endpoint.Port) + in.Port = pointer.LateInitialize(in.Port, cl.Endpoint.Port) } if cl.HsmStatus != nil { in.HSMClientCertificateIdentifier = pointer.LateInitialize(in.HSMClientCertificateIdentifier, cl.HsmStatus.HsmClientCertificateIdentifier) @@ -138,10 +139,11 @@ func IsUpToDate(p v1alpha1.ClusterParameters, cl redshifttypes.Cluster) (bool, e } // Since redshift.Cluster doesn't have a ClusterType field therefore determine its value based upon number of nodes. - if cl.NumberOfNodes > 1 && aws.ToString(p.ClusterType) != "multi-node" { + numNodes := ptr.Deref(cl.NumberOfNodes, 0) + if numNodes > 1 && aws.ToString(p.ClusterType) != "multi-node" { return false, nil } - if cl.NumberOfNodes == 1 && aws.ToString(p.ClusterType) != "single-node" { + if numNodes == 1 && aws.ToString(p.ClusterType) != "single-node" { return false, nil } @@ -321,7 +323,7 @@ func GenerateDeleteClusterInput(p *v1alpha1.ClusterParameters, cid *string) *red ClusterIdentifier: cid, FinalClusterSnapshotIdentifier: p.FinalClusterSnapshotIdentifier, FinalClusterSnapshotRetentionPeriod: p.FinalClusterSnapshotRetentionPeriod, - SkipFinalClusterSnapshot: aws.ToBool(p.SkipFinalClusterSnapshot), + SkipFinalClusterSnapshot: p.SkipFinalClusterSnapshot, } } @@ -409,19 +411,19 @@ func GenerateObservation(in redshifttypes.Cluster) v1alpha1.ClusterObservation { if in.ClusterSnapshotCopyStatus != nil { o.ClusterSnapshotCopyStatus = v1alpha1.ClusterSnapshotCopyStatus{ DestinationRegion: aws.ToString(in.ClusterSnapshotCopyStatus.DestinationRegion), - ManualSnapshotRetentionPeriod: in.ClusterSnapshotCopyStatus.ManualSnapshotRetentionPeriod, - RetentionPeriod: in.ClusterSnapshotCopyStatus.RetentionPeriod, + ManualSnapshotRetentionPeriod: ptr.Deref(in.ClusterSnapshotCopyStatus.ManualSnapshotRetentionPeriod, 0), + RetentionPeriod: ptr.Deref(in.ClusterSnapshotCopyStatus.RetentionPeriod, 0), SnapshotCopyGrantName: aws.ToString(in.ClusterSnapshotCopyStatus.SnapshotCopyGrantName), } } if in.DataTransferProgress != nil { o.DataTransferProgress = v1alpha1.DataTransferProgress{ CurrentRateInMegaBytesPerSecond: int(aws.ToFloat64(in.DataTransferProgress.CurrentRateInMegaBytesPerSecond)), - DataTransferredInMegaBytes: in.DataTransferProgress.DataTransferredInMegaBytes, + DataTransferredInMegaBytes: ptr.Deref(in.DataTransferProgress.DataTransferredInMegaBytes, 0), ElapsedTimeInSeconds: aws.ToInt64(in.DataTransferProgress.ElapsedTimeInSeconds), EstimatedTimeToCompletionInSeconds: aws.ToInt64(in.DataTransferProgress.EstimatedTimeToCompletionInSeconds), Status: aws.ToString(in.DataTransferProgress.Status), - TotalDataInMegaBytes: in.DataTransferProgress.TotalDataInMegaBytes, + TotalDataInMegaBytes: ptr.Deref(in.DataTransferProgress.TotalDataInMegaBytes, 0), } } if in.ElasticIpStatus != nil { @@ -433,7 +435,7 @@ func GenerateObservation(in redshifttypes.Cluster) v1alpha1.ClusterObservation { if in.Endpoint != nil { o.Endpoint = v1alpha1.Endpoint{ Address: aws.ToString(in.Endpoint.Address), - Port: in.Endpoint.Port, + Port: ptr.Deref(in.Endpoint.Port, 0), } } if in.HsmStatus != nil { diff --git a/pkg/clients/redshift/redshift_test.go b/pkg/clients/redshift/redshift_test.go index e1966e6d32..7eff88aa9d 100644 --- a/pkg/clients/redshift/redshift_test.go +++ b/pkg/clients/redshift/redshift_test.go @@ -27,6 +27,7 @@ import ( "github.com/aws/smithy-go/document" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/redshift/v1alpha1" ) @@ -81,8 +82,8 @@ func clusterParam(m ...func(*v1alpha1.ClusterParameters)) *v1alpha1.ClusterParam func cluster(m ...func(*redshifttypes.Cluster)) *redshifttypes.Cluster { o := &redshifttypes.Cluster{ - AllowVersionUpgrade: true, - AutomatedSnapshotRetentionPeriod: 1, + AllowVersionUpgrade: ptr.To(true), + AutomatedSnapshotRetentionPeriod: ptr.To[int32](1), AvailabilityZone: aws.String("us-east-1d"), ClusterParameterGroups: []redshifttypes.ClusterParameterGroupStatus{ { @@ -92,16 +93,16 @@ func cluster(m ...func(*redshifttypes.Cluster)) *redshifttypes.Cluster { ClusterSubnetGroupName: aws.String("default"), ClusterVersion: aws.String("1.0"), DBName: aws.String("dev"), - Encrypted: false, + Encrypted: ptr.To(false), Endpoint: &redshifttypes.Endpoint{ - Port: 5439, + Port: ptr.To[int32](5439), }, - EnhancedVpcRouting: false, + EnhancedVpcRouting: ptr.To(false), MaintenanceTrackName: aws.String("current"), - ManualSnapshotRetentionPeriod: -1, + ManualSnapshotRetentionPeriod: ptr.To[int32](-1), NodeType: aws.String("dc1.large"), - NumberOfNodes: 1, - PubliclyAccessible: true, + NumberOfNodes: ptr.To[int32](1), + PubliclyAccessible: ptr.To(true), VpcSecurityGroups: []redshifttypes.VpcSecurityGroupMembership{ { VpcSecurityGroupId: aws.String("sg-44444444"), @@ -134,7 +135,7 @@ func TestCreatePatch(t *testing.T) { cl: &redshifttypes.Cluster{ NodeType: &nodeType, ClusterIdentifier: aws.String(""), - NumberOfNodes: 1, + NumberOfNodes: ptr.To[int32](1), }, p: &v1alpha1.ClusterParameters{ NodeType: nodeType, @@ -150,7 +151,7 @@ func TestCreatePatch(t *testing.T) { cl: &redshifttypes.Cluster{ NodeType: &nodeType, ClusterIdentifier: aws.String(""), - NumberOfNodes: 2, + NumberOfNodes: ptr.To[int32](2), }, p: &v1alpha1.ClusterParameters{ NodeType: nodeType, @@ -192,7 +193,7 @@ func TestIsUpToDate(t *testing.T) { cl: redshifttypes.Cluster{ NodeType: &nodeType, ClusterIdentifier: aws.String(""), - NumberOfNodes: 1, + NumberOfNodes: ptr.To[int32](1), }, p: v1alpha1.ClusterParameters{ NodeType: nodeType, @@ -206,7 +207,7 @@ func TestIsUpToDate(t *testing.T) { cl: redshifttypes.Cluster{ NodeType: &nodeType, ClusterIdentifier: aws.String(""), - NumberOfNodes: 2, + NumberOfNodes: ptr.To[int32](2), }, p: v1alpha1.ClusterParameters{ NodeType: nodeType, @@ -281,17 +282,10 @@ func TestLateInitialize(t *testing.T) { cl: redshifttypes.Cluster{}, }, want: &v1alpha1.ClusterParameters{ - AllowVersionUpgrade: aws.Bool(false), - AutomatedSnapshotRetentionPeriod: aws.Int32(0), - ClusterType: aws.String("single-node"), - Encrypted: aws.Bool(false), - EnhancedVPCRouting: aws.Bool(false), - MasterUsername: "admin", - ManualSnapshotRetentionPeriod: aws.Int32(0), - NodeType: "dc1.large", - PubliclyAccessible: aws.Bool(false), - SkipFinalClusterSnapshot: aws.Bool(true), - NumberOfNodes: aws.Int32(0), + ClusterType: aws.String("single-node"), + MasterUsername: "admin", + NodeType: "dc1.large", + SkipFinalClusterSnapshot: aws.Bool(true), }, }, "FullSpec": { @@ -466,6 +460,7 @@ func TestGenerateModifyClusterInput(t *testing.T) { cl: redshifttypes.Cluster{}, }, want: &redshift.ModifyClusterInput{ + AllowVersionUpgrade: &upgrade, AutomatedSnapshotRetentionPeriod: aws.Int32(2), Encrypted: aws.Bool(true), MaintenanceTrackName: aws.String("r2d2"), @@ -494,7 +489,7 @@ func TestGenerateDeleteClusterInput(t *testing.T) { in: clusterParam(), out: &redshift.DeleteClusterInput{ ClusterIdentifier: aws.String("unit-test"), - SkipFinalClusterSnapshot: true, + SkipFinalClusterSnapshot: ptr.To(true), }, }, "FullSpec": { @@ -503,7 +498,7 @@ func TestGenerateDeleteClusterInput(t *testing.T) { ClusterIdentifier: aws.String("unit-test"), FinalClusterSnapshotIdentifier: aws.String("doom"), FinalClusterSnapshotRetentionPeriod: aws.Int32(1), - SkipFinalClusterSnapshot: true, + SkipFinalClusterSnapshot: ptr.To(true), }, }, } diff --git a/pkg/clients/s3/bucket.go b/pkg/clients/s3/bucket.go index 5900d888ca..a457e31edf 100644 --- a/pkg/clients/s3/bucket.go +++ b/pkg/clients/s3/bucket.go @@ -145,7 +145,7 @@ func GenerateCreateBucketInput(name string, s v1beta1.BucketParameters) *s3.Crea GrantReadACP: s.GrantReadACP, GrantWrite: s.GrantWrite, GrantWriteACP: s.GrantWriteACP, - ObjectLockEnabledForBucket: aws.ToBool(s.ObjectLockEnabledForBucket), + ObjectLockEnabledForBucket: s.ObjectLockEnabledForBucket, ObjectOwnership: s3types.ObjectOwnership(aws.ToString(s.ObjectOwnership)), } if s.LocationConstraint != "us-east-1" { diff --git a/pkg/controller/acmpca/certificateauthority/controller_test.go b/pkg/controller/acmpca/certificateauthority/controller_test.go index 6e6da5522c..5704edf500 100644 --- a/pkg/controller/acmpca/certificateauthority/controller_test.go +++ b/pkg/controller/acmpca/certificateauthority/controller_test.go @@ -30,6 +30,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/test" "github.com/google/go-cmp/cmp" "github.com/pkg/errors" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/acmpca/v1beta1" acmpca "github.com/crossplane-contrib/provider-aws/pkg/clients/acmpca" @@ -133,7 +134,7 @@ func TestObserve(t *testing.T) { Status: awsacmpcatypes.CertificateAuthorityStatusActive, RevocationConfiguration: &awsacmpcatypes.RevocationConfiguration{ CrlConfiguration: &awsacmpcatypes.CrlConfiguration{ - Enabled: false, + Enabled: ptr.To(false), }, }, CertificateAuthorityConfiguration: &awsacmpcatypes.CertificateAuthorityConfiguration{ @@ -330,7 +331,7 @@ func TestUpdate(t *testing.T) { Status: awsacmpcatypes.CertificateAuthorityStatusActive, RevocationConfiguration: &awsacmpcatypes.RevocationConfiguration{ CrlConfiguration: &awsacmpcatypes.CrlConfiguration{ - Enabled: false, + Enabled: ptr.To(false), }, }, }, diff --git a/pkg/controller/cache/replicationgroup/managed_test.go b/pkg/controller/cache/replicationgroup/managed_test.go index e43a83a348..798b0fb81e 100644 --- a/pkg/controller/cache/replicationgroup/managed_test.go +++ b/pkg/controller/cache/replicationgroup/managed_test.go @@ -31,6 +31,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/cache/v1beta1" "github.com/crossplane-contrib/provider-aws/pkg/clients/elasticache/fake" @@ -297,7 +298,7 @@ func TestObserve(t *testing.T) { ReplicationGroups: []types.ReplicationGroup{{ ClusterEnabled: aws.Bool(true), Status: aws.String(v1beta1.StatusAvailable), - ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: int32(port)}, + ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: ptr.To(int32(port))}, }}, }, nil }, @@ -526,7 +527,7 @@ func TestUpdate(t *testing.T) { SnapshotRetentionLimit: aws.Int32(int32(snapshotRetentionLimit)), SnapshotWindow: aws.String(snapshotWindow), ClusterEnabled: aws.Bool(true), - ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: int32(port)}, + ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: ptr.To(int32(port))}, }}, }, nil }, @@ -572,7 +573,7 @@ func TestUpdate(t *testing.T) { SnapshotRetentionLimit: aws.Int32(int32(snapshotRetentionLimit)), SnapshotWindow: aws.String(snapshotWindow), ClusterEnabled: aws.Bool(true), - ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: int32(port)}, + ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: ptr.To(int32(port))}, }}, }, nil }, @@ -618,7 +619,7 @@ func TestUpdate(t *testing.T) { SnapshotRetentionLimit: aws.Int32(int32(snapshotRetentionLimit)), SnapshotWindow: aws.String(snapshotWindow), ClusterEnabled: aws.Bool(true), - ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: int32(port)}, + ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: ptr.To(int32(port))}, }}, }, nil }, @@ -664,7 +665,7 @@ func TestUpdate(t *testing.T) { SnapshotRetentionLimit: aws.Int32(int32(snapshotRetentionLimit)), SnapshotWindow: aws.String(snapshotWindow), ClusterEnabled: aws.Bool(true), - ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: int32(port)}, + ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: ptr.To(int32(port))}, }}, }, nil }, @@ -710,7 +711,7 @@ func TestUpdate(t *testing.T) { SnapshotRetentionLimit: aws.Int32(int32(snapshotRetentionLimit)), SnapshotWindow: aws.String(snapshotWindow), ClusterEnabled: aws.Bool(true), - ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: int32(port)}, + ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: ptr.To(int32(port))}, }}, }, nil }, @@ -756,7 +757,7 @@ func TestUpdate(t *testing.T) { SnapshotRetentionLimit: aws.Int32(int32(snapshotRetentionLimit)), SnapshotWindow: aws.String(snapshotWindow), ClusterEnabled: aws.Bool(true), - ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: int32(port)}, + ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: ptr.To(int32(port))}, }}, }, nil }, @@ -804,7 +805,7 @@ func TestUpdate(t *testing.T) { SnapshotRetentionLimit: aws.Int32(int32(snapshotRetentionLimit)), SnapshotWindow: aws.String(snapshotWindow), ClusterEnabled: aws.Bool(true), - ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: int32(port)}, + ConfigurationEndpoint: &types.Endpoint{Address: aws.String(host), Port: ptr.To(int32(port))}, }}, }, nil }, diff --git a/pkg/controller/database/rdsinstance/rdsinstance.go b/pkg/controller/database/rdsinstance/rdsinstance.go index d8c6313a78..0b3307f237 100644 --- a/pkg/controller/database/rdsinstance/rdsinstance.go +++ b/pkg/controller/database/rdsinstance/rdsinstance.go @@ -347,7 +347,7 @@ func (e *external) Delete(ctx context.Context, mg resource.Managed) error { input := awsrds.DeleteDBInstanceInput{ DBInstanceIdentifier: aws.String(meta.GetExternalName(cr)), DeleteAutomatedBackups: cr.Spec.ForProvider.DeleteAutomatedBackups, - SkipFinalSnapshot: aws.ToBool(cr.Spec.ForProvider.SkipFinalSnapshotBeforeDeletion), + SkipFinalSnapshot: cr.Spec.ForProvider.SkipFinalSnapshotBeforeDeletion, FinalDBSnapshotIdentifier: cr.Spec.ForProvider.FinalDBSnapshotIdentifier, } _, err = e.client.DeleteDBInstance(ctx, &input) diff --git a/pkg/controller/database/rdsinstance/rdsinstance_test.go b/pkg/controller/database/rdsinstance/rdsinstance_test.go index 6e211f403d..5becf4cd30 100644 --- a/pkg/controller/database/rdsinstance/rdsinstance_test.go +++ b/pkg/controller/database/rdsinstance/rdsinstance_test.go @@ -31,6 +31,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/crossplane-contrib/provider-aws/apis/database/v1beta1" @@ -173,21 +174,7 @@ func withStatusAWSBackupRecoveryPointARN(s string) rdsModifier { } func instance(m ...rdsModifier) *v1beta1.RDSInstance { - falseFlag := false - cr := &v1beta1.RDSInstance{ - Spec: v1beta1.RDSInstanceSpec{ - ForProvider: v1beta1.RDSInstanceParameters{ - AutoMinorVersionUpgrade: &falseFlag, - BackupRetentionPeriod: new(int), - CopyTagsToSnapshot: &falseFlag, - DeletionProtection: &falseFlag, - EnableIAMDatabaseAuthentication: &falseFlag, - MultiAZ: &falseFlag, - PubliclyAccessible: &falseFlag, - StorageEncrypted: &falseFlag, - }, - }, - } + cr := &v1beta1.RDSInstance{} for _, f := range m { f(cr) } @@ -254,7 +241,7 @@ func TestObserve(t *testing.T) { { DBInstanceStatus: aws.String(string(v1beta1.RDSInstanceStateAvailable)), MaxAllocatedStorage: aws.Int32(100), - AllocatedStorage: 30, + AllocatedStorage: ptr.To(int32(30)), }, }, }, nil @@ -284,7 +271,7 @@ func TestObserve(t *testing.T) { DBInstances: []awsrdstypes.DBInstance{ { DBInstanceStatus: aws.String(string(v1beta1.RDSInstanceStateAvailable)), - BackupRetentionPeriod: 10, + BackupRetentionPeriod: ptr.To[int32](10), AwsBackupRecoveryPointArn: aws.String(awsBackupRecoveryPointARN), }, }, @@ -315,7 +302,7 @@ func TestObserve(t *testing.T) { DBInstances: []awsrdstypes.DBInstance{ { DBInstanceStatus: aws.String(string(v1beta1.RDSInstanceStateAvailable)), - BackupRetentionPeriod: 10, + BackupRetentionPeriod: ptr.To[int32](10), }, }, }, nil @@ -756,7 +743,7 @@ func TestUpdate(t *testing.T) { return &awsrds.DescribeDBInstancesOutput{ DBInstances: []awsrdstypes.DBInstance{{ MaxAllocatedStorage: aws.Int32(100), - AllocatedStorage: 30, + AllocatedStorage: ptr.To[int32](30), }}, }, nil }, @@ -788,7 +775,7 @@ func TestUpdate(t *testing.T) { MockDescribe: func(ctx context.Context, input *awsrds.DescribeDBInstancesInput, opts []func(*awsrds.Options)) (*awsrds.DescribeDBInstancesOutput, error) { return &awsrds.DescribeDBInstancesOutput{ DBInstances: []awsrdstypes.DBInstance{{ - BackupRetentionPeriod: 7, + BackupRetentionPeriod: ptr.To[int32](7), PreferredBackupWindow: &backupWindow, AwsBackupRecoveryPointArn: aws.String(awsBackupRecoveryPointARN), }}, diff --git a/pkg/controller/ec2/securitygrouprule/controller_test.go b/pkg/controller/ec2/securitygrouprule/controller_test.go index 3c0630273a..bf6c17df23 100644 --- a/pkg/controller/ec2/securitygrouprule/controller_test.go +++ b/pkg/controller/ec2/securitygrouprule/controller_test.go @@ -321,11 +321,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -357,11 +357,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -418,11 +418,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -454,11 +454,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -518,15 +518,15 @@ func TestCreate(t *testing.T) { var prefixListID *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } - if input.IpPermissions[0].PrefixListIds != nil && len(input.IpPermissions[0].PrefixListIds) > 0 { + if len(input.IpPermissions[0].PrefixListIds) > 0 { prefixListID = input.IpPermissions[0].PrefixListIds[0].PrefixListId description = input.IpPermissions[0].PrefixListIds[0].Description } @@ -560,15 +560,15 @@ func TestCreate(t *testing.T) { var prefixListID *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } - if input.IpPermissions[0].PrefixListIds != nil && len(input.IpPermissions[0].PrefixListIds) > 0 { + if len(input.IpPermissions[0].PrefixListIds) > 0 { prefixListID = input.IpPermissions[0].PrefixListIds[0].PrefixListId description = input.IpPermissions[0].PrefixListIds[0].Description } @@ -628,11 +628,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -664,11 +664,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -727,11 +727,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -763,11 +763,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -824,11 +824,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -860,11 +860,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -924,15 +924,15 @@ func TestCreate(t *testing.T) { var prefixListID *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } - if input.IpPermissions[0].PrefixListIds != nil && len(input.IpPermissions[0].PrefixListIds) > 0 { + if len(input.IpPermissions[0].PrefixListIds) > 0 { prefixListID = input.IpPermissions[0].PrefixListIds[0].PrefixListId description = input.IpPermissions[0].PrefixListIds[0].Description } @@ -966,15 +966,15 @@ func TestCreate(t *testing.T) { var prefixListID *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } - if input.IpPermissions[0].PrefixListIds != nil && len(input.IpPermissions[0].PrefixListIds) > 0 { + if len(input.IpPermissions[0].PrefixListIds) > 0 { prefixListID = input.IpPermissions[0].PrefixListIds[0].PrefixListId description = input.IpPermissions[0].PrefixListIds[0].Description } @@ -1034,11 +1034,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } @@ -1070,11 +1070,11 @@ func TestCreate(t *testing.T) { var cidrIpv4 *string = nil var description *string = nil var refSg *types.ReferencedSecurityGroup = nil - if input.IpPermissions[0].Ipv6Ranges != nil && len(input.IpPermissions[0].Ipv6Ranges) > 0 { + if len(input.IpPermissions[0].Ipv6Ranges) > 0 { cidrIpv6 = input.IpPermissions[0].Ipv6Ranges[0].CidrIpv6 description = input.IpPermissions[0].Ipv6Ranges[0].Description } - if input.IpPermissions[0].IpRanges != nil && len(input.IpPermissions[0].IpRanges) > 0 { + if len(input.IpPermissions[0].IpRanges) > 0 { cidrIpv4 = input.IpPermissions[0].IpRanges[0].CidrIp description = input.IpPermissions[0].IpRanges[0].Description } diff --git a/pkg/controller/ec2/subnet/controller.go b/pkg/controller/ec2/subnet/controller.go index db1d46c7f5..d5971d8172 100644 --- a/pkg/controller/ec2/subnet/controller.go +++ b/pkg/controller/ec2/subnet/controller.go @@ -148,7 +148,7 @@ func (e *external) Observe(ctx context.Context, mgd resource.Managed) (managed.E current := cr.Spec.ForProvider.DeepCopy() ec2.LateInitializeSubnet(&cr.Spec.ForProvider, &observed) - switch observed.State { + switch observed.State { //nolint:exhaustive case awsec2types.SubnetStateAvailable: cr.SetConditions(xpv1.Available()) case awsec2types.SubnetStatePending: diff --git a/pkg/controller/elasticloadbalancing/elb/controller.go b/pkg/controller/elasticloadbalancing/elb/controller.go index f99194173e..1d48b87733 100644 --- a/pkg/controller/elasticloadbalancing/elb/controller.go +++ b/pkg/controller/elasticloadbalancing/elb/controller.go @@ -237,11 +237,11 @@ func (e *external) Update(ctx context.Context, mgd resource.Managed) (managed.Ex if _, err := e.client.ConfigureHealthCheck(ctx, &awselb.ConfigureHealthCheckInput{ LoadBalancerName: aws.String(meta.GetExternalName(cr)), HealthCheck: &awselbtypes.HealthCheck{ - HealthyThreshold: cr.Spec.ForProvider.HealthCheck.HealthyThreshold, - Interval: cr.Spec.ForProvider.HealthCheck.Interval, + HealthyThreshold: &cr.Spec.ForProvider.HealthCheck.HealthyThreshold, + Interval: &cr.Spec.ForProvider.HealthCheck.Interval, Target: aws.String(cr.Spec.ForProvider.HealthCheck.Target), - Timeout: cr.Spec.ForProvider.HealthCheck.Timeout, - UnhealthyThreshold: cr.Spec.ForProvider.HealthCheck.HealthyThreshold, + Timeout: &cr.Spec.ForProvider.HealthCheck.Timeout, + UnhealthyThreshold: &cr.Spec.ForProvider.HealthCheck.HealthyThreshold, }, }); err != nil { return managed.ExternalUpdate{}, errorutils.Wrap(err, errUpdate) diff --git a/pkg/controller/elasticloadbalancing/elb/controller_test.go b/pkg/controller/elasticloadbalancing/elb/controller_test.go index f8138dbc35..23aa6b5cd3 100644 --- a/pkg/controller/elasticloadbalancing/elb/controller_test.go +++ b/pkg/controller/elasticloadbalancing/elb/controller_test.go @@ -45,7 +45,7 @@ var ( securityGroups = []string{"sg-someid"} subnets = []string{"subnet1"} listener = awselbtypes.Listener{ - InstancePort: port80, + InstancePort: &port80, InstanceProtocol: &protocol, LoadBalancerPort: port80, Protocol: &protocol, diff --git a/pkg/controller/rds/dbclusterparametergroup/setup.go b/pkg/controller/rds/dbclusterparametergroup/setup.go index 40de4a55c0..c209cc7a8d 100644 --- a/pkg/controller/rds/dbclusterparametergroup/setup.go +++ b/pkg/controller/rds/dbclusterparametergroup/setup.go @@ -258,7 +258,7 @@ func (c *custom) getDBEngineVersion(ctx context.Context, selector *svcapitypes.D if err != nil { return nil, err } - if resp.DBEngineVersions == nil || len(resp.DBEngineVersions) == 0 || resp.DBEngineVersions[0] == nil { + if len(resp.DBEngineVersions) == 0 || resp.DBEngineVersions[0] == nil { return nil, errors.New(errNoDBEngineVersions) } return resp.DBEngineVersions[0], nil diff --git a/pkg/controller/rds/dbparametergroup/setup.go b/pkg/controller/rds/dbparametergroup/setup.go index d9ce48fcc4..1468a41f08 100644 --- a/pkg/controller/rds/dbparametergroup/setup.go +++ b/pkg/controller/rds/dbparametergroup/setup.go @@ -258,7 +258,7 @@ func (c *custom) getDBEngineVersion(ctx context.Context, selector *svcapitypes.D if err != nil { return nil, err } - if resp.DBEngineVersions == nil || len(resp.DBEngineVersions) == 0 || resp.DBEngineVersions[0] == nil { + if len(resp.DBEngineVersions) == 0 || resp.DBEngineVersions[0] == nil { return nil, errors.New(errNoDBEngineVersions) } return resp.DBEngineVersions[0], nil diff --git a/pkg/controller/redshift/cluster/controller_test.go b/pkg/controller/redshift/cluster/controller_test.go index ca299f9d3c..d697b6843d 100644 --- a/pkg/controller/redshift/cluster/controller_test.go +++ b/pkg/controller/redshift/cluster/controller_test.go @@ -28,6 +28,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/test" "github.com/google/go-cmp/cmp" "github.com/pkg/errors" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/crossplane-contrib/provider-aws/apis/redshift/v1alpha1" @@ -120,12 +121,18 @@ func TestObserve(t *testing.T) { return &awsredshift.DescribeClustersOutput{ Clusters: []awsredshifttypes.Cluster{ { - ClusterStatus: aws.String(string(v1alpha1.StateAvailable)), - NumberOfNodes: 1, - ClusterIdentifier: &name, - MasterUsername: &masterUsername, - NodeType: &nodeType, - VpcSecurityGroups: vpcSecurityGroups, + ClusterStatus: aws.String(string(v1alpha1.StateAvailable)), + NumberOfNodes: ptr.To[int32](1), + ClusterIdentifier: &name, + MasterUsername: &masterUsername, + NodeType: &nodeType, + VpcSecurityGroups: vpcSecurityGroups, + AllowVersionUpgrade: aws.Bool(false), + AutomatedSnapshotRetentionPeriod: aws.Int32(0), + Encrypted: aws.Bool(false), + EnhancedVpcRouting: aws.Bool(false), + ManualSnapshotRetentionPeriod: aws.Int32(0), + PubliclyAccessible: aws.Bool(false), }, }, }, nil @@ -151,12 +158,18 @@ func TestObserve(t *testing.T) { return &awsredshift.DescribeClustersOutput{ Clusters: []awsredshifttypes.Cluster{ { - ClusterStatus: aws.String(string(v1alpha1.StateDeleting)), - NumberOfNodes: 1, - ClusterIdentifier: &name, - MasterUsername: &masterUsername, - NodeType: &nodeType, - VpcSecurityGroups: vpcSecurityGroups, + ClusterStatus: aws.String(string(v1alpha1.StateDeleting)), + NumberOfNodes: ptr.To[int32](1), + ClusterIdentifier: &name, + MasterUsername: &masterUsername, + NodeType: &nodeType, + VpcSecurityGroups: vpcSecurityGroups, + AllowVersionUpgrade: aws.Bool(false), + AutomatedSnapshotRetentionPeriod: aws.Int32(0), + Encrypted: aws.Bool(false), + EnhancedVpcRouting: aws.Bool(false), + ManualSnapshotRetentionPeriod: aws.Int32(0), + PubliclyAccessible: aws.Bool(false), }, }, }, nil @@ -182,12 +195,18 @@ func TestObserve(t *testing.T) { return &awsredshift.DescribeClustersOutput{ Clusters: []awsredshifttypes.Cluster{ { - ClusterStatus: aws.String(string(v1alpha1.StateFailed)), - NumberOfNodes: 1, - ClusterIdentifier: &name, - MasterUsername: &masterUsername, - NodeType: &nodeType, - VpcSecurityGroups: vpcSecurityGroups, + ClusterStatus: aws.String(string(v1alpha1.StateFailed)), + NumberOfNodes: ptr.To[int32](1), + ClusterIdentifier: &name, + MasterUsername: &masterUsername, + NodeType: &nodeType, + VpcSecurityGroups: vpcSecurityGroups, + AllowVersionUpgrade: aws.Bool(false), + AutomatedSnapshotRetentionPeriod: aws.Int32(0), + Encrypted: aws.Bool(false), + EnhancedVpcRouting: aws.Bool(false), + ManualSnapshotRetentionPeriod: aws.Int32(0), + PubliclyAccessible: aws.Bool(false), }, }, }, nil @@ -243,12 +262,18 @@ func TestObserve(t *testing.T) { return &awsredshift.DescribeClustersOutput{ Clusters: []awsredshifttypes.Cluster{ { - ClusterStatus: aws.String(v1alpha1.StateCreating), - NumberOfNodes: 1, - ClusterIdentifier: &name, - MasterUsername: &masterUsername, - NodeType: &nodeType, - VpcSecurityGroups: vpcSecurityGroups, + ClusterStatus: aws.String(v1alpha1.StateCreating), + NumberOfNodes: ptr.To[int32](1), + ClusterIdentifier: &name, + MasterUsername: &masterUsername, + NodeType: &nodeType, + VpcSecurityGroups: vpcSecurityGroups, + AllowVersionUpgrade: aws.Bool(false), + AutomatedSnapshotRetentionPeriod: aws.Int32(0), + Encrypted: aws.Bool(false), + EnhancedVpcRouting: aws.Bool(false), + ManualSnapshotRetentionPeriod: aws.Int32(0), + PubliclyAccessible: aws.Bool(false), }, }, }, nil diff --git a/pkg/controller/s3/bucket/CORSConfig.go b/pkg/controller/s3/bucket/CORSConfig.go index ed7a9c7b04..4b8fdc0dd4 100644 --- a/pkg/controller/s3/bucket/CORSConfig.go +++ b/pkg/controller/s3/bucket/CORSConfig.go @@ -21,6 +21,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/resource" "github.com/google/go-cmp/cmp" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1" "github.com/crossplane-contrib/provider-aws/pkg/clients/s3" @@ -124,7 +125,7 @@ func GeneratePutBucketCorsInput(name string, config *v1beta1.CORSConfiguration) AllowedMethods: cors.AllowedMethods, AllowedOrigins: cors.AllowedOrigins, ExposeHeaders: cors.ExposeHeaders, - MaxAgeSeconds: cors.MaxAgeSeconds, + MaxAgeSeconds: ptr.To(cors.MaxAgeSeconds), }) } return bci @@ -147,7 +148,7 @@ func CompareCORS(local []v1beta1.CORSRule, external []types.CORSRule) ResourceSt cmp.Equal(local[i].AllowedMethods, outputRule.AllowedMethods) && cmp.Equal(local[i].AllowedOrigins, outputRule.AllowedOrigins) && cmp.Equal(local[i].ExposeHeaders, outputRule.ExposeHeaders) && - local[i].MaxAgeSeconds == outputRule.MaxAgeSeconds) { + local[i].MaxAgeSeconds == ptr.Deref(outputRule.MaxAgeSeconds, 0)) { return NeedsUpdate } } @@ -164,7 +165,7 @@ func GenerateCORSRule(config []types.CORSRule) []v1beta1.CORSRule { AllowedMethods: cors.AllowedMethods, AllowedOrigins: cors.AllowedOrigins, ExposeHeaders: cors.ExposeHeaders, - MaxAgeSeconds: cors.MaxAgeSeconds, + MaxAgeSeconds: ptr.Deref(cors.MaxAgeSeconds, 0), } } return output diff --git a/pkg/controller/s3/bucket/CORSConfig_test.go b/pkg/controller/s3/bucket/CORSConfig_test.go index 45635a753a..02f27acb70 100644 --- a/pkg/controller/s3/bucket/CORSConfig_test.go +++ b/pkg/controller/s3/bucket/CORSConfig_test.go @@ -25,6 +25,7 @@ import ( "github.com/aws/smithy-go" "github.com/crossplane/crossplane-runtime/pkg/test" "github.com/google/go-cmp/cmp" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1" clientss3 "github.com/crossplane-contrib/provider-aws/pkg/clients/s3" @@ -55,7 +56,7 @@ func generateAWSCORS() *s3types.CORSConfiguration { AllowedMethods: []string{"GET"}, AllowedOrigins: []string{"test.origin"}, ExposeHeaders: []string{"test.expose"}, - MaxAgeSeconds: 10, + MaxAgeSeconds: ptr.To[int32](10), }, }, } diff --git a/pkg/controller/s3/bucket/lifecycleConfig.go b/pkg/controller/s3/bucket/lifecycleConfig.go index c362ba315d..fe19afb1ca 100644 --- a/pkg/controller/s3/bucket/lifecycleConfig.go +++ b/pkg/controller/s3/bucket/lifecycleConfig.go @@ -157,26 +157,26 @@ func GenerateLifecycleRules(in []v1beta1.LifecycleRule) []types.LifecycleRule { } if local.AbortIncompleteMultipartUpload != nil { rule.AbortIncompleteMultipartUpload = &types.AbortIncompleteMultipartUpload{ - DaysAfterInitiation: local.AbortIncompleteMultipartUpload.DaysAfterInitiation, + DaysAfterInitiation: ptr.To(local.AbortIncompleteMultipartUpload.DaysAfterInitiation), } } if local.Expiration != nil { rule.Expiration = &types.LifecycleExpiration{ - Days: local.Expiration.Days, - ExpiredObjectDeleteMarker: local.Expiration.ExpiredObjectDeleteMarker, + Days: ptr.To(local.Expiration.Days), + ExpiredObjectDeleteMarker: ptr.To(local.Expiration.ExpiredObjectDeleteMarker), } if local.Expiration.Date != nil { rule.Expiration.Date = ptr.To(local.Expiration.Date.Time) } } if local.NoncurrentVersionExpiration != nil { - rule.NoncurrentVersionExpiration = &types.NoncurrentVersionExpiration{NoncurrentDays: local.NoncurrentVersionExpiration.NoncurrentDays} + rule.NoncurrentVersionExpiration = &types.NoncurrentVersionExpiration{NoncurrentDays: ptr.To(local.NoncurrentVersionExpiration.NoncurrentDays)} } if local.NoncurrentVersionTransitions != nil { rule.NoncurrentVersionTransitions = make([]types.NoncurrentVersionTransition, len(local.NoncurrentVersionTransitions)) for tIndex, transition := range local.NoncurrentVersionTransitions { rule.NoncurrentVersionTransitions[tIndex] = types.NoncurrentVersionTransition{ - NoncurrentDays: transition.NoncurrentDays, + NoncurrentDays: ptr.To(transition.NoncurrentDays), StorageClass: types.TransitionStorageClass(transition.StorageClass), } } @@ -185,7 +185,7 @@ func GenerateLifecycleRules(in []v1beta1.LifecycleRule) []types.LifecycleRule { rule.Transitions = make([]types.Transition, len(local.Transitions)) for tIndex, transition := range local.Transitions { rule.Transitions[tIndex] = types.Transition{ - Days: transition.Days, + Days: ptr.To(transition.Days), StorageClass: types.TransitionStorageClass(transition.StorageClass), } if transition.Date != nil { @@ -268,7 +268,7 @@ func createLifecycleRulesFromExternal(external []types.LifecycleRule, config *v1 if rule.AbortIncompleteMultipartUpload != nil { config.Rules[i].AbortIncompleteMultipartUpload = &v1beta1.AbortIncompleteMultipartUpload{} - config.Rules[i].AbortIncompleteMultipartUpload.DaysAfterInitiation = rule.AbortIncompleteMultipartUpload.DaysAfterInitiation + config.Rules[i].AbortIncompleteMultipartUpload.DaysAfterInitiation = ptr.Deref(rule.AbortIncompleteMultipartUpload.DaysAfterInitiation, 0) } if rule.Expiration != nil { config.Rules[i].Expiration = &v1beta1.LifecycleExpiration{} @@ -276,25 +276,25 @@ func createLifecycleRulesFromExternal(external []types.LifecycleRule, config *v1 config.Rules[i].Expiration.Date, rule.Expiration.Date, ) - config.Rules[i].Expiration.Days = rule.Expiration.Days - config.Rules[i].Expiration.ExpiredObjectDeleteMarker = rule.Expiration.ExpiredObjectDeleteMarker + config.Rules[i].Expiration.Days = ptr.Deref(rule.Expiration.Days, 0) + config.Rules[i].Expiration.ExpiredObjectDeleteMarker = ptr.Deref(rule.Expiration.ExpiredObjectDeleteMarker, false) } if rule.NoncurrentVersionExpiration != nil { config.Rules[i].NoncurrentVersionExpiration = &v1beta1.NoncurrentVersionExpiration{} - config.Rules[i].NoncurrentVersionExpiration.NoncurrentDays = rule.NoncurrentVersionExpiration.NoncurrentDays + config.Rules[i].NoncurrentVersionExpiration.NoncurrentDays = ptr.Deref(rule.NoncurrentVersionExpiration.NoncurrentDays, 0) } if len(rule.NoncurrentVersionTransitions) != 0 { config.Rules[i].NoncurrentVersionTransitions = make([]v1beta1.NoncurrentVersionTransition, len(rule.NoncurrentVersionTransitions)) for j, nvt := range rule.NoncurrentVersionTransitions { - config.Rules[i].NoncurrentVersionTransitions[j].NoncurrentDays = nvt.NoncurrentDays + config.Rules[i].NoncurrentVersionTransitions[j].NoncurrentDays = ptr.Deref(nvt.NoncurrentDays, 0) config.Rules[i].NoncurrentVersionTransitions[j].StorageClass = string(nvt.StorageClass) } } if len(rule.Transitions) != 0 { config.Rules[i].Transitions = make([]v1beta1.Transition, len(rule.Transitions)) for j, transition := range rule.Transitions { - config.Rules[i].Transitions[j].Days = transition.Days + config.Rules[i].Transitions[j].Days = ptr.Deref(transition.Days, 0) config.Rules[i].Transitions[j].Date = pointer.LateInitializeTimePtr( config.Rules[i].Transitions[j].Date, transition.Date, diff --git a/pkg/controller/s3/bucket/lifecycleConfig_test.go b/pkg/controller/s3/bucket/lifecycleConfig_test.go index 5c9cc31e9b..aa11ed9cd2 100644 --- a/pkg/controller/s3/bucket/lifecycleConfig_test.go +++ b/pkg/controller/s3/bucket/lifecycleConfig_test.go @@ -29,6 +29,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1" clients3 "github.com/crossplane-contrib/provider-aws/pkg/clients/s3" @@ -88,11 +89,11 @@ func generateAWSLifecycle(sortTag bool) *s3types.BucketLifecycleConfiguration { conf := &s3types.BucketLifecycleConfiguration{ Rules: []s3types.LifecycleRule{ { - AbortIncompleteMultipartUpload: &s3types.AbortIncompleteMultipartUpload{DaysAfterInitiation: 1}, + AbortIncompleteMultipartUpload: &s3types.AbortIncompleteMultipartUpload{DaysAfterInitiation: ptr.To[int32](1)}, Expiration: &s3types.LifecycleExpiration{ Date: &awsDate, - Days: days, - ExpiredObjectDeleteMarker: marker, + Days: &days, + ExpiredObjectDeleteMarker: &marker, }, Filter: &s3types.LifecycleRuleFilterMemberAnd{ Value: s3types.LifecycleRuleAndOperator{ @@ -101,15 +102,15 @@ func generateAWSLifecycle(sortTag bool) *s3types.BucketLifecycleConfiguration { }, }, ID: pointer.ToOrNilIfZeroValue(id), - NoncurrentVersionExpiration: &s3types.NoncurrentVersionExpiration{NoncurrentDays: days}, + NoncurrentVersionExpiration: &s3types.NoncurrentVersionExpiration{NoncurrentDays: &days}, NoncurrentVersionTransitions: []s3types.NoncurrentVersionTransition{{ - NoncurrentDays: days, + NoncurrentDays: &days, StorageClass: s3types.TransitionStorageClassOnezoneIa, }}, Status: s3types.ExpirationStatusEnabled, Transitions: []s3types.Transition{{ Date: &awsDate, - Days: days, + Days: &days, StorageClass: s3types.TransitionStorageClassOnezoneIa, }}, }, diff --git a/pkg/controller/s3/bucket/notificationConfig_test.go b/pkg/controller/s3/bucket/notificationConfig_test.go index c7098d7c91..605275a56a 100644 --- a/pkg/controller/s3/bucket/notificationConfig_test.go +++ b/pkg/controller/s3/bucket/notificationConfig_test.go @@ -21,7 +21,6 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/aws/aws-sdk-go-v2/service/s3/types" s3types "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/crossplane/crossplane-runtime/pkg/test" "github.com/google/go-cmp/cmp" @@ -617,10 +616,10 @@ func TestIsNotificationConfigurationUpToDate(t *testing.T) { func TestSanitizeQueue(t *testing.T) { type args struct { - cr []types.QueueConfiguration + cr []s3types.QueueConfiguration } type want struct { - queueConfiguration []types.QueueConfiguration + queueConfiguration []s3types.QueueConfiguration } cases := map[string]struct { @@ -629,14 +628,14 @@ func TestSanitizeQueue(t *testing.T) { }{ "SanitizeQueueFilterKeyFilterRulesName": { args: args{ - cr: []types.QueueConfiguration{ + cr: []s3types.QueueConfiguration{ { Events: nil, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{ - Key: &types.S3KeyFilter{ - FilterRules: []types.FilterRule{ + Filter: &s3types.NotificationConfigurationFilter{ + Key: &s3types.S3KeyFilter{ + FilterRules: []s3types.FilterRule{ { Name: "preFIX", Value: nil, @@ -668,14 +667,14 @@ func TestSanitizeQueue(t *testing.T) { }, }, want: want{ - queueConfiguration: []types.QueueConfiguration{ + queueConfiguration: []s3types.QueueConfiguration{ { - Events: []types.Event{}, + Events: []s3types.Event{}, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{ - Key: &types.S3KeyFilter{ - FilterRules: []types.FilterRule{ + Filter: &s3types.NotificationConfigurationFilter{ + Key: &s3types.S3KeyFilter{ + FilterRules: []s3types.FilterRule{ { Name: "prefix", Value: nil, @@ -709,28 +708,28 @@ func TestSanitizeQueue(t *testing.T) { }, "SanitizeQueueEmptyFilterRules": { args: args{ - cr: []types.QueueConfiguration{ + cr: []s3types.QueueConfiguration{ { Events: nil, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{ - Key: &types.S3KeyFilter{ - FilterRules: []types.FilterRule{}, + Filter: &s3types.NotificationConfigurationFilter{ + Key: &s3types.S3KeyFilter{ + FilterRules: []s3types.FilterRule{}, }, }, }, }, }, want: want{ - queueConfiguration: []types.QueueConfiguration{ + queueConfiguration: []s3types.QueueConfiguration{ { - Events: []types.Event{}, + Events: []s3types.Event{}, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{ - Key: &types.S3KeyFilter{ - FilterRules: []types.FilterRule{}, + Filter: &s3types.NotificationConfigurationFilter{ + Key: &s3types.S3KeyFilter{ + FilterRules: []s3types.FilterRule{}, }, }, }, @@ -739,13 +738,13 @@ func TestSanitizeQueue(t *testing.T) { }, "SanitizeQueueNilFilterRules": { args: args{ - cr: []types.QueueConfiguration{ + cr: []s3types.QueueConfiguration{ { Events: nil, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{ - Key: &types.S3KeyFilter{ + Filter: &s3types.NotificationConfigurationFilter{ + Key: &s3types.S3KeyFilter{ FilterRules: nil, }, }, @@ -753,14 +752,14 @@ func TestSanitizeQueue(t *testing.T) { }, }, want: want{ - queueConfiguration: []types.QueueConfiguration{ + queueConfiguration: []s3types.QueueConfiguration{ { - Events: []types.Event{}, + Events: []s3types.Event{}, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{ - Key: &types.S3KeyFilter{ - FilterRules: []types.FilterRule{}, + Filter: &s3types.NotificationConfigurationFilter{ + Key: &s3types.S3KeyFilter{ + FilterRules: []s3types.FilterRule{}, }, }, }, @@ -769,24 +768,24 @@ func TestSanitizeQueue(t *testing.T) { }, "SanitizeQueueNilFilterKey": { args: args{ - cr: []types.QueueConfiguration{ + cr: []s3types.QueueConfiguration{ { Events: nil, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{ + Filter: &s3types.NotificationConfigurationFilter{ Key: nil, }, }, }, }, want: want{ - queueConfiguration: []types.QueueConfiguration{ + queueConfiguration: []s3types.QueueConfiguration{ { - Events: []types.Event{}, + Events: []s3types.Event{}, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{ + Filter: &s3types.NotificationConfigurationFilter{ Key: nil, }, }, @@ -795,7 +794,7 @@ func TestSanitizeQueue(t *testing.T) { }, "SanitizeQueueNilFilter": { args: args{ - cr: []types.QueueConfiguration{ + cr: []s3types.QueueConfiguration{ { Events: nil, QueueArn: nil, @@ -805,9 +804,9 @@ func TestSanitizeQueue(t *testing.T) { }, }, want: want{ - queueConfiguration: []types.QueueConfiguration{ + queueConfiguration: []s3types.QueueConfiguration{ { - Events: []types.Event{}, + Events: []s3types.Event{}, QueueArn: nil, Id: nil, Filter: nil, @@ -817,32 +816,32 @@ func TestSanitizeQueue(t *testing.T) { }, "SanitizeQueueEmptyFilter": { args: args{ - cr: []types.QueueConfiguration{ + cr: []s3types.QueueConfiguration{ { Events: nil, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{}, + Filter: &s3types.NotificationConfigurationFilter{}, }, }, }, want: want{ - queueConfiguration: []types.QueueConfiguration{ + queueConfiguration: []s3types.QueueConfiguration{ { - Events: []types.Event{}, + Events: []s3types.Event{}, QueueArn: nil, Id: nil, - Filter: &types.NotificationConfigurationFilter{}, + Filter: &s3types.NotificationConfigurationFilter{}, }, }, }, }, "SanitizeQueueEmptyConfigSlice": { args: args{ - cr: []types.QueueConfiguration{}, + cr: []s3types.QueueConfiguration{}, }, want: want{ - queueConfiguration: []types.QueueConfiguration{}, + queueConfiguration: []s3types.QueueConfiguration{}, }, }, "SanitizeQueueNilConfigSlice": { @@ -850,7 +849,7 @@ func TestSanitizeQueue(t *testing.T) { cr: nil, }, want: want{ - queueConfiguration: []types.QueueConfiguration{}, + queueConfiguration: []s3types.QueueConfiguration{}, }, }, } @@ -863,10 +862,10 @@ func TestSanitizeQueue(t *testing.T) { tc.want.queueConfiguration, actual, cmp.AllowUnexported( - types.FilterRule{}, - types.S3KeyFilter{}, - types.NotificationConfigurationFilter{}, - types.QueueConfiguration{}, + s3types.FilterRule{}, + s3types.S3KeyFilter{}, + s3types.NotificationConfigurationFilter{}, + s3types.QueueConfiguration{}, ), ); diff != "" { t.Errorf("r: -want, +got:\n%s", diff) diff --git a/pkg/controller/s3/bucket/publicAccessBlock.go b/pkg/controller/s3/bucket/publicAccessBlock.go index bded27cb85..210ce9d88d 100644 --- a/pkg/controller/s3/bucket/publicAccessBlock.go +++ b/pkg/controller/s3/bucket/publicAccessBlock.go @@ -24,6 +24,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/resource" "github.com/pkg/errors" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1" "github.com/crossplane-contrib/provider-aws/pkg/clients/s3" @@ -76,13 +77,13 @@ func (in *PublicAccessBlockClient) Observe(ctx context.Context, cr *v1beta1.Buck func isPublicAccessBlockUpToDate(cr *v1beta1.Bucket, external *awss3.GetPublicAccessBlockOutput) bool { if cr.Spec.ForProvider.PublicAccessBlockConfiguration != nil { switch { - case pointer.BoolValue(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicAcls) != external.PublicAccessBlockConfiguration.BlockPublicAcls: + case !ptr.Equal(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicAcls, external.PublicAccessBlockConfiguration.BlockPublicAcls): return false - case pointer.BoolValue(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicPolicy) != external.PublicAccessBlockConfiguration.BlockPublicPolicy: + case !ptr.Equal(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicPolicy, external.PublicAccessBlockConfiguration.BlockPublicPolicy): return false - case pointer.BoolValue(cr.Spec.ForProvider.PublicAccessBlockConfiguration.RestrictPublicBuckets) != external.PublicAccessBlockConfiguration.RestrictPublicBuckets: + case !ptr.Equal(cr.Spec.ForProvider.PublicAccessBlockConfiguration.RestrictPublicBuckets, external.PublicAccessBlockConfiguration.RestrictPublicBuckets): return false - case pointer.BoolValue(cr.Spec.ForProvider.PublicAccessBlockConfiguration.IgnorePublicAcls) != external.PublicAccessBlockConfiguration.IgnorePublicAcls: + case !ptr.Equal(cr.Spec.ForProvider.PublicAccessBlockConfiguration.IgnorePublicAcls, external.PublicAccessBlockConfiguration.IgnorePublicAcls): return false } } @@ -97,10 +98,10 @@ func (in *PublicAccessBlockClient) CreateOrUpdate(ctx context.Context, cr *v1bet input := &awss3.PutPublicAccessBlockInput{ Bucket: pointer.ToOrNilIfZeroValue(meta.GetExternalName(cr)), PublicAccessBlockConfiguration: &awss3types.PublicAccessBlockConfiguration{ - BlockPublicAcls: pointer.BoolValue(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicAcls), - BlockPublicPolicy: pointer.BoolValue(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicPolicy), - RestrictPublicBuckets: pointer.BoolValue(cr.Spec.ForProvider.PublicAccessBlockConfiguration.RestrictPublicBuckets), - IgnorePublicAcls: pointer.BoolValue(cr.Spec.ForProvider.PublicAccessBlockConfiguration.IgnorePublicAcls), + BlockPublicAcls: cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicAcls, + BlockPublicPolicy: cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicPolicy, + RestrictPublicBuckets: cr.Spec.ForProvider.PublicAccessBlockConfiguration.RestrictPublicBuckets, + IgnorePublicAcls: cr.Spec.ForProvider.PublicAccessBlockConfiguration.IgnorePublicAcls, }, } _, err := in.client.PutPublicAccessBlock(ctx, input) @@ -129,10 +130,10 @@ func (in *PublicAccessBlockClient) LateInitialize(ctx context.Context, cr *v1bet if cr.Spec.ForProvider.PublicAccessBlockConfiguration == nil { cr.Spec.ForProvider.PublicAccessBlockConfiguration = &v1beta1.PublicAccessBlockConfiguration{} } - cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicAcls = pointer.LateInitialize(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicAcls, pointer.ToOrNilIfZeroValue(external.PublicAccessBlockConfiguration.BlockPublicAcls)) - cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicPolicy = pointer.LateInitialize(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicPolicy, pointer.ToOrNilIfZeroValue(external.PublicAccessBlockConfiguration.BlockPublicPolicy)) - cr.Spec.ForProvider.PublicAccessBlockConfiguration.RestrictPublicBuckets = pointer.LateInitialize(cr.Spec.ForProvider.PublicAccessBlockConfiguration.RestrictPublicBuckets, pointer.ToOrNilIfZeroValue(external.PublicAccessBlockConfiguration.RestrictPublicBuckets)) - cr.Spec.ForProvider.PublicAccessBlockConfiguration.IgnorePublicAcls = pointer.LateInitialize(cr.Spec.ForProvider.PublicAccessBlockConfiguration.IgnorePublicAcls, pointer.ToOrNilIfZeroValue(external.PublicAccessBlockConfiguration.IgnorePublicAcls)) + cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicAcls = pointer.LateInitialize(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicAcls, external.PublicAccessBlockConfiguration.BlockPublicAcls) + cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicPolicy = pointer.LateInitialize(cr.Spec.ForProvider.PublicAccessBlockConfiguration.BlockPublicPolicy, external.PublicAccessBlockConfiguration.BlockPublicPolicy) + cr.Spec.ForProvider.PublicAccessBlockConfiguration.RestrictPublicBuckets = pointer.LateInitialize(cr.Spec.ForProvider.PublicAccessBlockConfiguration.RestrictPublicBuckets, external.PublicAccessBlockConfiguration.RestrictPublicBuckets) + cr.Spec.ForProvider.PublicAccessBlockConfiguration.IgnorePublicAcls = pointer.LateInitialize(cr.Spec.ForProvider.PublicAccessBlockConfiguration.IgnorePublicAcls, external.PublicAccessBlockConfiguration.IgnorePublicAcls) return nil } diff --git a/pkg/controller/s3/bucket/publicAccessBlock_test.go b/pkg/controller/s3/bucket/publicAccessBlock_test.go index a8d0c48e86..e2f2a8f3a5 100644 --- a/pkg/controller/s3/bucket/publicAccessBlock_test.go +++ b/pkg/controller/s3/bucket/publicAccessBlock_test.go @@ -9,6 +9,7 @@ import ( "github.com/aws/smithy-go" "github.com/crossplane/crossplane-runtime/pkg/test" "github.com/google/go-cmp/cmp" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1" clients3 "github.com/crossplane-contrib/provider-aws/pkg/clients/s3" @@ -101,7 +102,7 @@ func TestPublicAccessBlockClient_Observe(t *testing.T) { cl: NewPublicAccessBlockClient(fake.MockBucketClient{ MockGetPublicAccessBlock: func(ctx context.Context, input *s3.GetPublicAccessBlockInput, opts []func(*s3.Options)) (*s3.GetPublicAccessBlockOutput, error) { return &s3.GetPublicAccessBlockOutput{PublicAccessBlockConfiguration: &s3types.PublicAccessBlockConfiguration{ - BlockPublicAcls: false, + BlockPublicAcls: ptr.To(false), }}, nil }, }), @@ -127,7 +128,7 @@ func TestPublicAccessBlockClient_Observe(t *testing.T) { cl: NewPublicAccessBlockClient(fake.MockBucketClient{ MockGetPublicAccessBlock: func(ctx context.Context, input *s3.GetPublicAccessBlockInput, opts []func(*s3.Options)) (*s3.GetPublicAccessBlockOutput, error) { return &s3.GetPublicAccessBlockOutput{PublicAccessBlockConfiguration: &s3types.PublicAccessBlockConfiguration{ - BlockPublicAcls: true, + BlockPublicAcls: ptr.To(true), }}, nil }, }), @@ -150,8 +151,8 @@ func TestPublicAccessBlockClient_Observe(t *testing.T) { cl: NewPublicAccessBlockClient(fake.MockBucketClient{ MockGetPublicAccessBlock: func(ctx context.Context, input *s3.GetPublicAccessBlockInput, opts []func(*s3.Options)) (*s3.GetPublicAccessBlockOutput, error) { return &s3.GetPublicAccessBlockOutput{PublicAccessBlockConfiguration: &s3types.PublicAccessBlockConfiguration{ - BlockPublicAcls: true, - IgnorePublicAcls: true, + BlockPublicAcls: ptr.To(true), + IgnorePublicAcls: ptr.To(true), }}, nil }, }), @@ -174,7 +175,7 @@ func TestPublicAccessBlockClient_Observe(t *testing.T) { cl: NewPublicAccessBlockClient(fake.MockBucketClient{ MockGetPublicAccessBlock: func(ctx context.Context, input *s3.GetPublicAccessBlockInput, opts []func(*s3.Options)) (*s3.GetPublicAccessBlockOutput, error) { return &s3.GetPublicAccessBlockOutput{PublicAccessBlockConfiguration: &s3types.PublicAccessBlockConfiguration{ - BlockPublicAcls: true, + BlockPublicAcls: ptr.To(true), }}, nil }, }), diff --git a/pkg/controller/s3/bucket/replicationConfig.go b/pkg/controller/s3/bucket/replicationConfig.go index 85548291b6..f390fed7d7 100644 --- a/pkg/controller/s3/bucket/replicationConfig.go +++ b/pkg/controller/s3/bucket/replicationConfig.go @@ -28,6 +28,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/resource" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1" "github.com/crossplane-contrib/provider-aws/pkg/clients/s3" @@ -143,7 +144,7 @@ func createReplicationRulesFromExternal(external *types.ReplicationConfiguration for i, rule := range external.Rules { config.Rules[i] = v1beta1.ReplicationRule{ ID: rule.ID, - Priority: rule.Priority, + Priority: ptr.Deref(rule.Priority, 0), Filter: &v1beta1.ReplicationRuleFilter{}, Status: string(rule.Status), } @@ -194,7 +195,7 @@ func createReplicationRulesFromExternal(external *types.ReplicationConfiguration config.Rules[i].Destination.Metrics = &v1beta1.Metrics{} if rule.Destination.Metrics.EventThreshold != nil { config.Rules[i].Destination.Metrics.EventThreshold = &v1beta1.ReplicationTimeValue{} - config.Rules[i].Destination.Metrics.EventThreshold.Minutes = rule.Destination.Metrics.EventThreshold.Minutes + config.Rules[i].Destination.Metrics.EventThreshold.Minutes = ptr.Deref(rule.Destination.Metrics.EventThreshold.Minutes, 0) } config.Rules[i].Destination.Metrics.Status = string(rule.Destination.Metrics.Status) } @@ -202,7 +203,7 @@ func createReplicationRulesFromExternal(external *types.ReplicationConfiguration config.Rules[i].Destination.ReplicationTime = &v1beta1.ReplicationTime{} config.Rules[i].Destination.ReplicationTime.Status = string(rule.Destination.ReplicationTime.Status) if rule.Destination.ReplicationTime.Time != nil { - config.Rules[i].Destination.ReplicationTime.Time.Minutes = rule.Destination.ReplicationTime.Time.Minutes + config.Rules[i].Destination.ReplicationTime.Time.Minutes = ptr.Deref(rule.Destination.ReplicationTime.Time.Minutes, 0) } } } @@ -261,7 +262,7 @@ func copyDestination(input *v1beta1.ReplicationRule, newRule *types.ReplicationR Status: types.MetricsStatus(input.Destination.Metrics.Status), } if input.Destination.Metrics.EventThreshold != nil { - newRule.Destination.Metrics.EventThreshold = &types.ReplicationTimeValue{Minutes: input.Destination.Metrics.EventThreshold.Minutes} + newRule.Destination.Metrics.EventThreshold = &types.ReplicationTimeValue{Minutes: &input.Destination.Metrics.EventThreshold.Minutes} } } if input.Destination.ReplicationTime != nil { @@ -271,7 +272,7 @@ func copyDestination(input *v1beta1.ReplicationRule, newRule *types.ReplicationR } if input.Destination.ReplicationTime != nil { newRule.Destination.ReplicationTime.Time = &types.ReplicationTimeValue{ - Minutes: input.Destination.ReplicationTime.Time.Minutes, + Minutes: &input.Destination.ReplicationTime.Time.Minutes, } } } @@ -281,7 +282,7 @@ func createRule(input v1beta1.ReplicationRule) types.ReplicationRule { Rule := input newRule := types.ReplicationRule{ ID: Rule.ID, - Priority: Rule.Priority, + Priority: &Rule.Priority, Filter: &types.ReplicationRuleFilterMemberPrefix{Value: ""}, Status: types.ReplicationRuleStatus(Rule.Status), } diff --git a/pkg/controller/s3/bucket/replicationConfig_test.go b/pkg/controller/s3/bucket/replicationConfig_test.go index c16ad955fb..5e906b8f0b 100644 --- a/pkg/controller/s3/bucket/replicationConfig_test.go +++ b/pkg/controller/s3/bucket/replicationConfig_test.go @@ -25,6 +25,7 @@ import ( "github.com/aws/smithy-go" "github.com/crossplane/crossplane-runtime/pkg/test" "github.com/google/go-cmp/cmp" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1" clientss3 "github.com/crossplane-contrib/provider-aws/pkg/clients/s3" @@ -90,11 +91,11 @@ func generateAWSReplication() *s3types.ReplicationConfiguration { Bucket: &bucketName, EncryptionConfiguration: &s3types.EncryptionConfiguration{ReplicaKmsKeyID: &kmsID}, Metrics: &s3types.Metrics{ - EventThreshold: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + EventThreshold: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.MetricsStatusEnabled, }, ReplicationTime: &s3types.ReplicationTime{ - Time: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + Time: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.ReplicationTimeStatusEnabled, }, StorageClass: s3types.StorageClassOnezoneIa, @@ -107,7 +108,7 @@ func generateAWSReplication() *s3types.ReplicationConfiguration { }, }, ID: &id, - Priority: priority, + Priority: &priority, SourceSelectionCriteria: &s3types.SourceSelectionCriteria{SseKmsEncryptedObjects: &s3types.SseKmsEncryptedObjects{Status: s3types.SseKmsEncryptedObjectsStatusEnabled}}, Status: s3types.ReplicationRuleStatusEnabled, }}, @@ -519,11 +520,11 @@ func TestIsUpToDate(t *testing.T) { Bucket: &bucketName, EncryptionConfiguration: &s3types.EncryptionConfiguration{ReplicaKmsKeyID: &kmsID}, Metrics: &s3types.Metrics{ - EventThreshold: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + EventThreshold: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.MetricsStatusEnabled, }, ReplicationTime: &s3types.ReplicationTime{ - Time: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + Time: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.ReplicationTimeStatusEnabled, }, StorageClass: s3types.StorageClassOnezoneIa, @@ -536,7 +537,7 @@ func TestIsUpToDate(t *testing.T) { }, }, ID: &id, - Priority: priority, + Priority: &priority, SourceSelectionCriteria: &s3types.SourceSelectionCriteria{SseKmsEncryptedObjects: &s3types.SseKmsEncryptedObjects{Status: s3types.SseKmsEncryptedObjectsStatusEnabled}}, Status: s3types.ReplicationRuleStatusEnabled, }}, @@ -619,11 +620,11 @@ func TestIsUpToDate(t *testing.T) { Bucket: pointer.ToOrNilIfZeroValue("bucket-2"), EncryptionConfiguration: &s3types.EncryptionConfiguration{ReplicaKmsKeyID: &kmsID}, Metrics: &s3types.Metrics{ - EventThreshold: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + EventThreshold: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.MetricsStatusEnabled, }, ReplicationTime: &s3types.ReplicationTime{ - Time: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + Time: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.ReplicationTimeStatusEnabled, }, StorageClass: s3types.StorageClassOnezoneIa, @@ -636,7 +637,7 @@ func TestIsUpToDate(t *testing.T) { }, }, ID: pointer.ToOrNilIfZeroValue("rule-2"), - Priority: priority, + Priority: &priority, SourceSelectionCriteria: &s3types.SourceSelectionCriteria{SseKmsEncryptedObjects: &s3types.SseKmsEncryptedObjects{Status: s3types.SseKmsEncryptedObjectsStatusEnabled}}, Status: s3types.ReplicationRuleStatusEnabled, }, @@ -648,11 +649,11 @@ func TestIsUpToDate(t *testing.T) { Bucket: pointer.ToOrNilIfZeroValue("bucket-1"), EncryptionConfiguration: &s3types.EncryptionConfiguration{ReplicaKmsKeyID: &kmsID}, Metrics: &s3types.Metrics{ - EventThreshold: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + EventThreshold: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.MetricsStatusEnabled, }, ReplicationTime: &s3types.ReplicationTime{ - Time: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + Time: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.ReplicationTimeStatusEnabled, }, StorageClass: s3types.StorageClassOnezoneIa, @@ -665,7 +666,7 @@ func TestIsUpToDate(t *testing.T) { }, }, ID: pointer.ToOrNilIfZeroValue("rule-1"), - Priority: priority, + Priority: &priority, SourceSelectionCriteria: &s3types.SourceSelectionCriteria{SseKmsEncryptedObjects: &s3types.SseKmsEncryptedObjects{Status: s3types.SseKmsEncryptedObjectsStatusEnabled}}, Status: s3types.ReplicationRuleStatusEnabled, }}, @@ -726,11 +727,11 @@ func TestIsUpToDate(t *testing.T) { Bucket: &bucketName, EncryptionConfiguration: &s3types.EncryptionConfiguration{ReplicaKmsKeyID: &kmsID}, Metrics: &s3types.Metrics{ - EventThreshold: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + EventThreshold: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.MetricsStatusEnabled, }, ReplicationTime: &s3types.ReplicationTime{ - Time: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + Time: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.ReplicationTimeStatusEnabled, }, StorageClass: s3types.StorageClassOnezoneIa, @@ -752,7 +753,7 @@ func TestIsUpToDate(t *testing.T) { }, }, ID: &id, - Priority: priority, + Priority: &priority, SourceSelectionCriteria: &s3types.SourceSelectionCriteria{SseKmsEncryptedObjects: &s3types.SseKmsEncryptedObjects{Status: s3types.SseKmsEncryptedObjectsStatusEnabled}}, Status: s3types.ReplicationRuleStatusEnabled, }}, @@ -801,11 +802,11 @@ func TestIsUpToDate(t *testing.T) { Bucket: &bucketName, EncryptionConfiguration: &s3types.EncryptionConfiguration{ReplicaKmsKeyID: &kmsID}, Metrics: &s3types.Metrics{ - EventThreshold: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + EventThreshold: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.MetricsStatusEnabled, }, ReplicationTime: &s3types.ReplicationTime{ - Time: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + Time: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.ReplicationTimeStatusEnabled, }, StorageClass: s3types.StorageClassOnezoneIa, @@ -815,7 +816,7 @@ func TestIsUpToDate(t *testing.T) { Value: "", }, ID: &id, - Priority: priority, + Priority: &priority, SourceSelectionCriteria: &s3types.SourceSelectionCriteria{SseKmsEncryptedObjects: &s3types.SseKmsEncryptedObjects{Status: s3types.SseKmsEncryptedObjectsStatusEnabled}}, Status: s3types.ReplicationRuleStatusEnabled, }}, @@ -869,11 +870,11 @@ func TestIsUpToDate(t *testing.T) { Bucket: &bucketName, EncryptionConfiguration: &s3types.EncryptionConfiguration{ReplicaKmsKeyID: &kmsID}, Metrics: &s3types.Metrics{ - EventThreshold: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + EventThreshold: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.MetricsStatusEnabled, }, ReplicationTime: &s3types.ReplicationTime{ - Time: &s3types.ReplicationTimeValue{Minutes: int32(replicationTime)}, + Time: &s3types.ReplicationTimeValue{Minutes: ptr.To(int32(replicationTime))}, Status: s3types.ReplicationTimeStatusEnabled, }, StorageClass: s3types.StorageClassOnezoneIa, @@ -886,7 +887,7 @@ func TestIsUpToDate(t *testing.T) { }, }, ID: &id, - Priority: priority, + Priority: &priority, SourceSelectionCriteria: &s3types.SourceSelectionCriteria{SseKmsEncryptedObjects: &s3types.SseKmsEncryptedObjects{Status: s3types.SseKmsEncryptedObjectsStatusEnabled}}, Status: s3types.ReplicationRuleStatusEnabled, }}, diff --git a/pkg/controller/s3/bucket/sseConfig.go b/pkg/controller/s3/bucket/sseConfig.go index ec6336802d..50535f78a3 100644 --- a/pkg/controller/s3/bucket/sseConfig.go +++ b/pkg/controller/s3/bucket/sseConfig.go @@ -23,6 +23,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/resource" + "k8s.io/utils/ptr" "github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1" "github.com/crossplane-contrib/provider-aws/pkg/clients/s3" @@ -76,7 +77,7 @@ func (in *SSEConfigurationClient) Observe(ctx context.Context, bucket *v1beta1.B if string(outputRule.SSEAlgorithm) != Rule.ApplyServerSideEncryptionByDefault.SSEAlgorithm { return NeedsUpdate, nil } - if external.ServerSideEncryptionConfiguration.Rules[i].BucketKeyEnabled != Rule.BucketKeyEnabled { + if ptr.Deref(external.ServerSideEncryptionConfiguration.Rules[i].BucketKeyEnabled, false) != Rule.BucketKeyEnabled { return NeedsUpdate, nil } } @@ -144,7 +145,7 @@ func GeneratePutBucketEncryptionInput(name string, config *v1beta1.ServerSideEnc } for i, rule := range config.Rules { bei.ServerSideEncryptionConfiguration.Rules[i] = types.ServerSideEncryptionRule{ - BucketKeyEnabled: rule.BucketKeyEnabled, + BucketKeyEnabled: ptr.To(rule.BucketKeyEnabled), ApplyServerSideEncryptionByDefault: &types.ServerSideEncryptionByDefault{ KMSMasterKeyID: rule.ApplyServerSideEncryptionByDefault.KMSMasterKeyID, SSEAlgorithm: types.ServerSideEncryption(rule.ApplyServerSideEncryptionByDefault.SSEAlgorithm), diff --git a/pkg/utils/connect/aws/config.go b/pkg/utils/connect/aws/config.go index 00d7d1dcfb..4106f66414 100644 --- a/pkg/utils/connect/aws/config.go +++ b/pkg/utils/connect/aws/config.go @@ -154,9 +154,9 @@ func UseProviderConfig(ctx context.Context, c client.Client, mg resource.Managed } } -type awsEndpointResolverAdaptorWithOptions func(service, region string, options interface{}) (aws.Endpoint, error) +type awsEndpointResolverAdaptorWithOptions func(service, region string, options interface{}) (aws.Endpoint, error) //nolint:staticcheck -func (a awsEndpointResolverAdaptorWithOptions) ResolveEndpoint(service, region string, options ...interface{}) (aws.Endpoint, error) { +func (a awsEndpointResolverAdaptorWithOptions) ResolveEndpoint(service, region string, options ...interface{}) (aws.Endpoint, error) { //nolint:staticcheck return a(service, region, options) } @@ -166,17 +166,17 @@ func SetResolver(pc *v1beta1.ProviderConfig, cfg *aws.Config) *aws.Config { //no if pc.Spec.Endpoint == nil { return cfg } - cfg.EndpointResolverWithOptions = awsEndpointResolverAdaptorWithOptions(func(service, region string, options interface{}) (aws.Endpoint, error) { + cfg.EndpointResolverWithOptions = awsEndpointResolverAdaptorWithOptions(func(service, region string, options interface{}) (aws.Endpoint, error) { //nolint:staticcheck fullURL := "" switch pc.Spec.Endpoint.URL.Type { case URLConfigTypeStatic: if pc.Spec.Endpoint.URL.Static == nil { - return aws.Endpoint{}, errors.New("static type is chosen but static field does not have a value") + return aws.Endpoint{}, errors.New("static type is chosen but static field does not have a value") //nolint:staticcheck } fullURL = pointer.StringValue(pc.Spec.Endpoint.URL.Static) case URLConfigTypeDynamic: if pc.Spec.Endpoint.URL.Dynamic == nil { - return aws.Endpoint{}, errors.New("dynamic type is chosen but dynamic configuration is not given") + return aws.Endpoint{}, errors.New("dynamic type is chosen but dynamic configuration is not given") //nolint:staticcheck } // NOTE(muvaf): IAM and Route 53 do not have a region. if service == "IAM" || service == "Route 53" { @@ -185,9 +185,9 @@ func SetResolver(pc *v1beta1.ProviderConfig, cfg *aws.Config) *aws.Config { //no fullURL = fmt.Sprintf("%s://%s.%s.%s", pc.Spec.Endpoint.URL.Dynamic.Protocol, strings.ToLower(service), region, pc.Spec.Endpoint.URL.Dynamic.Host) } default: - return aws.Endpoint{}, errors.New("unsupported url config type is chosen") + return aws.Endpoint{}, errors.New("unsupported url config type is chosen") //nolint:staticcheck } - e := aws.Endpoint{ + e := aws.Endpoint{ //nolint:staticcheck URL: fullURL, HostnameImmutable: pointer.BoolValue(pc.Spec.Endpoint.HostnameImmutable), PartitionID: pointer.StringValue(pc.Spec.Endpoint.PartitionID), @@ -783,7 +783,7 @@ func SetAssumeRoleOptions(pc *v1beta1.ProviderConfig) func(*stscreds.AssumeRoleO opt.ExternalID = pc.Spec.AssumeRole.ExternalID } - if pc.Spec.AssumeRole.Tags != nil && len(pc.Spec.AssumeRole.Tags) > 0 { + if len(pc.Spec.AssumeRole.Tags) > 0 { for _, t := range pc.Spec.AssumeRole.Tags { opt.Tags = append( opt.Tags, @@ -791,7 +791,7 @@ func SetAssumeRoleOptions(pc *v1beta1.ProviderConfig) func(*stscreds.AssumeRoleO } } - if pc.Spec.AssumeRole.TransitiveTagKeys != nil && len(pc.Spec.AssumeRole.TransitiveTagKeys) > 0 { + if len(pc.Spec.AssumeRole.TransitiveTagKeys) > 0 { opt.TransitiveTagKeys = pc.Spec.AssumeRole.TransitiveTagKeys } } diff --git a/pkg/utils/connect/aws/config_test.go b/pkg/utils/connect/aws/config_test.go index 876ff2f530..5f39ea73b2 100644 --- a/pkg/utils/connect/aws/config_test.go +++ b/pkg/utils/connect/aws/config_test.go @@ -503,7 +503,7 @@ func TestUseProviderConfigResolveEndpoint(t *testing.T) { // If no endpointConfig was provided the returned endpointResolver should be nil if tc.args.endpointConfig != nil { - actual, endpointError := config.EndpointResolverWithOptions.ResolveEndpoint(tc.args.service, tc.args.region, nil) + actual, endpointError := config.EndpointResolverWithOptions.ResolveEndpoint(tc.args.service, tc.args.region, nil) //nolint:staticcheck // Assert exceptions match if diff := cmp.Diff(tc.want.error, endpointError, test.EquateConditions()); diff != "" { t.Errorf("r: -want error, +got error:\n%s", diff) @@ -512,7 +512,7 @@ func TestUseProviderConfigResolveEndpoint(t *testing.T) { if diff := cmp.Diff(tc.want.url, actual.URL); diff != "" { t.Errorf("add: -want, +got:\n%s", diff) } - } else if config.EndpointResolverWithOptions != nil { + } else if config.EndpointResolverWithOptions != nil { //nolint:staticcheck t.Errorf("Expected config.EndpointResolverWithOptions to be nil") } })