Skip to content

Commit

Permalink
FIX: Always setting public files to true
Browse files Browse the repository at this point in the history
  • Loading branch information
Blagoj Petrov committed May 14, 2023
1 parent b5fa17e commit 57f296a
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions lib/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ const get = (obj, path, defaultValue = undefined) => {
return result === undefined || result === obj ? defaultValue : result;
};

/**
* Sets a configuration field value.
*
* @param {*} fieldValue - The value to validate.
* @param {*} defaultValue - The default value to return if the field is not provided or is invalid.
* @returns {*} The validated field value or the default value.
* @throws {Error} If the default value is undefined or the field value is undefined.
*/
const setConfigField = (fieldValue, defaultValue) => {
if (typeof defaultValue === 'undefined') throw new Error('Default value is required!');
if (typeof fieldValue === 'undefined') return defaultValue;
switch (typeof fieldValue) {
case 'boolean':
return fieldValue;
case 'string':
if (['true', 'false'].includes(fieldValue)) return fieldValue === 'true';
throw new Error(`Invalid boolean value for ${fieldValue}!`);
default:
return defaultValue;
}
}

/**
* Check validity of Service Account configuration
* @param config
Expand All @@ -43,9 +65,9 @@ const checkServiceAccount = (config = {}) => {
}

/** Check or set default boolean optional variable */
config.publicFiles = eval(config.publicFiles) || true; // default value
config.uniform = eval(config.uniform) || false; // default value
config.skipCheckBucket = eval(config.skipCheckBucket) || false; // default value
config.publicFiles = setConfigField(config.publicFiles, true); // default value
config.uniform = setConfigField(config.uniform, false); // default value
config.skipCheckBucket = setConfigField(config.skipCheckBucket, false); // default value

let serviceAccount;
if (config.serviceAccount) {
Expand Down

0 comments on commit 57f296a

Please sign in to comment.