mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
feat: allow python custom registries configuration
This commit is contained in:
parent
9444c7b4f6
commit
833fa285aa
5 changed files with 259 additions and 3 deletions
|
|
@ -5,3 +5,11 @@
|
|||
export function getMinimumPackageAgeHours() {
|
||||
return process.env.SAFE_CHAIN_MINIMUM_PACKAGE_AGE_HOURS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom pip registries from environment variable
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
export function getPipCustomRegistries() {
|
||||
return process.env.SAFE_CHAIN_PIP_CUSTOM_REGISTRIES;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,3 +98,30 @@ export function skipMinimumPackageAge() {
|
|||
|
||||
return defaultSkipMinimumPackageAge;
|
||||
}
|
||||
|
||||
/** @type {string[]} */
|
||||
const defaultPipCustomRegistries = [];
|
||||
/** @returns {string[]} */
|
||||
export function getPipCustomRegistries() {
|
||||
// Priority 1: Environment variable
|
||||
const envValue = validatePipCustomRegistries(
|
||||
environmentVariables.getPipCustomRegistries()
|
||||
);
|
||||
if (envValue !== undefined) {
|
||||
return envValue;
|
||||
}
|
||||
|
||||
return defaultPipCustomRegistries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string | undefined} value
|
||||
* @returns {string[] | undefined}
|
||||
*/
|
||||
function validatePipCustomRegistries(value) {
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return value.split(",");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue