diff --git a/cmd/demo_scripts/create_qovery_demo.sh b/cmd/demo_scripts/create_qovery_demo.sh index 16335189..7d3219f8 100755 --- a/cmd/demo_scripts/create_qovery_demo.sh +++ b/cmd/demo_scripts/create_qovery_demo.sh @@ -6,6 +6,7 @@ QOVERY_API_URL=${QOVERY_API_URL:='https://api.qovery.com'} CLUSTER_NAME=$1 ARCH=$2 ORGANIZATION_ID=$3 +USER_AGENT=$6 case $3 in qov_*) AUTHORIZATION_HEADER="Authorization: Token $4" @@ -29,10 +30,10 @@ esac POWERSHELL_CMD='powershell.exe' get_or_create_on_premise_account() { - accountId=$(curl -s --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/onPremise/credentials | jq -r .results[0].id) + accountId=$(curl -s --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' -H "User-Agent: ${USER_AGENT}" ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/onPremise/credentials | jq -r .results[0].id) if [ "$accountId" = "null" ] then - accountId=$(curl -s -X POST --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' -d '{"name": "on-premise"}' ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/onPremise/credentials | jq -r .id) + accountId=$(curl -s -X POST --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' -H "User-Agent: ${USER_AGENT}" -d '{"name": "on-premise"}' ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/onPremise/credentials | jq -r .id) fi echo "$accountId" @@ -41,12 +42,12 @@ get_or_create_on_premise_account() { get_or_create_demo_cluster() { accountId=$1 clusterName=$2 - clusterId=$(curl -s -X GET --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/cluster | jq -r '.results[] | select(.name=="'"$clusterName"'") | .id') + clusterId=$(curl -s -X GET --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' -H "User-Agent: ${USER_AGENT}" ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/cluster | jq -r '.results[] | select(.name=="'"$clusterName"'") | .id') if [ "$clusterId" = "" ] then payload='{"name":"'$2'","region":"on-premise","cloud_provider":"ON_PREMISE","kubernetes":"SELF_MANAGED", "production": false, "is_demo": true, "features":[],"cloud_provider_credentials":{"cloud_provider":"ON_PREMISE","credentials":{"id":"'${accountId}'","name":"on-premise"},"region":"unknown"}}' - clusterId=$(curl -s -X POST --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' -d "${payload}" ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/cluster | jq -r .id) + clusterId=$(curl -s -X POST --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/json' -H "User-Agent: ${USER_AGENT}" -d "${payload}" ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/cluster | jq -r .id) fi echo "$clusterId" @@ -54,7 +55,7 @@ get_or_create_demo_cluster() { get_cluster_values() { clusterId=$1 - curl -s -X GET --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/x-yaml' ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/cluster/"${clusterId}"/installationHelmValues + curl -s -X GET --fail-with-body -H "${AUTHORIZATION_HEADER}" -H 'Content-Type: application/x-yaml' -H "User-Agent: ${USER_AGENT}" ${QOVERY_API_URL}/organization/"${ORGANIZATION_ID}"/cluster/"${clusterId}"/installationHelmValues } get_or_create_cluster() { diff --git a/cmd/demo_up.go b/cmd/demo_up.go index fdc60e7c..43163fff 100644 --- a/cmd/demo_up.go +++ b/cmd/demo_up.go @@ -68,12 +68,13 @@ var demoUpCmd = &cobra.Command{ os.Exit(1) } + userAgent := "'CLI " + utils.Version+ "'" cmdStr := ` set -eu set -o pipefail -%s %s %s %s %s %t 2>&1 | tee %s +%s %s %s %s %s %t %s 2>&1 | tee %s ` - cmdArgs := fmt.Sprintf(cmdStr, scriptPath, demoClusterName, detectArchitecture(), string(orgId), string(token), demoDebug, debugLogsPath) + cmdArgs := fmt.Sprintf(cmdStr, scriptPath, demoClusterName, detectArchitecture(), string(orgId), string(token), demoDebug, userAgent, debugLogsPath) shCmd := exec.Command("/bin/bash", "-c", cmdArgs) shCmd.Stdout = os.Stdout shCmd.Stderr = os.Stderr