From b2b680bd2d140fb9a6838c8fad4d5d78cdf65591 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 17 Aug 2022 18:14:26 +0200 Subject: [PATCH 1/2] chore: fix s3 redirects with prefixes Signed-off-by: CrazyMax --- _releaser/cloudfront-lambda-redirects.js | 12 ++- _releaser/redirects-prefixes.json | 111 ++++++++++++++++++----- 2 files changed, 99 insertions(+), 24 deletions(-) diff --git a/_releaser/cloudfront-lambda-redirects.js b/_releaser/cloudfront-lambda-redirects.js index face10fe003c..de8c59d34300 100644 --- a/_releaser/cloudfront-lambda-redirects.js +++ b/_releaser/cloudfront-lambda-redirects.js @@ -25,10 +25,16 @@ exports.handler = (event, context, callback) => { } const redirectsPrefixes = JSON.parse(`{{.RedirectsPrefixesJSON}}`); - for (let key in redirectsPrefixes) { - if (!request.uri.startsWith(key)) { + for (let x in redirectsPrefixes) { + const rp = redirectsPrefixes[x]; + if (!request.uri.startsWith(`/${rp['prefix']}`)) { continue; } + let newlocation = "/"; + if (rp['strip']) { + let re = new RegExp(`(^/${rp['prefix']})`, 'gi'); + newlocation = request.uri.replace(re,'/'); + } //console.log(`redirect: ${request.uri} to ${redirectsPrefixes[key]}`); const response = { status: '301', @@ -36,7 +42,7 @@ exports.handler = (event, context, callback) => { headers: { location: [{ key: 'Location', - value: redirectsPrefixes[key], + value: newlocation, }], }, } diff --git a/_releaser/redirects-prefixes.json b/_releaser/redirects-prefixes.json index a032ff2de9ef..978000601a6b 100644 --- a/_releaser/redirects-prefixes.json +++ b/_releaser/redirects-prefixes.json @@ -1,21 +1,90 @@ -{ - "/compliance/": "/", - "/datacenter/": "/", - "/ee/": "/", - "/v1.4/": "/", - "/v1.5/": "/", - "/v1.6/": "/", - "/v1.7/": "/", - "/v1.8/": "/", - "/v1.9/": "/", - "/v1.10/": "/", - "/v1.11/": "/", - "/v1.12/": "/", - "/v1.13/": "/", - "/v17.03/": "/", - "/v17.06/": "/", - "/v17.09/": "/", - "/v17.12/": "/", - "/v18.03/": "/", - "/v18.09/": "/" -} +[ + { + "prefix": "compliance/", + "strip": false + }, + { + "prefix": "datacenter/", + "strip": false + }, + { + "prefix": "ee/", + "strip": false + }, + { + "prefix": "v1.4/", + "strip": true + }, + { + "prefix": "v1.5/", + "strip": true + }, + { + "prefix": "v1.6/", + "strip": true + }, + { + "prefix": "v1.7/", + "strip": true + }, + { + "prefix": "v1.8/", + "strip": true + }, + { + "prefix": "v1.9/", + "strip": true + }, + { + "prefix": "v1.10/", + "strip": true + }, + { + "prefix": "v1.11/", + "strip": true + }, + { + "prefix": "v1.12/", + "strip": true + }, + { + "prefix": "v1.13/", + "strip": true + }, + { + "prefix": "v17.03/", + "strip": true + }, + { + "prefix": "v17.06/enterprise/", + "strip": false + }, + { + "prefix": "v17.06/", + "strip": true + }, + { + "prefix": "v17.09/", + "strip": true + }, + { + "prefix": "v17.12/", + "strip": true + }, + { + "prefix": "v18.03/ee/", + "strip": false + }, + { + "prefix": "v18.03/", + "strip": true + }, + { + "prefix": "v18.09/ee/", + "strip": false + }, + { + "prefix": "v18.09/", + "strip": true + } +] From c27e2e4ee727de9b7ddbcdd6b820b92a35986e63 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 17 Aug 2022 18:14:53 +0200 Subject: [PATCH 2/2] lab: disable slack notification Signed-off-by: CrazyMax --- .github/workflows/deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 917e5ce2cdb7..4c2f65d6df42 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -46,7 +46,6 @@ jobs: DOCS_S3_CONFIG="s3-config.json" DOCS_CLOUDFRONT_ID="E1MYDYF65FW3HG" DOCS_LAMBDA_FUNCTION_REDIRECTS="DockerDocsRedirectFunction-labs" - DOCS_SLACK_MSG="Successfully deployed docs-labs from lab branch. $DOCS_URL" else echo >&2 "ERROR: unknown branch ${{ github.ref }}" exit 1