Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let _obj: Partial | boolean = obj;
// If the variable is a plugin setting that is contained in aliases
// Then update the config via the filename not the alias
const res = /plugins\.([\w-]+)/.exec(key);
if (res && aliases.plugins[res[1]]) {
_key = key
.split('.')
.slice(2)
.join('.');
_obj = obj.plugins![aliases.plugins[res[1]]];
}
// Try set the key, however current value may be a boolean or undefined
// meaning that deeper keys may throw error. If that's the case,
// then set the value to an empty object, and try again
dot.str(_key, value, _obj);
});
const { checked } = target;
let newValue;
const index = oldValue.indexOf(value);
if (checked && index < 0) {
newValue = [...oldValue, value]
} else if (!checked && index > -1) {
newValue = oldValue.filter(v => v !== value);
}
// using dot helps us change nested values
let data;
const isNested = name.includes('.');
if (isNested) {
dot.override = true;
data = dot.str(name, newValue, { ...formData });
} else {
data = { ...formData, [name]: newValue };
}
setChecked(checked);
setFormData(data);
}, [value, formData, setFormData, name]);
].map(eventPath => {
dot.str(eventPath, eventPath, events);
return eventPath;
});
function setTfParameter(parameter, value, root = '$') {
dot.str(`${root}.terraform.${parameter}`, value.constructor === String ? trimBoth(value, '"') : value, cfg);
}
set(path, value) {
dot.str(path, value, this._config);
return this;
}
].map(eventPath => {
dot.str(eventPath, eventPath, events);
return eventPath;
});
let key = workspaceEnabled ? `available-workspaces.${tfWorkspace}.var-files` : 'var-files';
setTfParameter(key, tfVarfiles, cfgKey);
}
for (let property in tfVars) {
if (tfVars.hasOwnProperty(property)) {
let key = workspaceEnabled ? `available-workspaces.${tfWorkspace}.vars` : 'vars';
setTfParameter(`${key}.${property}`, tfVars[property], cfgKey);
}
}
});
let customConfig = optionsToObject(options.customConfig);
for (let property in customConfig) {
if (customConfig.hasOwnProperty(property)) {
dot.str(property, customConfig[property], cfg);
}
}
return Promise.resolve(cfg);
}
].map(eventPath => {
dot.str(eventPath, eventPath, events);
return eventPath;
});
function transformConfig(config) {
cfg = config;
if (options.sync) {
dot.str('$.cnci.sync', true, cfg);
}
let { modules, filtered } = parseModules(cfg);
let workspaceEnabled = false;
let tfModules = modules.filter(module => typeof dot.pick(`${module}.terraform`, cfg) !== 'undefined');
tfModules.forEach(module => {
let tfVars = optionsToObject(options.tfVars);
let tfVarfiles = _arr(options.tfVarfiles);
let tfWorkspace = options.tfWorkspace;
let cfgKey = filtered ? module : ConfigBasedComponent.MAIN_CONFIG_KEY;
if (options.tfVersion) {
setTfParameter('version', options.tfVersion, cfgKey);
}