@docupace/pipeline 1.0.48 → 1.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.cjs +12 -12
- package/README.md +135 -135
- package/bin/azuread_update_callbacks_for_app.sh +58 -58
- package/bin/next-changeset-validate.sh +8 -8
- package/next/changeset.sh +75 -75
- package/next/copy.sh +34 -34
- package/next/deploy.sh +40 -40
- package/next/execute.sh +123 -123
- package/next/sonar.sh +23 -23
- package/package.json +1 -1
- package/src/auth0/alias.js +72 -72
- package/src/auth0/configure.js +783 -783
- package/src/auth0/export.js +43 -43
- package/src/auth0/metadata.js +132 -132
- package/src/auth0/vault.js +107 -107
- package/src/changeset/changeset-config.js +34 -34
- package/src/changeset/cli.js +188 -188
- package/src/changeset/create.js +205 -205
- package/src/changeset/package-util.js +86 -86
- package/src/changeset/util.js +43 -43
- package/src/changeset/validate.js +84 -84
- package/src/changeset/version.js +95 -95
- package/src/jenkins/setParams.groovy +58 -58
- package/src/next/alias.js +53 -53
- package/src/next/apache.js +73 -73
- package/src/next/cli.js +220 -220
- package/src/next/config.js +100 -136
- package/src/next/connect.js +227 -227
- package/src/next/copy.js +61 -61
- package/src/next/deploy.js +553 -553
- package/src/next/haproxy.js +71 -71
- package/src/next/jira.js +80 -80
- package/src/next/logger.js +17 -17
- package/src/next/pipline.js +114 -114
- package/src/next/publish.js +71 -71
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/src/next/util.js +93 -93
- package/src/next/vault.js +45 -45
- package/terraform/apply.sh +37 -37
- package/terraform/init.sh +72 -72
- package/terraform/plan.sh +76 -76
- package/terraform/validate.sh +17 -17
package/next/deploy.sh
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -e # Enable command tracing
|
|
4
|
-
# Variables
|
|
5
|
-
REPO_NAME="gitops-dev"
|
|
6
|
-
REPO_URL="https://x-token-auth:$GITOPS_REP_TOKEN@bitbucket.org/dp-cloud/${REPO_NAME}.git"
|
|
7
|
-
FILE_PATH="dp/$2/$1.values.yaml"
|
|
8
|
-
BUILD_NUMBER=$BITBUCKET_BUILD_NUMBER
|
|
9
|
-
GITOPS_BRANCH=master
|
|
10
|
-
if [ -n "$VERSION_TAG" ]; then
|
|
11
|
-
DEPLOY_TAG=$VERSION_TAG
|
|
12
|
-
else
|
|
13
|
-
DEPLOY_TAG="build-$BUILD_NUMBER"
|
|
14
|
-
fi
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# Clone the repository
|
|
19
|
-
|
|
20
|
-
git config user.email qxebpukjnzljnwty1knte7ym53aogk@bots.bitbucket.org
|
|
21
|
-
git clone $REPO_URL
|
|
22
|
-
cd ${REPO_NAME} || exit
|
|
23
|
-
|
|
24
|
-
# Checkout the branch
|
|
25
|
-
|
|
26
|
-
# Modify the YAML file
|
|
27
|
-
sed -i "s/tag: .*/tag: $DEPLOY_TAG/" $FILE_PATH
|
|
28
|
-
|
|
29
|
-
# Add changes to git
|
|
30
|
-
git add $FILE_PATH
|
|
31
|
-
|
|
32
|
-
# Commit changes
|
|
33
|
-
git commit -m "Update image tag to $DEPLOY_TAG"
|
|
34
|
-
|
|
35
|
-
# Push changes
|
|
36
|
-
git push origin $GITOPS_BRANCH
|
|
37
|
-
|
|
38
|
-
# Clean up
|
|
39
|
-
cd ..
|
|
40
|
-
rm -rf ${REPO_NAME}
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e # Enable command tracing
|
|
4
|
+
# Variables
|
|
5
|
+
REPO_NAME="gitops-dev"
|
|
6
|
+
REPO_URL="https://x-token-auth:$GITOPS_REP_TOKEN@bitbucket.org/dp-cloud/${REPO_NAME}.git"
|
|
7
|
+
FILE_PATH="dp/$2/$1.values.yaml"
|
|
8
|
+
BUILD_NUMBER=$BITBUCKET_BUILD_NUMBER
|
|
9
|
+
GITOPS_BRANCH=master
|
|
10
|
+
if [ -n "$VERSION_TAG" ]; then
|
|
11
|
+
DEPLOY_TAG=$VERSION_TAG
|
|
12
|
+
else
|
|
13
|
+
DEPLOY_TAG="build-$BUILD_NUMBER"
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Clone the repository
|
|
19
|
+
|
|
20
|
+
git config user.email qxebpukjnzljnwty1knte7ym53aogk@bots.bitbucket.org
|
|
21
|
+
git clone $REPO_URL
|
|
22
|
+
cd ${REPO_NAME} || exit
|
|
23
|
+
|
|
24
|
+
# Checkout the branch
|
|
25
|
+
|
|
26
|
+
# Modify the YAML file
|
|
27
|
+
sed -i "s/tag: .*/tag: $DEPLOY_TAG/" $FILE_PATH
|
|
28
|
+
|
|
29
|
+
# Add changes to git
|
|
30
|
+
git add $FILE_PATH
|
|
31
|
+
|
|
32
|
+
# Commit changes
|
|
33
|
+
git commit -m "Update image tag to $DEPLOY_TAG"
|
|
34
|
+
|
|
35
|
+
# Push changes
|
|
36
|
+
git push origin $GITOPS_BRANCH
|
|
37
|
+
|
|
38
|
+
# Clean up
|
|
39
|
+
cd ..
|
|
40
|
+
rm -rf ${REPO_NAME}
|
package/next/execute.sh
CHANGED
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Usage: ./pipeline.sh <function> <BITBUCKET_REPO_SLUG>
|
|
4
|
-
# Example: ./pipeline.sh build docupace-ui-main
|
|
5
|
-
|
|
6
|
-
set -e # Enable command tracing
|
|
7
|
-
GIT_SHA=$(git log --pretty=format:'%h' -n 1)
|
|
8
|
-
JF_REGISTRY_FULL_URL="${JF_REGISTRY_URL}/${JF_REGISTRY_REPO_NAME}"
|
|
9
|
-
PARAM1=$2
|
|
10
|
-
PARAM2=$3
|
|
11
|
-
|
|
12
|
-
pull() {
|
|
13
|
-
IMAGE_NAME=$2
|
|
14
|
-
docker pull "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
# Function to run Sonar analysis
|
|
18
|
-
sonar() {
|
|
19
|
-
export DOCKER_HOST=""
|
|
20
|
-
IMAGE_NAME="${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}"
|
|
21
|
-
SONAR_CONTAINER_NAME="${BITBUCKET_REPO_SLUG}-${GIT_SHA}"
|
|
22
|
-
|
|
23
|
-
echo "Running Sonar analysis on Docker image ${IMAGE_NAME}..."
|
|
24
|
-
|
|
25
|
-
# Remove any existing container with the same name
|
|
26
|
-
if [ "$(docker ps -a --filter "name=$SONAR_CONTAINER_NAME" --format "{{.Names}}")" ]; then
|
|
27
|
-
docker rm -f $SONAR_CONTAINER_NAME
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
cd "$ROOT_DIR"
|
|
31
|
-
docker run --rm \
|
|
32
|
-
-e BRANCH=$BITBUCKET_BRANCH \
|
|
33
|
-
-e PR_ID=$BITBUCKET_PR_ID \
|
|
34
|
-
-e PR_DESTINATION_BRANCH=$BITBUCKET_PR_DESTINATION_BRANCH \
|
|
35
|
-
-e SONAR_TOKEN=$SONAR_TOKEN \
|
|
36
|
-
--name $SONAR_CONTAINER_NAME $IMAGE_NAME pnpm sonar
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
# Function to publish the Docker image
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
loginRegistry() {
|
|
43
|
-
echo ${JF_REGISTRY_PASSWORD_DEV} | docker login --username ${JF_REGISTRY_USER_DEV} --password-stdin ${JF_REGISTRY_URL}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
logoutRegistry() {
|
|
47
|
-
docker logout ${JF_REGISTRY_URL}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
copy() {
|
|
51
|
-
DIR="$(dirname "$0")"
|
|
52
|
-
bash $DIR/copy.sh
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
publish() {
|
|
56
|
-
SLUG_SUFFIX=""
|
|
57
|
-
if [ -n "$APP_NAME" ]; then
|
|
58
|
-
SLUG_SUFFIX="-${APP_NAME}"
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
|
-
BUILD_IMAGE_NAME="${BITBUCKET_REPO_SLUG}${SLUG_SUFFIX}:build-${BITBUCKET_BUILD_NUMBER}"
|
|
62
|
-
IMAGE_NAME="${BITBUCKET_REPO_SLUG}${SLUG_SUFFIX}:sha-${GIT_SHA}"
|
|
63
|
-
|
|
64
|
-
export DOCKER_HOST=""
|
|
65
|
-
|
|
66
|
-
echo "Publishing Docker image ${IMAGE_NAME}..."
|
|
67
|
-
|
|
68
|
-
loginRegistry
|
|
69
|
-
|
|
70
|
-
# Check if the image already exists in the registry
|
|
71
|
-
if docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME} >/dev/null 2>&1; then
|
|
72
|
-
echo "Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push."
|
|
73
|
-
else
|
|
74
|
-
docker tag ${IMAGE_NAME} "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
75
|
-
docker push "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
# Tag and push the build image
|
|
79
|
-
docker tag ${IMAGE_NAME} "${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}"
|
|
80
|
-
docker push "${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}"
|
|
81
|
-
|
|
82
|
-
# Tag and push each Git tag as a Docker tag
|
|
83
|
-
GIT_TAGS=$(git tag --points-at HEAD)
|
|
84
|
-
for GIT_TAG in ${GIT_TAGS}; do
|
|
85
|
-
docker tag ${IMAGE_NAME} "${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${GIT_TAG}"
|
|
86
|
-
docker push "${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${GIT_TAG}"
|
|
87
|
-
done
|
|
88
|
-
|
|
89
|
-
# Logout from Docker registry
|
|
90
|
-
loginRegistry
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
# Function to deploy
|
|
94
|
-
# application - ui|graphql
|
|
95
|
-
# site
|
|
96
|
-
deploy() {
|
|
97
|
-
echo "Deploying $PARAM1 application for site $PARAM2..."
|
|
98
|
-
DIR="$(dirname "$0")"
|
|
99
|
-
bash $DIR/deploy.sh $PARAM1 $PARAM2
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
# Main logic to call the appropriate function
|
|
103
|
-
case "$1" in
|
|
104
|
-
build)
|
|
105
|
-
build
|
|
106
|
-
;;
|
|
107
|
-
sonar)
|
|
108
|
-
sonar
|
|
109
|
-
;;
|
|
110
|
-
publish)
|
|
111
|
-
publish
|
|
112
|
-
;;
|
|
113
|
-
deploy)
|
|
114
|
-
deploy
|
|
115
|
-
;;
|
|
116
|
-
copy)
|
|
117
|
-
copy
|
|
118
|
-
;;
|
|
119
|
-
*)
|
|
120
|
-
echo "Usage: $0 {build|sonar|publish|deploy|copy} <BITBUCKET_REPO_SLUG>"
|
|
121
|
-
exit 1
|
|
122
|
-
;;
|
|
123
|
-
esac
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Usage: ./pipeline.sh <function> <BITBUCKET_REPO_SLUG>
|
|
4
|
+
# Example: ./pipeline.sh build docupace-ui-main
|
|
5
|
+
|
|
6
|
+
set -e # Enable command tracing
|
|
7
|
+
GIT_SHA=$(git log --pretty=format:'%h' -n 1)
|
|
8
|
+
JF_REGISTRY_FULL_URL="${JF_REGISTRY_URL}/${JF_REGISTRY_REPO_NAME}"
|
|
9
|
+
PARAM1=$2
|
|
10
|
+
PARAM2=$3
|
|
11
|
+
|
|
12
|
+
pull() {
|
|
13
|
+
IMAGE_NAME=$2
|
|
14
|
+
docker pull "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# Function to run Sonar analysis
|
|
18
|
+
sonar() {
|
|
19
|
+
export DOCKER_HOST=""
|
|
20
|
+
IMAGE_NAME="${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}"
|
|
21
|
+
SONAR_CONTAINER_NAME="${BITBUCKET_REPO_SLUG}-${GIT_SHA}"
|
|
22
|
+
|
|
23
|
+
echo "Running Sonar analysis on Docker image ${IMAGE_NAME}..."
|
|
24
|
+
|
|
25
|
+
# Remove any existing container with the same name
|
|
26
|
+
if [ "$(docker ps -a --filter "name=$SONAR_CONTAINER_NAME" --format "{{.Names}}")" ]; then
|
|
27
|
+
docker rm -f $SONAR_CONTAINER_NAME
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
cd "$ROOT_DIR"
|
|
31
|
+
docker run --rm \
|
|
32
|
+
-e BRANCH=$BITBUCKET_BRANCH \
|
|
33
|
+
-e PR_ID=$BITBUCKET_PR_ID \
|
|
34
|
+
-e PR_DESTINATION_BRANCH=$BITBUCKET_PR_DESTINATION_BRANCH \
|
|
35
|
+
-e SONAR_TOKEN=$SONAR_TOKEN \
|
|
36
|
+
--name $SONAR_CONTAINER_NAME $IMAGE_NAME pnpm sonar
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# Function to publish the Docker image
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
loginRegistry() {
|
|
43
|
+
echo ${JF_REGISTRY_PASSWORD_DEV} | docker login --username ${JF_REGISTRY_USER_DEV} --password-stdin ${JF_REGISTRY_URL}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
logoutRegistry() {
|
|
47
|
+
docker logout ${JF_REGISTRY_URL}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
copy() {
|
|
51
|
+
DIR="$(dirname "$0")"
|
|
52
|
+
bash $DIR/copy.sh
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
publish() {
|
|
56
|
+
SLUG_SUFFIX=""
|
|
57
|
+
if [ -n "$APP_NAME" ]; then
|
|
58
|
+
SLUG_SUFFIX="-${APP_NAME}"
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
BUILD_IMAGE_NAME="${BITBUCKET_REPO_SLUG}${SLUG_SUFFIX}:build-${BITBUCKET_BUILD_NUMBER}"
|
|
62
|
+
IMAGE_NAME="${BITBUCKET_REPO_SLUG}${SLUG_SUFFIX}:sha-${GIT_SHA}"
|
|
63
|
+
|
|
64
|
+
export DOCKER_HOST=""
|
|
65
|
+
|
|
66
|
+
echo "Publishing Docker image ${IMAGE_NAME}..."
|
|
67
|
+
|
|
68
|
+
loginRegistry
|
|
69
|
+
|
|
70
|
+
# Check if the image already exists in the registry
|
|
71
|
+
if docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME} >/dev/null 2>&1; then
|
|
72
|
+
echo "Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push."
|
|
73
|
+
else
|
|
74
|
+
docker tag ${IMAGE_NAME} "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
75
|
+
docker push "${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Tag and push the build image
|
|
79
|
+
docker tag ${IMAGE_NAME} "${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}"
|
|
80
|
+
docker push "${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}"
|
|
81
|
+
|
|
82
|
+
# Tag and push each Git tag as a Docker tag
|
|
83
|
+
GIT_TAGS=$(git tag --points-at HEAD)
|
|
84
|
+
for GIT_TAG in ${GIT_TAGS}; do
|
|
85
|
+
docker tag ${IMAGE_NAME} "${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${GIT_TAG}"
|
|
86
|
+
docker push "${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${GIT_TAG}"
|
|
87
|
+
done
|
|
88
|
+
|
|
89
|
+
# Logout from Docker registry
|
|
90
|
+
loginRegistry
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# Function to deploy
|
|
94
|
+
# application - ui|graphql
|
|
95
|
+
# site
|
|
96
|
+
deploy() {
|
|
97
|
+
echo "Deploying $PARAM1 application for site $PARAM2..."
|
|
98
|
+
DIR="$(dirname "$0")"
|
|
99
|
+
bash $DIR/deploy.sh $PARAM1 $PARAM2
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# Main logic to call the appropriate function
|
|
103
|
+
case "$1" in
|
|
104
|
+
build)
|
|
105
|
+
build
|
|
106
|
+
;;
|
|
107
|
+
sonar)
|
|
108
|
+
sonar
|
|
109
|
+
;;
|
|
110
|
+
publish)
|
|
111
|
+
publish
|
|
112
|
+
;;
|
|
113
|
+
deploy)
|
|
114
|
+
deploy
|
|
115
|
+
;;
|
|
116
|
+
copy)
|
|
117
|
+
copy
|
|
118
|
+
;;
|
|
119
|
+
*)
|
|
120
|
+
echo "Usage: $0 {build|sonar|publish|deploy|copy} <BITBUCKET_REPO_SLUG>"
|
|
121
|
+
exit 1
|
|
122
|
+
;;
|
|
123
|
+
esac
|
package/next/sonar.sh
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Initialize sonar-scanner command with common parameters
|
|
4
|
-
SONAR_CMD="npx sonarqube-scanner"
|
|
5
|
-
|
|
6
|
-
echo "PR_ID=$PR_ID"
|
|
7
|
-
echo "BRANCH=$BRANCH"
|
|
8
|
-
echo "PR_DESTINATION_BRANCH=$PR_DESTINATION_BRANCH"
|
|
9
|
-
|
|
10
|
-
# Determine the type of scan based on environment variables
|
|
11
|
-
if [[ ! -z "$PR_ID" ]]; then
|
|
12
|
-
SONAR_CMD+=" \
|
|
13
|
-
-Dsonar.pullrequest.key=$PR_ID \
|
|
14
|
-
-Dsonar.pullrequest.branch=$BRANCH \
|
|
15
|
-
-Dsonar.pullrequest.base=$PR_DESTINATION_BRANCH"
|
|
16
|
-
else
|
|
17
|
-
SONAR_CMD+=" \
|
|
18
|
-
-Dsonar.branch.name=$BRANCH"
|
|
19
|
-
fi
|
|
20
|
-
|
|
21
|
-
# Execute the sonar-scanner command
|
|
22
|
-
echo "Running: $SONAR_CMD"
|
|
23
|
-
$SONAR_CMD
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Initialize sonar-scanner command with common parameters
|
|
4
|
+
SONAR_CMD="npx sonarqube-scanner"
|
|
5
|
+
|
|
6
|
+
echo "PR_ID=$PR_ID"
|
|
7
|
+
echo "BRANCH=$BRANCH"
|
|
8
|
+
echo "PR_DESTINATION_BRANCH=$PR_DESTINATION_BRANCH"
|
|
9
|
+
|
|
10
|
+
# Determine the type of scan based on environment variables
|
|
11
|
+
if [[ ! -z "$PR_ID" ]]; then
|
|
12
|
+
SONAR_CMD+=" \
|
|
13
|
+
-Dsonar.pullrequest.key=$PR_ID \
|
|
14
|
+
-Dsonar.pullrequest.branch=$BRANCH \
|
|
15
|
+
-Dsonar.pullrequest.base=$PR_DESTINATION_BRANCH"
|
|
16
|
+
else
|
|
17
|
+
SONAR_CMD+=" \
|
|
18
|
+
-Dsonar.branch.name=$BRANCH"
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
# Execute the sonar-scanner command
|
|
22
|
+
echo "Running: $SONAR_CMD"
|
|
23
|
+
$SONAR_CMD
|
package/package.json
CHANGED
package/src/auth0/alias.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
|
|
3
|
-
import { createAlias } from '../next/alias.js';
|
|
4
|
-
|
|
5
|
-
import { getAuth0AuthToken } from './configure.js';
|
|
6
|
-
|
|
7
|
-
import { getVaultSecrets } from './vault.js';
|
|
8
|
-
|
|
9
|
-
import { getVaultSecretsConfigs } from '../next/config.js';
|
|
10
|
-
|
|
11
|
-
import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
|
|
12
|
-
|
|
13
|
-
export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
|
|
14
|
-
console.log(`Forming alias name for application ${application}...`);
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
const auth0Response = await axios.get(
|
|
18
|
-
`https://${auth0Domain}/api/v2/clients`,
|
|
19
|
-
{
|
|
20
|
-
headers: { authorization: `Bearer ${auth0AuthToken}` },
|
|
21
|
-
},
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const appAuth0ClientIdData = auth0Response.data.find(
|
|
25
|
-
(client) => client.name === `${application}`,
|
|
26
|
-
);
|
|
27
|
-
const appAuth0ClientId = appAuth0ClientIdData.client_id;
|
|
28
|
-
|
|
29
|
-
console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
|
|
30
|
-
return `${appAuth0ClientId}@clients`;
|
|
31
|
-
} catch (err) {
|
|
32
|
-
console.error(
|
|
33
|
-
`Failed to form alias name for application: ${application}: ${err.message}`,
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function configureAlias(site, env, username, password, realm) {
|
|
39
|
-
console.log(`Creating alias for site: ${site} in env: ${env}`);
|
|
40
|
-
// Site Common Secrets
|
|
41
|
-
const siteCommonSecretsPath =
|
|
42
|
-
getVaultSecretsConfigs(site).siteCommonSecretsPath;
|
|
43
|
-
console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
|
|
44
|
-
const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
|
|
45
|
-
|
|
46
|
-
const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
|
|
47
|
-
const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
|
|
48
|
-
const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
|
|
49
|
-
const auth0Token = await getAuth0AuthToken(
|
|
50
|
-
auth0Domain,
|
|
51
|
-
auth0ClientId,
|
|
52
|
-
auth0ClientSecret,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
await cloneEnvRepository(env);
|
|
56
|
-
|
|
57
|
-
const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
|
|
58
|
-
'graphql-server',
|
|
59
|
-
env,
|
|
60
|
-
site,
|
|
61
|
-
'values',
|
|
62
|
-
);
|
|
63
|
-
const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
|
|
64
|
-
|
|
65
|
-
const clientCredentialsAlias = await getCCAlias({
|
|
66
|
-
application: 'docupace-graphql-client-credentials',
|
|
67
|
-
auth0Domain: auth0Domain,
|
|
68
|
-
auth0AuthToken: auth0Token,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
|
|
72
|
-
}
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
import { createAlias } from '../next/alias.js';
|
|
4
|
+
|
|
5
|
+
import { getAuth0AuthToken } from './configure.js';
|
|
6
|
+
|
|
7
|
+
import { getVaultSecrets } from './vault.js';
|
|
8
|
+
|
|
9
|
+
import { getVaultSecretsConfigs } from '../next/config.js';
|
|
10
|
+
|
|
11
|
+
import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
|
|
12
|
+
|
|
13
|
+
export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
|
|
14
|
+
console.log(`Forming alias name for application ${application}...`);
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const auth0Response = await axios.get(
|
|
18
|
+
`https://${auth0Domain}/api/v2/clients`,
|
|
19
|
+
{
|
|
20
|
+
headers: { authorization: `Bearer ${auth0AuthToken}` },
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const appAuth0ClientIdData = auth0Response.data.find(
|
|
25
|
+
(client) => client.name === `${application}`,
|
|
26
|
+
);
|
|
27
|
+
const appAuth0ClientId = appAuth0ClientIdData.client_id;
|
|
28
|
+
|
|
29
|
+
console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
|
|
30
|
+
return `${appAuth0ClientId}@clients`;
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error(
|
|
33
|
+
`Failed to form alias name for application: ${application}: ${err.message}`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function configureAlias(site, env, username, password, realm) {
|
|
39
|
+
console.log(`Creating alias for site: ${site} in env: ${env}`);
|
|
40
|
+
// Site Common Secrets
|
|
41
|
+
const siteCommonSecretsPath =
|
|
42
|
+
getVaultSecretsConfigs(site).siteCommonSecretsPath;
|
|
43
|
+
console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
|
|
44
|
+
const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
|
|
45
|
+
|
|
46
|
+
const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
|
|
47
|
+
const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
|
|
48
|
+
const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
|
|
49
|
+
const auth0Token = await getAuth0AuthToken(
|
|
50
|
+
auth0Domain,
|
|
51
|
+
auth0ClientId,
|
|
52
|
+
auth0ClientSecret,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
await cloneEnvRepository(env);
|
|
56
|
+
|
|
57
|
+
const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
|
|
58
|
+
'graphql-server',
|
|
59
|
+
env,
|
|
60
|
+
site,
|
|
61
|
+
'values',
|
|
62
|
+
);
|
|
63
|
+
const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
|
|
64
|
+
|
|
65
|
+
const clientCredentialsAlias = await getCCAlias({
|
|
66
|
+
application: 'docupace-graphql-client-credentials',
|
|
67
|
+
auth0Domain: auth0Domain,
|
|
68
|
+
auth0AuthToken: auth0Token,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
|
|
72
|
+
}
|