Skip to content

Commit 157f1da

Browse files
authored
🦺 Now, it is also mandatory to add a username to the integration with registries 🦺
🦺 Now, it is also mandatory to add a username to the integration with registries 🦺
2 parents 909e32a + 589ed64 commit 157f1da

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

β€Žtooling/charts/tl500-course-content/templates/stackrox/configure-stackrox-job.yamlβ€Ž

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ spec:
1919
- |
2020
test {{ .Values.verbose | default "false" }} == true && set -x
2121
22+
# ── Configuration ───────────────────────────────────────────────
23+
STACKROX_NS="{{ index .Values "stackrox-chart" "stackrox" "namespace" }}"
24+
CLUSTER_DOMAIN="{{ .Values.cluster_domain }}"
25+
REGISTRY_ENDPOINT="image-registry.openshift-image-registry.svc:5000"
26+
2227
# ── Step 1: Wait for StackRox Operator ──────────────────────────
2328
echo "⏳ [1/5] Waiting for StackRox operator CRD..."
2429
while [ true ]; do oc get crd centrals.platform.stackrox.io; if [ $? -eq 0 ]; then break; fi ; sleep 5s; done
2530
echo "βœ… [1/5] StackRox CRD available"
2631
2732
# ── Step 2: Wait for Central pods ───────────────────────────────
2833
echo "⏳ [2/5] Waiting for Central pods..."
29-
while test 0 == $(oc -n {{ index .Values "stackrox-chart" "stackrox" "namespace" }} get pod -l app.kubernetes.io/component=central -o name 2>/dev/null | wc -l); do sleep 5; done
30-
oc -n {{ index .Values "stackrox-chart" "stackrox" "namespace" }} wait pod -l app.kubernetes.io/component=central --for=condition=Ready --timeout=200s
34+
while test 0 == $(oc -n ${STACKROX_NS} get pod -l app.kubernetes.io/component=central -o name 2>/dev/null | wc -l); do sleep 5; done
35+
oc -n ${STACKROX_NS} wait pod -l app.kubernetes.io/component=central --for=condition=Ready --timeout=200s
3136
if [ $? != 0 ]; then
3237
echo "πŸ›‘ [2/5] Timed out waiting for Central pods";
3338
exit 1;
@@ -37,8 +42,8 @@ spec:
3742
3843
# ── Step 3: Get StackRox credentials ────────────────────────────
3944
echo "⏳ [3/5] Retrieving StackRox admin credentials..."
40-
ROX_ENDPOINT=central-stackrox.{{ index .Values "stackrox-chart" "stackrox.namespace" | quote }}
41-
ROX_ADMIN_PASSWD=$(oc -n {{ index .Values "stackrox-chart" "stackrox" "namespace" }} get secret central-htpasswd -o jsonpath='{.data.password}' | base64 --decode)
45+
ROX_ENDPOINT="central-${STACKROX_NS}.${CLUSTER_DOMAIN}"
46+
ROX_ADMIN_PASSWD=$(oc -n ${STACKROX_NS} get secret central-htpasswd -o jsonpath='{.data.password}' | base64 --decode)
4247
echo "βœ… [3/5] Credentials retrieved"
4348
4449
# ── Step 4: Wait for pipeline ServiceAccount ────────────────────
@@ -49,7 +54,26 @@ spec:
4954
# ── Step 5: Configure registry integration ──────────────────────
5055
echo "⏳ [5/5] Creating token and configuring StackRox registry integration..."
5156
TOKEN=$(oc create token pipeline -n tl500 --duration=8760h)
52-
RET=$(curl -sk -u "admin:${ROX_ADMIN_PASSWD}" "https://$ROX_ENDPOINT/v1/imageintegrations" -d "{\"id\": \"\",\"name\": \"tl500\",\"categories\": [\"REGISTRY\"],\"docker\": {\"endpoint\": \"image-registry.openshift-image-registry.svc:5000\",\"username\": \"\",\"password\": \"${TOKEN}\",\"insecure\": true},\"autogenerated\": false,\"clusterId\": \"\",\"clusters\": [],\"skipTestIntegration\": false,\"type\": \"docker\" }" | jq .error)
57+
PAYLOAD=$(cat <<EOF
58+
{
59+
"id": "",
60+
"name": "tl500 - OCP internal registry",
61+
"categories": ["REGISTRY"],
62+
"docker": {
63+
"endpoint": "${REGISTRY_ENDPOINT}",
64+
"username": "pipeline",
65+
"password": "${TOKEN}",
66+
"insecure": true
67+
},
68+
"autogenerated": false,
69+
"clusterId": "",
70+
"clusters": [],
71+
"skipTestIntegration": false,
72+
"type": "docker"
73+
}
74+
EOF
75+
)
76+
RET=$(curl -sk -u "admin:${ROX_ADMIN_PASSWD}" "https://${ROX_ENDPOINT}/v1/imageintegrations" -d "$PAYLOAD" | jq .error)
5377
if [[ ${RET} != "null" && ! -z ${RET} ]]; then
5478
echo "πŸ›‘ [5/5] Failed to set image integration: ${RET}";
5579
exit 1;

0 commit comments

Comments
Β (0)