2020-08-27 05:19:33 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
const latestVersions = {
|
2.0 GA and separate Cloud from OSS (#1805)
* WIP separate cloud docs, duplicate content shortcode
* WIP cloud-separation
* WIP separate cloud
* duplicated oss into cloud and am making updates
* moved cloud updates to cloud
* reimplemented duplicate-oss shortcode
* separate Cloud and OSS content in Tools & integ...
* Split OSS and Cloud content for Security & auth
* Split OSS and Cloud content for Manage org
* Split OSS and Cloud - Manage Orgs add'l updates
* various updates, primarily in oss and cloud reference
* split content for notification endpoints
* Move InfluxQL doc to Cloud
- Remove the "Query with InfluxQL" page from OSS docs
- Re-incorporate changes made in https://github.com/influxdata/docs-v2/pull/1506
* removed product tags from nav and articles
* WIP separate cloud docs, duplicate content shortcode
* WIP cloud-separation
* WIP separate cloud
* duplicated oss into cloud and am making updates
* moved cloud updates to cloud
* reimplemented duplicate-oss shortcode
* separate Cloud and OSS content in Tools & integ...
* Split OSS and Cloud content for Security & auth
* Split OSS and Cloud content for Manage org
* Split OSS and Cloud - Manage Orgs add'l updates
* various updates, primarily in oss and cloud reference
* split content for notification endpoints
* Move InfluxQL doc to Cloud
- Remove the "Query with InfluxQL" page from OSS docs
- Re-incorporate changes made in https://github.com/influxdata/docs-v2/pull/1506
* removed product tags from nav and articles
* New URL switcher (#1720)
* restructured url modal
* rearchitected the url switcher functionality
* add influxdb preference management to url switcher
* create separate pages for querying data
* update weight
* Update flux-repl.md
* Update influx-query.md
* edits f Scott
* move content from explore-metrics to data-explorer
* edits; delete explore-metrics
* edits
* delete file
* remove duplicate content
* add InfluxQLquery examples
* Remove references to "security script"
* draft updates for Band Plot vis
* WIP separate cloud docs, duplicate content shortcode
* WIP cloud-separation
* WIP separate cloud
* duplicated oss into cloud and am making updates
* moved cloud updates to cloud
* reimplemented duplicate-oss shortcode
* separate Cloud and OSS content in Tools & integ...
* Split OSS and Cloud content for Security & auth
* Split OSS and Cloud content for Manage org
* Split OSS and Cloud - Manage Orgs add'l updates
* various updates, primarily in oss and cloud reference
* split content for notification endpoints
* Move InfluxQL doc to Cloud
- Remove the "Query with InfluxQL" page from OSS docs
- Re-incorporate changes made in https://github.com/influxdata/docs-v2/pull/1506
* removed product tags from nav and articles
* WIP separate cloud docs, duplicate content shortcode
* WIP cloud-separation
* WIP separate cloud
* duplicated oss into cloud and am making updates
* moved cloud updates to cloud
* reimplemented duplicate-oss shortcode
* separate Cloud and OSS content in Tools & integ...
* Split OSS and Cloud content for Manage org
* Split OSS and Cloud - Manage Orgs add'l updates
* various updates, primarily in oss and cloud reference
* split content for notification endpoints
* Move InfluxQL doc to Cloud
- Remove the "Query with InfluxQL" page from OSS docs
- Re-incorporate changes made in https://github.com/influxdata/docs-v2/pull/1506
* New URL switcher (#1720)
* restructured url modal
* rearchitected the url switcher functionality
* add influxdb preference management to url switcher
* URL validation on custom URL (#1763)
* added url validation to custom url form, resolves #1739
* removed placeholder message from custom url form
* updated styles for url selector modal
* Move restore command to `influx` cli, update flags
* Update table for backup
* Remove RC information, update paths for restore, change `backup-path` flag to `input`
* WIP separate cloud docs, duplicate content shortcode
* WIP cloud-separation
* WIP separate cloud
* duplicated oss into cloud and am making updates
* moved cloud updates to cloud
* reimplemented duplicate-oss shortcode
* separate Cloud and OSS content in Tools & integ...
* Split OSS and Cloud content for Security & auth
* Split OSS and Cloud content for Manage org
* Split OSS and Cloud - Manage Orgs add'l updates
* various updates, primarily in oss and cloud reference
* split content for notification endpoints
* Move InfluxQL doc to Cloud
- Remove the "Query with InfluxQL" page from OSS docs
- Re-incorporate changes made in https://github.com/influxdata/docs-v2/pull/1506
* removed product tags from nav and articles
* WIP separate cloud docs, duplicate content shortcode
* WIP cloud-separation
* WIP separate cloud
* duplicated oss into cloud and am making updates
* moved cloud updates to cloud
* reimplemented duplicate-oss shortcode
* separate Cloud and OSS content in Tools & integ...
* Split OSS and Cloud content for Manage org
* Split OSS and Cloud - Manage Orgs add'l updates
* various updates, primarily in oss and cloud reference
* Move InfluxQL doc to Cloud
- Remove the "Query with InfluxQL" page from OSS docs
- Re-incorporate changes made in https://github.com/influxdata/docs-v2/pull/1506
* New URL switcher (#1720)
* restructured url modal
* rearchitected the url switcher functionality
* add influxdb preference management to url switcher
* WIP separate cloud docs, duplicate content shortcode
* WIP cloud-separation
* WIP separate cloud
* duplicated oss into cloud and am making updates
* moved cloud updates to cloud
* reimplemented duplicate-oss shortcode
* Split OSS and Cloud content for Manage org
* Split OSS and Cloud - Manage Orgs add'l updates
* various updates, primarily in oss and cloud reference
* Move InfluxQL doc to Cloud
- Remove the "Query with InfluxQL" page from OSS docs
- Re-incorporate changes made in https://github.com/influxdata/docs-v2/pull/1506
* WIP separate cloud docs, duplicate content shortcode
* WIP cloud-separation
* WIP separate cloud
* duplicated oss into cloud and am making updates
* moved cloud updates to cloud
* reimplemented duplicate-oss shortcode
* separate Cloud and OSS content in Tools & integ...
* Split OSS and Cloud content for Manage org
* Split OSS and Cloud - Manage Orgs add'l updates
* various updates, primarily in oss and cloud reference
* Move InfluxQL doc to Cloud
- Remove the "Query with InfluxQL" page from OSS docs
- Re-incorporate changes made in https://github.com/influxdata/docs-v2/pull/1506
* URL validation on custom URL (#1763)
* added url validation to custom url form, resolves #1739
* removed placeholder message from custom url form
* updated styles for url selector modal
* WIP updating InfluxDB OSS naming throughout
* updated canonical shortcode for oss vs cloud, updated 2.0 version numbers on homepage
* updated swagger file to rc4 for 2.0 and cloud
* fixed canonical partial
* Update multi-user Cloud docs
Also adds a heading the note on permissions.
Closes #1764
* Fix table for backup flags
* Update input flag, remove TSI references
* Address PR feedback
* Remove product tag
* Fix DBRP mapping examples (#1776)
* updated dbrp mapping examples in influxql query guide, closes #1774
* removed unnecessarily escaped newline from dbrp mapping example
* add draft rc4 and GA RNs
* cloud and oss name updates
* emphasis production ready
* update curl example
* duplicate oss pages in cloud
* Address PR feedback
* added new aws us east region, resolves #1777 (#1782)
* Add steps for script editor
* Add cloud version
* moved and updated upgrade guides (#1783)
* Fix typos
* update upgrade links
* edits
* Clarify 1m cardinality is initial limit only
* fix typo
* fix date
* Add note on `_internal` database to v1-to-v2 upgrade guide
Closes #1775.
* Update influxdb.md
* fixed broken links throughout cloud docs
* fixed broken links in 2.0 oss
* Address PR feedback
* remove window pushdowns
* updated oss pushdown list
* Add instructions for verifying InfluxDB 2.0 download
* updated latest versions in edge.js
* added flux-0.94.0 to flux release notes (#1790)
* update date and add Flux .94.0 link
* delete broken link to image
* remove auto refresh; not currently in UI
* add duplicate-oss tag to Cloud execute-queries
* highlight diff between Flux and InfluxQL example
* delete extra header
* Generate v1 compatibility API docs (#1789)
* updated swagger generation to generate v1 compat api docs
* restructured api docs
* updated restore flags table
* updated infludb binary urls in oss and cloud
* Address PR feedback
* Make contact support a mailto link
* Add --log-level flag to `influxd upgrade`
Closes #1795
* add release note about api/v2/delete
* update delete data note for 2.0
* edit
* Fix URLs and filenames in OSS 2.0 Get Started
* update version for GA
* Add color to Flux example for Flux documentation (addresses #1724 )
* Change versions to 2.0.1 in GS
* Replace 2.0.0 with 2.0.1
* Revert Docker updates to 2.0.0
* Add release notes for 2.0.0
* edits; add known issue
* clarify DB is 1.x
* updated influxdb versions in cloud and oss getting started
* updated influxdb oss urls doc
* remove rc and upd upgrade link in back up data
* Edit `influxd upgrade` docs (#1798)
* Edit `influxd upgrade` guide
Major revision of existing docs.
Add "Before you begin: important considerations" section.
* Address PR feedback
* Edit backup instructions
* More work on kap
* Rm comment
* Rm sentence
* Add note on Docker
* Edit intro
* Edit link
* Work on PR feedback
* Continue PR feedback
* More PR feedback
* More edits
* more edits
* Edits
* more edits
* rm word
* updates to address PR feedback for the upgrade guide
Co-authored-by: pierwill <pierwill@users.noreply.github.com>
Co-authored-by: Scott Anderson <scott@influxdata.com>
Co-authored-by: Kelly <kelly@influxdata.com>
Co-authored-by: pierwill <pierwill@users.noreply.github.com>
Co-authored-by: pierwill <19642016+pierwill@users.noreply.github.com>
Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com>
Co-authored-by: noramullen1 <42354779+noramullen1@users.noreply.github.com>
2020-11-11 16:52:14 +00:00
|
|
|
'influxdb': 'v2.0',
|
2020-08-27 05:19:33 +00:00
|
|
|
'influxdbv2': 'v2.0',
|
2021-06-17 21:56:25 +00:00
|
|
|
'telegraf': 'v1.19',
|
2021-06-28 21:00:08 +00:00
|
|
|
'chronograf': 'v1.9',
|
2021-06-28 20:57:05 +00:00
|
|
|
'kapacitor': 'v1.6',
|
2021-06-17 19:45:43 +00:00
|
|
|
'enterprise': 'v1.9',
|
2020-08-27 05:19:33 +00:00
|
|
|
};
|
|
|
|
|
2020-09-11 19:51:36 +00:00
|
|
|
const archiveDomain = 'https://archive.docs.influxdata.com';
|
2020-08-27 05:19:33 +00:00
|
|
|
|
|
|
|
exports.handler = (event, context, callback) => {
|
|
|
|
|
|
|
|
function temporaryRedirect(condition, newUri) {
|
|
|
|
if (condition) {
|
|
|
|
return callback(null, {
|
|
|
|
status: '302',
|
|
|
|
statusDescription: 'Found',
|
|
|
|
headers: {
|
|
|
|
location: [{
|
|
|
|
key: 'Location',
|
|
|
|
value: newUri,
|
|
|
|
}],
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function permanantRedirect(condition, newUri) {
|
|
|
|
if (condition) {
|
|
|
|
return callback(null, {
|
|
|
|
status: '301',
|
|
|
|
statusDescription: 'Moved Permanently',
|
|
|
|
headers: {
|
|
|
|
'location': [{
|
|
|
|
key: 'Location',
|
|
|
|
value: newUri,
|
|
|
|
}],
|
|
|
|
'cache-control': [{
|
|
|
|
key: 'Cache-Control',
|
|
|
|
value: "max-age=3600"
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const { request } = event.Records[0].cf;
|
|
|
|
const parsedPath = path.parse(request.uri);
|
|
|
|
const indexPath = 'index.html';
|
|
|
|
const validExtensions = {
|
|
|
|
'.html': true,
|
|
|
|
'.css': true,
|
|
|
|
'.js': true,
|
|
|
|
'.xml': true,
|
|
|
|
'.png': true,
|
|
|
|
'.gif': true,
|
|
|
|
'.jpg': true,
|
|
|
|
'.ico': true,
|
|
|
|
'.svg': true,
|
|
|
|
'.csv': true,
|
|
|
|
'.txt': true,
|
|
|
|
'.lp': true,
|
|
|
|
'.json': true,
|
|
|
|
'.rb': true,
|
|
|
|
'.eot': true,
|
|
|
|
'.ttf': true,
|
|
|
|
'.woff': true,
|
|
|
|
'.otf': true,
|
2020-09-14 18:26:53 +00:00
|
|
|
'.gz': true,
|
|
|
|
'.tar': true,
|
2021-02-19 18:07:47 +00:00
|
|
|
'.zip': true,
|
2020-09-14 18:47:07 +00:00
|
|
|
'.md5': true,
|
|
|
|
'.sha256': true,
|
2020-08-27 05:19:33 +00:00
|
|
|
};
|
|
|
|
|
2020-11-16 18:52:56 +00:00
|
|
|
// Remove multiple slashes from path
|
2021-02-19 18:07:47 +00:00
|
|
|
// permanantRedirect(/\/{2,}/.test(request.uri), request.uri.replace(/\/{2,}/, `/`));
|
2020-11-16 18:52:56 +00:00
|
|
|
|
2020-08-27 05:19:33 +00:00
|
|
|
// Remove index.html from path
|
2020-09-01 23:08:54 +00:00
|
|
|
permanantRedirect(request.uri.endsWith('index.html'), request.uri.substr(0, request.uri.length - indexPath.length));
|
2020-08-27 05:19:33 +00:00
|
|
|
|
|
|
|
// If file has a valid extension, return the request unchanged
|
|
|
|
if (validExtensions[parsedPath.ext]) {
|
|
|
|
callback(null, request);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////// START PRODUCT-SPECIFIC REDIRECTS //////////////////////
|
|
|
|
|
|
|
|
//////////////////////////// v2 subdomain redirect ///////////////////////////
|
2020-09-01 23:08:54 +00:00
|
|
|
permanantRedirect(request.headers.host[0].value === 'v2.docs.influxdata.com', `https://docs.influxdata.com${request.uri}`);
|
2020-08-27 05:19:33 +00:00
|
|
|
|
|
|
|
////////////////////////// Latest version redirects //////////////////////////
|
|
|
|
temporaryRedirect(/\/influxdb\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['influxdb']}`));
|
|
|
|
temporaryRedirect(/\/telegraf\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['telegraf']}`));
|
|
|
|
temporaryRedirect(/\/chronograf\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['chronograf']}`));
|
|
|
|
temporaryRedirect(/\/kapacitor\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['kapacitor']}`));
|
|
|
|
temporaryRedirect(/\/enterprise_influxdb\/latest/.test(request.uri), request.uri.replace(/\/latest/, `/${latestVersions['enterprise']}`));
|
|
|
|
|
|
|
|
////////////////////////// Versionless URL redirects /////////////////////////
|
|
|
|
temporaryRedirect(request.uri === '/influxdb/', `/influxdb/${latestVersions['influxdb']}/`);
|
|
|
|
temporaryRedirect(request.uri === '/telegraf/', `/telegraf/${latestVersions['telegraf']}/`);
|
|
|
|
temporaryRedirect(request.uri === '/chronograf/', `/chronograf/${latestVersions['chronograf']}/`);
|
|
|
|
temporaryRedirect(request.uri === '/kapacitor/', `/kapacitor/${latestVersions['kapacitor']}/`);
|
|
|
|
temporaryRedirect(request.uri === '/enterprise_influxdb/', `/enterprise_influxdb/${latestVersions['enterprise']}/`);
|
|
|
|
|
|
|
|
/////////////////////////////// Flux redirects ///////////////////////////////
|
|
|
|
// Redirect flux guides and introduction based on latest InfluxDB version
|
|
|
|
if (/v2/.test(latestVersions['influxdb'])) {
|
2020-09-09 16:14:09 +00:00
|
|
|
temporaryRedirect(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\/guides\//.test(request.uri), request.uri.replace(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\/guides\//, `/influxdb/${latestVersions['influxdb']}/query-data/flux/`));
|
|
|
|
temporaryRedirect(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\/introduction\//.test(request.uri), request.uri.replace(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\/introduction\//, `/influxdb/${latestVersions['influxdb']}/query-data/get-started/`));
|
2020-08-27 05:19:33 +00:00
|
|
|
} else {
|
2020-09-09 16:14:09 +00:00
|
|
|
temporaryRedirect(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\/guides\//.test(request.uri), request.uri.replace(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\/guides\//, `/influxdb/${latestVersions['influxdb']}/flux/guides/`));
|
|
|
|
temporaryRedirect(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\/introduction\//.test(request.uri), request.uri.replace(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\/introduction\//, `/influxdb/${latestVersions['influxdb']}/flux/`));
|
2020-08-27 05:19:33 +00:00
|
|
|
}
|
|
|
|
// Redirect Flux stdlib and language sections to v2 Flux docs
|
2020-09-09 16:14:09 +00:00
|
|
|
temporaryRedirect(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\/(?:functions|stdlib|language)\//.test(request.uri), request.uri.replace(/\/flux\/(?:v0\.[0-9]{1,2}|latest)\//, `/influxdb/${latestVersions['influxdbv2']}/reference/flux/`));
|
2020-08-27 05:19:33 +00:00
|
|
|
|
|
|
|
// Redirect versionless and base version to v2 Flux docs
|
2020-09-11 19:51:36 +00:00
|
|
|
temporaryRedirect(/^\/flux\/(?:v0\.[0-9]{1,2}\/|latest|)(?:\/|)$/.test(request.uri), `/influxdb/${latestVersions['influxdbv2']}/reference/flux/`);
|
2020-08-27 05:19:33 +00:00
|
|
|
|
|
|
|
////////////////////////////// v2 path redirect //////////////////////////////
|
2020-09-01 23:08:54 +00:00
|
|
|
permanantRedirect(/^\/v2\.0\//.test(request.uri), request.uri.replace(/^\/v2\.0\//, `/influxdb/v2.0/`));
|
2020-08-27 05:19:33 +00:00
|
|
|
|
|
|
|
////////////////////////// Archive version redirects /////////////////////////
|
2020-09-01 23:08:54 +00:00
|
|
|
permanantRedirect(/\/influxdb\/(?:v0\.[0-9]{1,2}|v1\.[0-2])\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
|
|
permanantRedirect(/\/telegraf\/(?:v0\.[0-9]{1,2}|v1\.[0-8])\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
|
|
permanantRedirect(/\/chronograf\/(?:v0\.[0-9]{1,2}|v1\.[0-5])\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
|
|
permanantRedirect(/\/kapacitor\/(?:v0\.[0-9]{1,2}|v1\.[0-3])\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
|
|
permanantRedirect(/\/enterprise_influxdb\/v1\.[0-3]\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
|
|
|
permanantRedirect(/\/enterprise_kapacitor\//.test(request.uri), `${archiveDomain}${request.uri}`);
|
2020-08-27 05:19:33 +00:00
|
|
|
|
|
|
|
/////////////////////// END PRODUCT-SPECIFIC REDIRECTS ///////////////////////
|
|
|
|
|
|
|
|
// Redirect to the a trailing slash
|
2020-09-01 23:08:54 +00:00
|
|
|
permanantRedirect(!request.uri.endsWith('/'), request.uri + '/');
|
2020-08-27 05:19:33 +00:00
|
|
|
|
|
|
|
// Use index.html if the path doesn't have an extension
|
|
|
|
// or if the version number is parsed as an extension.
|
|
|
|
let newUri;
|
|
|
|
|
|
|
|
if (parsedPath.ext === '' || /\.\d*/.test(parsedPath.ext)) {
|
|
|
|
newUri = path.join(parsedPath.dir, parsedPath.base, indexPath);
|
|
|
|
} else {
|
|
|
|
newUri = request.uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Replace the received URI with the URI that includes the index page
|
|
|
|
request.uri = newUri;
|
|
|
|
|
|
|
|
// Return to CloudFront
|
|
|
|
// request.uri = request.uri + indexPath;
|
|
|
|
callback(null, request);
|
2020-09-02 20:18:46 +00:00
|
|
|
};
|