Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,45 @@ tests:
- ref: quay-install-odf-operator
- ref: optional-operators-subscribe
- ref: quay-install-quay
- ref: quay-create-admin
- as: quay-create-admin
commands: |
set -euo pipefail
echo "Patching Quay config to enable user initialization..." >&2
config_secret="$(oc -n quay get secret --sort-by='{.metadata.creationTimestamp}' -o name | grep ^secret/quay-quay-config-secret- | tail -n1)"
config_yaml="$(oc -n quay get "$config_secret" -o 'go-template={{index .data "config.yaml" | base64decode}}')"
patched_base64="$(printf '%s\nFEATURE_USER_INITIALIZE: true\nSUPER_USERS:\n- admin\n' "$config_yaml" | base64 | tr -d '\n')"
oc -n quay patch "$config_secret" --type=merge -p '{"data":{"config.yaml":"'"$patched_base64"'"}}'

echo "Restarting Quay pods to pick up new config..." >&2
oc delete pods -n quay -l quay-component=quay-app

echo "Waiting for Quay to become ready..." >&2
for i in $(seq 1 60); do
ready="$(oc -n quay get pods -l quay-component=quay-app -o go-template='{{$x := ""}}{{range .items}}{{$status := "False"}}{{range .status.conditions}}{{if eq .type "Ready"}}{{$status = .status}}{{end}}{{end}}{{if or (eq $x "") (eq $status "False")}}{{$x = $status}}{{end}}{{end}}{{or $x "False"}}')"
if [ "$ready" = "True" ]; then break; fi
sleep 10
done
if [ "$ready" != "True" ]; then
echo "Timed out waiting for Quay pods" >&2
exit 1
fi

echo "Creating admin user via initialization API..." >&2
registryEndpoint="$(oc -n quay get quayregistry quay -o jsonpath='{.status.registryEndpoint}')"
response="$(curl -sk -X POST "$registryEndpoint/api/v1/user/initialize" \
--header 'Content-Type: application/json' \
--data '{"username": "admin", "password": "p@ssw0rd", "email": "admin@localhost.local", "access_token": false}')"
if echo "$response" | grep -q '"username"'; then
echo "Admin user created successfully" >&2
else
echo "Failed to create admin user: $response" >&2
exit 1
fi
from: cli
resources:
requests:
cpu: 100m
memory: 200Mi
test:
- as: tests
commands: |
Expand Down