Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Always setting public files to true #170

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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