Skip to content

Commit

Permalink
Merge pull request #32809 from vespa-engine/aressem/move-to-public
Browse files Browse the repository at this point in the history
Switch to api.factory.vespa.ai
  • Loading branch information
aressem authored Nov 12, 2024
2 parents e3e2386 + 8459d75 commit ab294b5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,47 @@ if (( $# < 1 )); then
fi

COMMAND=$1
FACTORY_API="https://api.factory.vespa.ai/factory/v1"
FACTORY_API="https://factory.vespa.aws-us-east-1a.vespa.oath.cloud/api/factory/v1"
COOKIEJAR=$(pwd)/jar.txt
# shellcheck disable=2064
trap "rm -f $COOKIEJAR" EXIT

CURL="curl -sL --key /workspace/identity/key --cert /workspace/identity/cert"
TOKEN=$(curl -sL --key /workspace/identity/key --cert /workspace/identity/cert -X POST -H "Content-Type: application/x-www-form-urlencoded" -d"grant_type=client_credentials&scope=vespa.factory%3Adomain" "https://zts.athenz.vespa-cloud.com:4443/zts/v1/oauth2/token" | jq -re '.access_token')
SESSION_TOKEN=null
WAIT_UNTIL=$(( $(date +%s) + 120 ))
set +e
while [[ $SESSION_TOKEN == null ]]; do
SESSION_TOKEN=$(curl -s -H 'Content-Type: application/json' -H 'Accept: application/json' -d "{ \"username\": \"svc-okta-vespa-factory\", \"password\": \"$SVC_OKTA_VESPA_FACTORY_TOKEN\" }" https://ouryahoo.okta.com/api/v1/authn | jq -re '.sessionToken')

if [[ $SESSION_TOKEN == null ]]; then
if [[ $(date +%s) -ge $WAIT_UNTIL ]]; then
echo "Could not fetch session token from Okta: SESSION_TOKEN=$SESSION_TOKEN"
exit 1
else
echo "Invalid SESSION_TOKEN=$SESSION_TOKEN . Trying again ..." >&2
sleep 3
fi
fi
done
set -e

LOCATION=$(curl -s -i -c "$COOKIEJAR" "https://factory.vespa.aws-us-east-1a.vespa.oath.cloud/login" | grep location | awk '{print $2}' | tr -d '\r')
curl -sL -b "$COOKIEJAR" -c "$COOKIEJAR" "$LOCATION&sessionToken=$SESSION_TOKEN" &> /dev/null

CURL="curl -sL -b $COOKIEJAR"

shift
case $COMMAND in
get-version)
VERSION=$1
if [[ -z $VERSION ]]; then echo "Usage: $0 $COMMAND <version>"; exit 1; fi
$CURL -H "Authorization: Bearer $TOKEN" "$FACTORY_API/versions/$VERSION"
$CURL "$FACTORY_API/versions/$VERSION"
;;
create-build)
FACTORY_PIPELINE_ID=$1
FACTORY_PLATFORM=$2
if [[ -z $FACTORY_PIPELINE_ID ]]; then echo "Usage: $0 $COMMAND <pipeline id> [factory platform]"; exit 1; fi
if [[ -z $FACTORY_PLATFORM ]]; then FACTORY_PLATFORM="opensource_centos7"; fi
$CURL -H "Authorization: Bearer $TOKEN" -d "{
$CURL -d "{
\"startSeconds\": $(date +%s),
\"sdApiUrl\": \"https://api.buildkite.com/\",
\"pipelineId\": $FACTORY_PIPELINE_ID,
Expand All @@ -36,7 +59,7 @@ case $COMMAND in
"$FACTORY_API/builds"
;;
create-release)
$CURL -H "Authorization: Bearer $TOKEN" -d "{
$CURL -d "{
\"startSeconds\": $(date +%s),
\"systemName\": \"opensource\"
}" \
Expand All @@ -51,7 +74,7 @@ case $COMMAND in
echo "Usage: $0 $COMMAND <pipeline id> <status> <description>"
exit 1
fi
$CURL -H "Authorization: Bearer $TOKEN" -d "{
$CURL -d "{
\"updatedSeconds\": $(date +%s),
\"sdApiUrl\": \"https://api.buildkite.com/\",
\"pipelineId\": $FACTORY_PIPELINE_ID,
Expand All @@ -65,7 +88,7 @@ case $COMMAND in
update-released-time)
VERSION=$1
if [[ -z $VERSION ]]; then echo "Usage: $0 $COMMAND <version>"; exit 1; fi
$CURL -H "Authorization: Bearer $TOKEN" -d "{
$CURL -d "{
\"releasedSeconds\": $(date +%s),
\"systemName\": \"opensource\"
}" \
Expand Down
39 changes: 8 additions & 31 deletions .buildkite/factory-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,24 @@ if (( $# < 1 )); then
fi

COMMAND=$1
FACTORY_API="https://factory.vespa.aws-us-east-1a.vespa.oath.cloud/api/factory/v1"
COOKIEJAR=$(pwd)/jar.txt
# shellcheck disable=2064
trap "rm -f $COOKIEJAR" EXIT
FACTORY_API="https://api.factory.vespa.ai/factory/v1"

SESSION_TOKEN=null
WAIT_UNTIL=$(( $(date +%s) + 120 ))
set +e
while [[ $SESSION_TOKEN == null ]]; do
SESSION_TOKEN=$(curl -s -H 'Content-Type: application/json' -H 'Accept: application/json' -d "{ \"username\": \"svc-okta-vespa-factory\", \"password\": \"$SVC_OKTA_VESPA_FACTORY_TOKEN\" }" https://ouryahoo.okta.com/api/v1/authn | jq -re '.sessionToken')

if [[ $SESSION_TOKEN == null ]]; then
if [[ $(date +%s) -ge $WAIT_UNTIL ]]; then
echo "Could not fetch session token from Okta: SESSION_TOKEN=$SESSION_TOKEN"
exit 1
else
echo "Invalid SESSION_TOKEN=$SESSION_TOKEN . Trying again ..." >&2
sleep 3
fi
fi
done
set -e

LOCATION=$(curl -s -i -c "$COOKIEJAR" "https://factory.vespa.aws-us-east-1a.vespa.oath.cloud/login" | grep location | awk '{print $2}' | tr -d '\r')
curl -sL -b "$COOKIEJAR" -c "$COOKIEJAR" "$LOCATION&sessionToken=$SESSION_TOKEN" &> /dev/null

CURL="curl -sL -b $COOKIEJAR"
CURL="curl -sL --key /workspace/identity/key --cert /workspace/identity/cert"
TOKEN=$(curl -sL --key /workspace/identity/key --cert /workspace/identity/cert -X POST -H "Content-Type: application/x-www-form-urlencoded" -d"grant_type=client_credentials&scope=vespa.factory%3Adomain" "https://zts.athenz.vespa-cloud.com:4443/zts/v1/oauth2/token" | jq -re '.access_token')

shift
case $COMMAND in
get-version)
VERSION=$1
if [[ -z $VERSION ]]; then echo "Usage: $0 $COMMAND <version>"; exit 1; fi
$CURL "$FACTORY_API/versions/$VERSION"
$CURL -H "Authorization: Bearer $TOKEN" "$FACTORY_API/versions/$VERSION"
;;
create-build)
FACTORY_PIPELINE_ID=$1
FACTORY_PLATFORM=$2
if [[ -z $FACTORY_PIPELINE_ID ]]; then echo "Usage: $0 $COMMAND <pipeline id> [factory platform]"; exit 1; fi
if [[ -z $FACTORY_PLATFORM ]]; then FACTORY_PLATFORM="opensource_centos7"; fi
$CURL -d "{
$CURL -H "Authorization: Bearer $TOKEN" -d "{
\"startSeconds\": $(date +%s),
\"sdApiUrl\": \"https://api.buildkite.com/\",
\"pipelineId\": $FACTORY_PIPELINE_ID,
Expand All @@ -59,7 +36,7 @@ case $COMMAND in
"$FACTORY_API/builds"
;;
create-release)
$CURL -d "{
$CURL -H "Authorization: Bearer $TOKEN" -d "{
\"startSeconds\": $(date +%s),
\"systemName\": \"opensource\"
}" \
Expand All @@ -74,7 +51,7 @@ case $COMMAND in
echo "Usage: $0 $COMMAND <pipeline id> <status> <description>"
exit 1
fi
$CURL -d "{
$CURL -H "Authorization: Bearer $TOKEN" -d "{
\"updatedSeconds\": $(date +%s),
\"sdApiUrl\": \"https://api.buildkite.com/\",
\"pipelineId\": $FACTORY_PIPELINE_ID,
Expand All @@ -88,7 +65,7 @@ case $COMMAND in
update-released-time)
VERSION=$1
if [[ -z $VERSION ]]; then echo "Usage: $0 $COMMAND <version>"; exit 1; fi
$CURL -d "{
$CURL -H "Authorization: Bearer $TOKEN" -d "{
\"releasedSeconds\": $(date +%s),
\"systemName\": \"opensource\"
}" \
Expand Down

0 comments on commit ab294b5

Please sign in to comment.