Skip to content

Commit 87b4640

Browse files
author
Nivedithaa Mahendran
committed
update suite function
1 parent 54ec518 commit 87b4640

6 files changed

Lines changed: 30 additions & 15 deletions

File tree

image/cli/mascli/functions/gitops_mas_config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ function gitops_mas_config_noninteractive() {
404404
if [ "${CONFIG_ACTION}" == "upsert" ]; then
405405

406406
if [ "${MAS_CONFIG_TYPE}" == "mongo" ]; then
407-
export MONGODB_PROVIDER=${MONGODB_PROVIDER:-"yaml"}
407+
export MONGODB_PROVIDER=${MONGODB_PROVIDER:-"aws"}
408408
if ! [[ "$MONGODB_PROVIDER" =~ ^(aws|yaml)$ ]]; then
409409
gitops_mas_config_help "Invalid MONGODB_PROVIDER \"${MONGODB_PROVIDER}\"; must be one of aws|yaml"
410410
fi

image/cli/mascli/functions/gitops_mongo_atlas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ AWS Secrets Manager Configuration (Required):
2222
2323
MongoDB Atlas Configuration (Required):
2424
--atlas-uri ${COLOR_YELLOW}ATLAS_URI${TEXT_RESET} MongoDB Atlas URI (default: 'https://cloud.mongodb.com/')
25-
--mongo-provider ${COLOR_YELLOW}MONGODB_PROVIDER${TEXT_RESET} MongoDB provider type (default: 'atlas')
25+
--mongo-provider ${COLOR_YELLOW}MONGODB_PROVIDER${TEXT_RESET} MongoDB provider type (default: 'aws')
2626
2727
MongoDB Atlas Resource Configuration (Required):
2828
--mongo-action ${COLOR_YELLOW}MONGO_ACTION${TEXT_RESET} Action to perform ('install' or 'uninstall')
@@ -104,7 +104,7 @@ function gitops_mongo_atlas_noninteractive() {
104104

105105
# MongoDB Atlas defaults
106106
export ATLAS_URI=${ATLAS_URI:-"https://cloud.mongodb.com/"}
107-
export MONGODB_PROVIDER=${MONGODB_PROVIDER:-"yaml"}
107+
export MONGODB_PROVIDER=${MONGODB_PROVIDER:-"aws"}
108108
export MONGO_NODE_COUNT=${MONGO_NODE_COUNT:-3}
109109
export MONGO_SHARDS=${MONGO_SHARDS:-1}
110110
export MONGO_BACKUP_ENABLED=${MONGO_BACKUP_ENABLED:-"true"}

image/cli/mascli/functions/gitops_suite

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ function gitops_suite() {
763763
fi
764764

765765
# by default yaml. pass aws, in case if configuring with DocDB
766-
export MONGODB_PROVIDER=${MONGODB_PROVIDER:-"yaml"}
766+
export MONGODB_PROVIDER=${MONGODB_PROVIDER:-"aws"}
767767

768768
# MongoDB reset and update flags
769769
export MONGO_RESET_INSTANCE_PASSWORD=${MONGO_RESET_INSTANCE_PASSWORD:-"false"}
@@ -772,13 +772,27 @@ function gitops_suite() {
772772
export MONGO_SECRET_FILE=$TEMP_DIR/mongo-secret.json
773773
export MONGO_CONFIG_FILE=$TEMP_DIR/mongo-info.yaml
774774

775-
sm_verify_secret_exists ${ACCOUNT_ID}${SECRETS_KEY_SEPERATOR}${CLUSTER_ID}${SECRETS_KEY_SEPERATOR}mongo "username,password,info"
776-
sm_get_secret_file ${ACCOUNT_ID}${SECRETS_KEY_SEPERATOR}${CLUSTER_ID}${SECRETS_KEY_SEPERATOR}mongo $MONGO_SECRET_FILE
777-
778-
jq -r .info $MONGO_SECRET_FILE > $MONGO_CONFIG_FILE
779-
MASTER_MONGO_USERNAME=$(jq -r .username $MONGO_SECRET_FILE)
780-
MASTER_MONGO_PASSWORD=$(jq -r .password $MONGO_SECRET_FILE)
781-
UNESCAPED_MONGO_INFO=$(jq -r .info $MONGO_SECRET_FILE)
775+
# Verify cluster-level secret exists and retrieve it
776+
# If mongodb_provider is yaml and mongo_action is install, only info field is required
777+
if [[ "${MONGODB_PROVIDER}" == "yaml" && "${MONGO_ACTION}" == "install" ]]; then
778+
echo
779+
echo_h2 "MongoDB Provider is 'yaml' - Verifying cluster-level MongoDB secret (info field only)"
780+
sm_verify_secret_exists ${ACCOUNT_ID}${SECRETS_KEY_SEPERATOR}${CLUSTER_ID}${SECRETS_KEY_SEPERATOR}mongo "info"
781+
sm_get_secret_file ${ACCOUNT_ID}${SECRETS_KEY_SEPERATOR}${CLUSTER_ID}${SECRETS_KEY_SEPERATOR}mongo $MONGO_SECRET_FILE
782+
783+
jq -r .info $MONGO_SECRET_FILE > $MONGO_CONFIG_FILE
784+
UNESCAPED_MONGO_INFO=$(jq -r .info $MONGO_SECRET_FILE)
785+
echo "✓ Cluster-level MongoDB secret verified (master credentials not required for yaml provider)"
786+
else
787+
# For aws provider or other actions, retrieve and process the secret with all fields
788+
sm_verify_secret_exists ${ACCOUNT_ID}${SECRETS_KEY_SEPERATOR}${CLUSTER_ID}${SECRETS_KEY_SEPERATOR}mongo "username,password,info"
789+
sm_get_secret_file ${ACCOUNT_ID}${SECRETS_KEY_SEPERATOR}${CLUSTER_ID}${SECRETS_KEY_SEPERATOR}mongo $MONGO_SECRET_FILE
790+
791+
jq -r .info $MONGO_SECRET_FILE > $MONGO_CONFIG_FILE
792+
MASTER_MONGO_USERNAME=$(jq -r .username $MONGO_SECRET_FILE)
793+
MASTER_MONGO_PASSWORD=$(jq -r .password $MONGO_SECRET_FILE)
794+
UNESCAPED_MONGO_INFO=$(jq -r .info $MONGO_SECRET_FILE)
795+
fi
782796

783797

784798
# Instance-level secrets to use
@@ -794,12 +808,13 @@ function gitops_suite() {
794808
export SECRET_KEY_MONGO_INFO=${SECRET_NAME_MONGO}#info
795809

796810

811+
# Create/update instance-level secret
797812
export MONGO_INSTANCE_SECRET_FILE=$TEMP_DIR/mongo-instance-secret.json
798813
sm_get_secret_file ${ACCOUNT_ID}${SECRETS_KEY_SEPERATOR}${CLUSTER_ID}${SECRETS_KEY_SEPERATOR}${MAS_INSTANCE_ID}${SECRETS_KEY_SEPERATOR}mongo $MONGO_INSTANCE_SECRET_FILE
799814
INSTANCE_MONGO_USERNAME=$(jq -r .username $MONGO_INSTANCE_SECRET_FILE)
800815
INSTANCE_MONGO_PASSWORD=$(jq -r .password $MONGO_INSTANCE_SECRET_FILE)
801816

802-
# Setting mongo instance secret with info field copied from the cluster level secret,
817+
# Setting mongo instance secret with info field copied from the cluster level secret
803818
# Instance username and password will be created in presync hook unless it is already set in the docdb secret created in federal env, this is due to the
804819
# presync hook not running in a federal env due to the userid requirements.
805820
export DOCDB_FEDERAL_INSTANCE_SECRET_FILE=$TEMP_DIR/docdb-federal-instance-secret.json

image/cli/mascli/functions/gitops_suite_license_service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ function gitops_suite_license_service() {
326326
mkdir -p $TEMP_DIR
327327

328328
# by default yaml. pass aws, in case if configuring with DocDB
329-
export MONGODB_PROVIDER=${MONGODB_PROVIDER:-"yaml"}
329+
export MONGODB_PROVIDER=${MONGODB_PROVIDER:-"aws"}
330330

331331
export MONGO_SECRET_FILE=$TEMP_DIR/mongo-secret.json
332332
export MONGO_CONFIG_FILE=$TEMP_DIR/mongo-info.yaml

tekton/src/pipelines/gitops/gitops-mas-cluster.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ spec:
342342
default: "https://cloud.mongodb.com/"
343343
- name: mongodb_provider
344344
type: string
345-
default: "yaml"
345+
default: "aws"
346346
- name: mongo_reset_master_password
347347
type: string
348348
default: "false"

tekton/src/tasks/gitops/gitops-mongo-atlas.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ spec:
2828
default: "https://cloud.mongodb.com/"
2929
- name: mongodb_provider
3030
type: string
31-
default: "yaml"
31+
default: "aws"
3232

3333
# MongoDB Atlas Resource Configuration
3434
- name: mongo_action

0 commit comments

Comments
 (0)