Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function JDCgetCapabilities(selectedImage) {
const log = appUtils.getLogger();
const returnCaps = [];
if (!selectedImage.labels) {
return [];
}
else {
const convertedLabels = dot.object(selectedImage.labels);
if (convertedLabels && convertedLabels.caps_add) {
const convertedCaps = convertedLabels.caps_add.split(',');
convertedCaps.forEach((cap) => {
const cleanedCap = cap.trim();
// If is a valid cap add
if (dockerCapabilities.check(cleanedCap)) {
returnCaps.push(cleanedCap);
}
else log.warn(`${cap} is not a valid cap! No converted`);
});
// TBD CHECK OF CAPS
return returnCaps;
}
else return [];
}
}
Object.keys(this.props.schema).map(fieldName =>
{
if(typeof state[`${fieldName}_fieldValue`] !== 'undefined' &&
!(this.props.type === 'insert' && state[`${fieldName}_fieldValue`] === '') &&
this.getDocumentValue(fieldName) !== this.getStateOrDefaultSchemaValue(fieldName, null, null, state))
{
formFields[fieldName] = this.getStateOrDefaultSchemaValue(fieldName, null, null, state); // Gets the state value
if(fieldName.indexOf('.') > 0) // If this fieldName belongs to object
{
let fieldNameObj = Dot.object(Object.assign({}, {[fieldName]: formFields[fieldName]})), // Get the entire object
// schemaKey = fieldName.substr(0, fieldName.lastIndexOf('.')); // Get the parent object key
schemaKey = fieldName.substr(0, fieldName.indexOf('.')); // Get the parent object key
Dot.copy(schemaKey, schemaKey, this.props.doc, fieldNameObj); // Copy the original object
formFields = {...Dot.dot(fieldNameObj), ...formFields}; // Turn the original object into dotted object and then merge it with the new fieldName value
}
}
});
config.get('nitro.basePath'),
config.get('nitro.viewDataDirectory'),
`/${req.query._data}.json`
) : false;
if (customDataPath && fs.existsSync(customDataPath)) {
extend(true, data, JSON.parse(fs.readFileSync(customDataPath, 'utf8')));
} else if (fs.existsSync(dataPath)) {
extend(true, data, JSON.parse(fs.readFileSync(dataPath, 'utf8')));
}
// handle query string parameters
if (Object.keys(req.query).length !== 0) {
// simple clone
const reqQuery = JSON.parse(JSON.stringify(req.query));
dot.object(reqQuery);
extend(true, data, reqQuery);
// save query for use in patterns
data._query = reqQuery;
}
// layout handling
if (data._layout) {
if (utils.layoutExists(data._layout)) {
data.layout = utils.getLayoutPath(data._layout);
}
}
if (!data.layout || !utils.layoutExists(utils.getLayoutName(data.layout))) {
// use default layout if present
if (utils.layoutExists(config.get('nitro.defaultLayout'))) {
data.layout = utils.getLayoutPath(config.get('nitro.defaultLayout'));
}
elasticsearchPool.getConnection(url,httpAuth).then(function (client) {
client.index({
index: index,
type: type,
id: document_id,
body: parser.object(document)
}, function (error, response) {
if (!error && !response.errors) {
logger.info('Inserted document %s to %s/%s (index/type)', document_id, index, type);
return resolve(true);
} else {
if (error) {
logger.error('Document %s NOT inserted to %s/%s (index/type) because of "%s"\n%s', document_id, index, type, error.message, error.stack);
return reject(error);
}
if (response.errors) {
logger.warn('Document %s NOT inserted to %s/%s (index/type):\n%s', document_id, index, type, JSON.stringify(response.errors));
return reject(response.errors);
}
}
}).catch(function (err) {
return reject(err);
createResultYaml() {
const jsonObject = this.createYamlFromPages();
var resultYaml =
"apiVersion: " +
this.state.spec.apiVersion +
"\n" +
"kind: " +
this.state.spec.kind +
"\n";
if (Object.getOwnPropertyNames(jsonObject).length > 0) {
resultYaml = resultYaml + YAML.safeDump(Dot.object(jsonObject));
}
this.setState({
resultYaml: resultYaml
});
return resultYaml;
}
internalConfig.validate = values => {
var errors = validatejs(values, fieldValidationsConstraints);
if (errors) {
dot.object(errors);
}
return errors || {};
};
_.forEach(json, row => {
dot.object(row);
});
return json;
elasticsearchPool.getConnection(url,httpAuth).then(function (client) {
client.update({
index: index,
type: type,
id: document_id,
body: {
doc: parser.object(partialDocument)
}
}, function (error, response) {
if (!error && !response.errors) {
logger.info('Update %s in %s/%s (index/type)', document_id, index, type);
return resolve(true);
} else {
if (error) {
logger.error('Document %s to be updated but not found', document_id);
return reject(error);
}
if (response.errors) {
logger.warn('Document %s NOT updated to %s/%s (index/type):\n%s', document_id, index, type, JSON.stringify(response.errors));
return reject(response.errors);
}
}
}).catch(function (err) {