mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
Webiste: Update custom hook to validate githubRepoDRIByPath config variable (#24497)
Closes: #24399 Changes: - Updated the website's custom hook to validate values in the sails.config.custom.githubRepoDRIByPath config variable when the website starts.
This commit is contained in:
parent
cae70d2921
commit
00c35aed11
1 changed files with 13 additions and 0 deletions
13
website/api/hooks/custom/index.js
vendored
13
website/api/hooks/custom/index.js
vendored
|
|
@ -88,6 +88,19 @@ will be disabled and/or hidden in the UI.
|
|||
from: sails.config.custom.fromEmailAddress,
|
||||
fromName: sails.config.custom.fromName,
|
||||
});
|
||||
|
||||
// Validate all values in the githubRepoDRIByPath config variable.
|
||||
if(sails.config.custom.githubRepoDRIByPath) {
|
||||
if(!_.isObject(sails.config.custom.githubRepoDRIByPath)) {
|
||||
throw new Error(`Invalid configuration! An invalid "sails.config.custom.githubRepoDRIByPath" value was provided. If set, this value should be a dictionary, where each key is a path in the GitHub repo, and each value is a GitHub username. Please change this value to be a dictionary and try running this script again.`);
|
||||
}
|
||||
for(let path in sails.config.custom.githubRepoDRIByPath) {
|
||||
if(typeof sails.config.custom.githubRepoDRIByPath[path] !== 'string') {
|
||||
throw new Error(`Invalid configuration! A path (${path}) in the "sails.config.custom.githubRepoDRIByPath" config value contains a DRI value that is not a string (type: ${typeof sails.config.custom.githubRepoDRIByPath[path]}). Please change the DRI for this path to be a string containing a single GitHub username and try running this script again.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send a request to our Algolia crawler to reindex the website.
|
||||
// FUTURE: If this breaks again, use the Platform model to store when the website was last crawled
|
||||
// (platform.algoliaLastCrawledWebsiteAt), and then only send a request if it was <30m ago, then remove dyno check.
|
||||
|
|
|
|||
Loading…
Reference in a new issue