Skip to content

Commit 2bcc988

Browse files
author
Shailza Thakur
committed
Remove container registry secret creation
1 parent f504dcf commit 2bcc988

File tree

1 file changed

+10
-51
lines changed

1 file changed

+10
-51
lines changed

code-engine-cos2cos/config.sh

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ if [ $? -eq 0 ]; then
103103
fi
104104

105105
echo "-----"
106-
echo "Step 6: Creating Secrets (Base Secret, Auth Secret, Registry Secret)"
106+
echo "Step 6: Creating Secrets (Base Secret, Auth Secret)"
107107
echo "---"
108108
echo "Step 6.1: Creating Base Secret: $BASE_SECRET"
109109
ibmcloud ce secret create --name ${BASE_SECRET} \
@@ -147,45 +147,9 @@ else
147147
echo -e "${GREEN}SUCCESS${NC}: Step 6.1: Base secret creation complete."
148148
fi
149149

150-
# Creating a container registry secret
151-
echo "---"
152-
echo "Step 6.2: Creating Container Registry Secret: $CONTAINER_REGISTRY_SECRET"
153-
echo "Step 6.2.1: Checking if API key '${API_KEY_NAME}' exists"
154-
API_KEY=$(ibmcloud iam api-keys --output json | jq -r ".[] | select(.name == \"$API_KEY_NAME\") | .apikey")
155-
156-
if [ -z "$API_KEY" ]; then
157-
echo "API key '${API_KEY_NAME}' does not exist. Creating a new one..."
158-
API_KEY=$(ibmcloud iam api-key-create ${API_KEY_NAME} -d "API Key for IBM CR COS-to-COS" -o JSON | jq -r '.apikey' )
159-
# ibmcloud iam api-key-create ${API_KEY_NAME} -d "API Key for IBM CR COS-to-COS" --file key_file
160-
echo "API key '${API_KEY_NAME}' created."
161-
else
162-
echo "API key '${API_KEY_NAME}' already exists. Skipping creation."
163-
fi
164-
165-
ibmcloud ce secret create --name ${CONTAINER_REGISTRY_SECRET} --format registry --password ${API_KEY} --server ${REGISTRY_SERVER}
166-
if [ $? -ne 0 ]; then
167-
echo "Secret '${CONTAINER_REGISTRY_SECRET}' already exists."
168-
read -p "Do you want to override the existing container registry secret? (y/n): " confirm
169-
if [[ "$confirm" =~ ^[Yy]$ ]]; then
170-
echo "Updating secret ${CONTAINER_REGISTRY_SECRET}..."
171-
ibmcloud ce secret update --name ${CONTAINER_REGISTRY_SECRET} --password ${API_KEY} --server ${REGISTRY_SERVER}
172-
173-
if [ $? -eq 0 ]; then
174-
echo -e "${GREEN}SUCCESS${NC}: Step 6.2: Container Registry secret update complete."
175-
else
176-
echo -e "${RED}ERROR${NC}: Failed to update container registry secret."
177-
exit 1
178-
fi
179-
else
180-
echo "Container registry secret update cancelled by user. Exiting..."
181-
exit 0
182-
fi
183-
else
184-
echo -e "${GREEN}SUCCESS${NC}: Step 6.2: Container Registry secret creation complete."
185-
fi
186150
# Auth secrets
187151
echo "---"
188-
echo "Step 6.3: Creating Auth Secret: $AUTH_SECRET"
152+
echo "Step 6.2: Creating Auth Secret: $AUTH_SECRET"
189153
ibmcloud ce secret create --name ${AUTH_SECRET} \
190154
--from-literal IBM_COS_CRTokenFilePath_PRIMARY=${IBM_COS_CRTokenFilePath_PRIMARY} \
191155
--from-literal IBM_COS_CRTokenFilePath_SECONDARY=${IBM_COS_CRTokenFilePath_SECONDARY} \
@@ -213,27 +177,30 @@ if [ $? -ne 0 ]; then
213177
exit 0
214178
fi
215179
else
216-
echo -e "${GREEN}SUCCESS${NC}: Step 6.3: Auth secret creation complete."
180+
echo -e "${GREEN}SUCCESS${NC}: Step 6.2: Auth secret creation complete."
217181
fi
218182
# Create a job
219183
# Create the job with environment variables, including the bucket's region
220184
echo "-----"
221185
echo "Step 7: Creating JOB with name $JOB_NAME"
222-
ibmcloud ce job create --name ${JOB_NAME} --image "${JOB_IMAGE}" \
223-
--registry-secret ${CONTAINER_REGISTRY_SECRET} \
186+
ibmcloud ce job create --name ${JOB_NAME} \
187+
--src "." \
224188
--env-from-secret ${BASE_SECRET} \
225189
--env-from-secret ${AUTH_SECRET} \
226-
--argument true 2>/dev/null
190+
--argument true 2>/dev/null \
191+
--wait
192+
# --registry-secret ${CONTAINER_REGISTRY_SECRET} \
193+
227194
if [ $? -ne 0 ]; then
228195
# echo "Job '${JOB_NAME}' already exists. Exiting"
229196
# exit 1
230197

231198
echo "Job '${JOB_NAME}' already exists. Updating Job."
232199
ibmcloud ce job update --name ${JOB_NAME} --image "${JOB_IMAGE}" \
233-
--registry-secret ${CONTAINER_REGISTRY_SECRET} \
234200
--env-from-secret ${BASE_SECRET} \
235201
--env-from-secret ${AUTH_SECRET} \
236202
--argument true 2>/dev/null
203+
# --registry-secret ${CONTAINER_REGISTRY_SECRET} \
237204
fi
238205
if [ $? -eq 0 ]; then
239206
echo -e "${GREEN}SUCCESS${NC}Step 7: Job Created"
@@ -277,11 +244,3 @@ curl \
277244
}" 2>/dev/null
278245
# echo "******* DONE: Compute Resource Token *******"
279246

280-
# echo "-----"
281-
# echo "Step 9"
282-
# # Submit the job
283-
# echo "LIVE !"
284-
# echo " ********** Submitting the job and Logs *********"
285-
# RANDOM_CODE=$(printf "%06d" $((RANDOM % 1000000)))
286-
# ibmcloud ce jobrun submit --job ${JOB_NAME} --name ${JOB_NAME}-${RANDOM_CODE}
287-
# ibmcloud ce jobrun logs --name ${JOB_NAME}-${RANDOM_CODE} --follow

0 commit comments

Comments
 (0)