docs-v2/deploy/edge.js

159 lines
6.8 KiB
JavaScript
Raw Normal View History

'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',
'influxdbv2': 'v2.0',
2021-06-17 21:56:25 +00:00
'telegraf': 'v1.19',
'chronograf': 'v1.9',
Kapacitor 1.6.0 (#2756) * base changes and cleanup for kapa 1.6 * Kapacitor 1.6.0 jstirnaman (#2684) * update: add kapacitor/v1/users to API doc (#2617). * fix: spelling * update: cleanup user API. * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/kapacitor/v1.6/working/api.md * Update content/kapacitor/v1.6/working/api.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Kapacitor 1.6.0 release notes (#2682) * Fix headings in Kapacitor release notes * Add 1.6.0 release notes Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Kapacitor Flux tasks (#2687) * kapacitor flux task setup * added crud docs for kapacitor flux tasks * added kapacitor flux task cli commands * Apply suggestions from code review Co-authored-by: pierwill <19642016+pierwill@users.noreply.github.com> * Update content/kapacitor/v1.6/working/flux/_index.md Co-authored-by: pierwill <19642016+pierwill@users.noreply.github.com> * Kapacitor TrickleNode (#2694) * closes #2691 * WIP TrickleNode * add Trickle chaining methods * remove unused back-to-top links in kapacitor docs * Kapacitor 1.6 new configuration settings (#2693) * kapacitor config doc cleanup * updated heading and links * added new kapacitor 1.6 config options, closes #2616, closes #2609 * updated slack instructions * Kapacitor Zenoss event handler (#2695) * added zenoss event handler to kapacitor, closes #2271 * updated descriptions and removed defaults from zenoss event handler * updated kapacitor release notes * Updated Kapacitor Kafka event handler partitioning options (#2697) * updated kafka partitioning behavior, closes #2263 * fixed typos in kapacitor kafka content * Apply suggestions from code review Co-authored-by: pierwill <19642016+pierwill@users.noreply.github.com> Co-authored-by: pierwill <19642016+pierwill@users.noreply.github.com> * added kafka link to release notes * Kapacitor API updates (#2718) * clean up kapacitor api headings * add flux task api endpoints to kapacitor api doc * Kapacitor authorization and authentication (#2717) * ported and revamped kapacitor authentication content, closes #2690 * Apply suggestions from code review Co-authored-by: Jason Stirnaman <jstirnaman@influxdata.com> * updated comment in kapacitor auth example * Apply suggestions from code review Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> Co-authored-by: Jason Stirnaman <jstirnaman@influxdata.com> Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> * updated edge.js * Add default kapacitor.conf locations (#2782) * added default kapacitor config locations, closes #2779 * Apply suggestions from code review * updated data for kapacitor 1.6.0 changelog Co-authored-by: Jason Stirnaman <jstirnaman@influxdata.com> Co-authored-by: pierwill <19642016+pierwill@users.noreply.github.com> Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com>
2021-06-28 20:57:05 +00:00
'kapacitor': 'v1.6',
'enterprise': 'v1.9',
};
const archiveDomain = 'https://archive.docs.influxdata.com';
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,
'.zip': true,
'.md5': true,
'.sha256': true,
};
// Remove multiple slashes from path
// permanantRedirect(/\/{2,}/.test(request.uri), request.uri.replace(/\/{2,}/, `/`));
// Remove index.html from path
permanantRedirect(request.uri.endsWith('index.html'), request.uri.substr(0, request.uri.length - indexPath.length));
// If file has a valid extension, return the request unchanged
if (validExtensions[parsedPath.ext]) {
callback(null, request);
}
////////////////////// START PRODUCT-SPECIFIC REDIRECTS //////////////////////
//////////////////////////// v2 subdomain redirect ///////////////////////////
permanantRedirect(request.headers.host[0].value === 'v2.docs.influxdata.com', `https://docs.influxdata.com${request.uri}`);
////////////////////////// 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'])) {
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/`));
} else {
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/`));
}
// Redirect Flux stdlib and language sections to v2 Flux docs
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/`));
// Redirect versionless and base version to v2 Flux docs
temporaryRedirect(/^\/flux\/(?:v0\.[0-9]{1,2}\/|latest|)(?:\/|)$/.test(request.uri), `/influxdb/${latestVersions['influxdbv2']}/reference/flux/`);
////////////////////////////// v2 path redirect //////////////////////////////
permanantRedirect(/^\/v2\.0\//.test(request.uri), request.uri.replace(/^\/v2\.0\//, `/influxdb/v2.0/`));
////////////////////////// Archive version redirects /////////////////////////
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}`);
/////////////////////// END PRODUCT-SPECIFIC REDIRECTS ///////////////////////
// Redirect to the a trailing slash
permanantRedirect(!request.uri.endsWith('/'), request.uri + '/');
// 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
};