Skip to content

Commit 5facb46

Browse files
feat: CLOUDP-380110: Update input scripts to fix publish error (#1601)
Co-authored-by: Rakhul S Prakash <rakhul.s.prakash@peerislands.io>
1 parent 7dbc200 commit 5facb46

5 files changed

Lines changed: 26 additions & 51 deletions

File tree

cfn-resources/service-account-access-list-entry/test/cfn-test-create-inputs.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ set -o nounset
99
set -o pipefail
1010

1111
function usage {
12-
echo "usage:$0 <org_id>"
12+
echo "usage: $0"
13+
echo " Requires MONGODB_ATLAS_ORG_ID environment variable to be set."
1314
echo "Generates test input files for service account access list entry"
1415
exit 0
1516
}
1617

17-
if [ "$#" -ne 1 ]; then usage; fi
18-
if [[ "$*" == help ]]; then usage; fi
18+
if [[ "${1:-}" == help ]]; then usage; fi
19+
20+
if [ -z "${MONGODB_ATLAS_ORG_ID:-}" ]; then
21+
echo "Error: MONGODB_ATLAS_ORG_ID environment variable is not set"
22+
exit 1
23+
fi
24+
25+
orgId="${MONGODB_ATLAS_ORG_ID}"
26+
echo "OrgId: $orgId"
1927

2028
rm -rf inputs
2129
mkdir inputs
@@ -27,9 +35,6 @@ if [ ${MONGODB_ATLAS_PROFILE+x} ]; then
2735
profile=${MONGODB_ATLAS_PROFILE}
2836
fi
2937

30-
orgId="${1}"
31-
echo "OrgId: $orgId"
32-
3338
serviceAccountName="cfn-test-sa-accesslist-$(date +%s)-$RANDOM"
3439
echo "Creating service account: $serviceAccountName"
3540

cfn-resources/service-account-access-list-entry/test/contract-testing/cfn-test-create.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,4 @@ set -o errexit
55
set -o nounset
66
set -o pipefail
77

8-
if [ -z "${MONGODB_ATLAS_ORG_ID:-}" ]; then
9-
echo "Error: MONGODB_ATLAS_ORG_ID environment variable is not set"
10-
exit 1
11-
fi
12-
13-
orgId="${MONGODB_ATLAS_ORG_ID}"
14-
echo "Using OrgId: $orgId"
15-
16-
./test/cfn-test-create-inputs.sh "$orgId"
8+
./test/cfn-test-create-inputs.sh

cfn-resources/service-account-secret/test/cfn-test-create-inputs.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ set -o nounset
99
set -o pipefail
1010

1111
function usage {
12-
echo "usage:$0 <org_id>"
12+
echo "usage: $0"
13+
echo " Requires MONGODB_ATLAS_ORG_ID environment variable to be set."
1314
echo "Generates test input files for service account secret"
1415
exit 0
1516
}
1617

17-
if [ "$#" -ne 1 ]; then usage; fi
18-
if [[ "$*" == help ]]; then usage; fi
18+
if [[ "${1:-}" == help ]]; then usage; fi
19+
20+
if [ -z "${MONGODB_ATLAS_ORG_ID:-}" ]; then
21+
echo "Error: MONGODB_ATLAS_ORG_ID environment variable is not set"
22+
exit 1
23+
fi
24+
25+
orgId="${MONGODB_ATLAS_ORG_ID}"
26+
echo "OrgId: $orgId"
1927

2028
rm -rf inputs
2129
mkdir inputs
@@ -27,9 +35,6 @@ if [ ${MONGODB_ATLAS_PROFILE+x} ]; then
2735
profile=${MONGODB_ATLAS_PROFILE}
2836
fi
2937

30-
orgId="${1}"
31-
echo "OrgId: $orgId"
32-
3338
# Create a service account for testing using Atlas CLI
3439
serviceAccountName="cfn-test-sa-$(date +%s)-$RANDOM"
3540
echo "Creating service account: $serviceAccountName"

cfn-resources/service-account-secret/test/contract-testing/cfn-test-create.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,4 @@ set -o errexit
55
set -o nounset
66
set -o pipefail
77

8-
# Get org ID from environment or use default
9-
if [ -z "${MONGODB_ATLAS_ORG_ID:-}" ]; then
10-
echo "Error: MONGODB_ATLAS_ORG_ID environment variable is not set"
11-
exit 1
12-
fi
13-
14-
orgId="${MONGODB_ATLAS_ORG_ID}"
15-
echo "Using OrgId: $orgId"
16-
17-
./test/cfn-test-create-inputs.sh "$orgId"
8+
./test/cfn-test-create-inputs.sh
Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
#!/usr/bin/env bash
22

3-
# This tool deletes the mongodb resources used for `cfn test` as inputs.
3+
# This tool deletes the MongoDB resources used for `cfn test` as inputs.
44
set -o errexit
55
set -o nounset
66
set -o pipefail
77

8-
if [ ! -f ./inputs/inputs_1_create.json ]; then
9-
echo "No inputs file found, nothing to clean up"
10-
exit 0
11-
fi
12-
13-
orgId=$(jq -r '.OrgId' ./inputs/inputs_1_create.json)
14-
clientId=$(jq -r '.ClientId' ./inputs/inputs_1_create.json)
15-
16-
# Delete service account using Atlas CLI (this will also delete all its secrets)
17-
if atlas api serviceAccounts deleteOrgServiceAccount --orgId "$orgId" --clientId "$clientId" --version "2024-08-05" --output json 2>/dev/null; then
18-
echo "Service account $clientId deletion OK"
19-
else
20-
exitCode=$?
21-
if [ $exitCode -eq 0 ]; then
22-
echo "Service account $clientId deletion OK"
23-
else
24-
echo "Warning: Failed cleaning service account: $clientId (may already be deleted)"
25-
fi
26-
fi
8+
./test/cfn-test-delete-inputs.sh

0 commit comments

Comments
 (0)