From 804770651641b19df991745fee1865795030dcb1 Mon Sep 17 00:00:00 2001 From: Russsnizza <134000942+Russsnizza@users.noreply.github.com> Date: Thu, 19 Sep 2024 18:15:51 -0500 Subject: [PATCH 1/2] Add null pointer checks for improved error handling Fix example for db-cluster-parameter-group. --- .../gyro/aws/rds/DbClusterParameterGroupFinder.java | 2 +- src/main/java/gyro/aws/rds/DbClusterResource.java | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/gyro/aws/rds/DbClusterParameterGroupFinder.java b/src/main/java/gyro/aws/rds/DbClusterParameterGroupFinder.java index 2d4097f59..ce2334223 100644 --- a/src/main/java/gyro/aws/rds/DbClusterParameterGroupFinder.java +++ b/src/main/java/gyro/aws/rds/DbClusterParameterGroupFinder.java @@ -34,7 +34,7 @@ * * .. code-block:: gyro * - * cluster-parameter-groups: $(external-query aws::db-cluster-parameter-group { name: 'cluster-parameter-group-example'}) + * db-cluster-parameter-group: $(external-query aws::db-cluster-parameter-group { name: 'cluster-parameter-group-example'}) */ @Type("db-cluster-parameter-group") public class DbClusterParameterGroupFinder extends AwsFinder { diff --git a/src/main/java/gyro/aws/rds/DbClusterResource.java b/src/main/java/gyro/aws/rds/DbClusterResource.java index b74eb068a..610ea83b2 100644 --- a/src/main/java/gyro/aws/rds/DbClusterResource.java +++ b/src/main/java/gyro/aws/rds/DbClusterResource.java @@ -902,7 +902,8 @@ protected void doCreate(GyroUI ui, State state) { .map(SecurityGroupResource::getId) .collect(Collectors.toList()) : null) .manageMasterUserPassword(getManageMasterUserPassword()) - .masterUserSecretKmsKeyId(getMasterUserSecretKmsKey().getId()) + .masterUserSecretKmsKeyId( + getMasterUserSecretKmsKey() == null ? null : getMasterUserSecretKmsKey().getId()) .serverlessV2ScalingConfiguration(getServerlessV2ScalingConfiguration() != null ? getServerlessV2ScalingConfiguration().toServerlessV2ScalingConfiguration() : null) .storageType(getStorageType()) @@ -963,11 +964,12 @@ protected void doCreate(GyroUI ui, State state) { .dbClusterInstanceClass(getDbClusterInstanceClass()) .iops(getIops()) .manageMasterUserPassword(getManageMasterUserPassword()) - .masterUserSecretKmsKeyId(getMasterUserSecretKmsKey().getId()) + .masterUserSecretKmsKeyId( + getMasterUserSecretKmsKey() == null ? null : getMasterUserSecretKmsKey().getId()) .serverlessV2ScalingConfiguration(getServerlessV2ScalingConfiguration() != null ? getServerlessV2ScalingConfiguration().toServerlessV2ScalingConfiguration() : null) .storageType(getStorageType()) - .allocatedStorage(getAllocatedStorage()) + .allocatedStorage(getAllocatedStorage() == null ? null : getAllocatedStorage()) .autoMinorVersionUpgrade(getAutoMinorVersionUpgrade()) .copyTagsToSnapshot(getCopyTagsToSnapshot()) .enableLocalWriteForwarding(getEnableLocalWriteForwarding()) @@ -1059,11 +1061,12 @@ protected void doUpdate(Resource config, Set changedProperties) { .dbClusterInstanceClass(getDbClusterInstanceClass()) .iops(getIops()) .manageMasterUserPassword(getManageMasterUserPassword()) - .masterUserSecretKmsKeyId(getMasterUserSecretKmsKey().getId()) + .masterUserSecretKmsKeyId( + getMasterUserSecretKmsKey() == null ? null : getMasterUserSecretKmsKey().getId()) .serverlessV2ScalingConfiguration(getServerlessV2ScalingConfiguration() != null ? getServerlessV2ScalingConfiguration().toServerlessV2ScalingConfiguration() : null) .storageType(getStorageType()) - .allocatedStorage(getAllocatedStorage()) + .allocatedStorage(getAllocatedStorage() == null ? null : getAllocatedStorage()) .autoMinorVersionUpgrade(getAutoMinorVersionUpgrade()) .copyTagsToSnapshot(getCopyTagsToSnapshot()) .enableLocalWriteForwarding(Objects.equals(getEnableLocalWriteForwarding(), From 8e17ceba82f0cdedb2e381c0e7f94c0c5fa78010 Mon Sep 17 00:00:00 2001 From: Russsnizza <134000942+Russsnizza@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:22:13 -0500 Subject: [PATCH 2/2] Delete NP ternary operator from allocatedStorage(getAllocatedStorage() --- src/main/java/gyro/aws/rds/DbClusterResource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gyro/aws/rds/DbClusterResource.java b/src/main/java/gyro/aws/rds/DbClusterResource.java index 610ea83b2..7cb247776 100644 --- a/src/main/java/gyro/aws/rds/DbClusterResource.java +++ b/src/main/java/gyro/aws/rds/DbClusterResource.java @@ -969,7 +969,7 @@ protected void doCreate(GyroUI ui, State state) { .serverlessV2ScalingConfiguration(getServerlessV2ScalingConfiguration() != null ? getServerlessV2ScalingConfiguration().toServerlessV2ScalingConfiguration() : null) .storageType(getStorageType()) - .allocatedStorage(getAllocatedStorage() == null ? null : getAllocatedStorage()) + .allocatedStorage(getAllocatedStorage()) .autoMinorVersionUpgrade(getAutoMinorVersionUpgrade()) .copyTagsToSnapshot(getCopyTagsToSnapshot()) .enableLocalWriteForwarding(getEnableLocalWriteForwarding()) @@ -1066,7 +1066,7 @@ protected void doUpdate(Resource config, Set changedProperties) { .serverlessV2ScalingConfiguration(getServerlessV2ScalingConfiguration() != null ? getServerlessV2ScalingConfiguration().toServerlessV2ScalingConfiguration() : null) .storageType(getStorageType()) - .allocatedStorage(getAllocatedStorage() == null ? null : getAllocatedStorage()) + .allocatedStorage(getAllocatedStorage()) .autoMinorVersionUpgrade(getAutoMinorVersionUpgrade()) .copyTagsToSnapshot(getCopyTagsToSnapshot()) .enableLocalWriteForwarding(Objects.equals(getEnableLocalWriteForwarding(),