Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Source Code Plugin
const scmConfig = config.get('scm');
const ScmPlugin = require(`screwdriver-scm-${scmConfig.plugin}`);
const scm = new ScmPlugin(hoek.applyToDefaults({ ecosystem },
(scmConfig[scmConfig.plugin] || {})));
authConfig.scm = scm;
// Setup Model Factories
const Models = require('screwdriver-models');
const userFactory = Models.UserFactory.getInstance({
datastore,
scm,
password: authConfig.encryptionPassword
});
const tokenFactory = Models.TokenFactory.getInstance({
datastore
});
// Setup datastore and create test user
return datastore.setup()
.then(() => userFactory.get({ username, scmContext }))
.then((model) => {
if (!model) {
return userFactory.create({
username,
scmContext,
token: gitToken
});
}
return model.sealToken(gitToken)
const datastoreConfig = config.get('datastore');
const DatastorePlugin = require(`screwdriver-datastore-${datastoreConfig.plugin}`);
const datastore = new DatastorePlugin(hoek.applyToDefaults({ ecosystem },
(datastoreConfig[datastoreConfig.plugin] || {})));
// Source Code Plugin
const scmConfig = config.get('scm');
const ScmPlugin = require(`screwdriver-scm-${scmConfig.plugin}`);
const scm = new ScmPlugin(hoek.applyToDefaults({ ecosystem },
(scmConfig[scmConfig.plugin] || {})));
authConfig.scm = scm;
// Setup Model Factories
const Models = require('screwdriver-models');
const userFactory = Models.UserFactory.getInstance({
datastore,
scm,
password: authConfig.encryptionPassword
});
const tokenFactory = Models.TokenFactory.getInstance({
datastore
});
// Setup datastore and create test user
return datastore.setup()
.then(() => userFactory.get({ username, scmContext }))
.then((model) => {
if (!model) {
return userFactory.create({
username,
scmContext,
handler: (request, reply) => {
const Platform = new Model.Platform(datastore);
const config = request.payload;
const id = Platform.generateId({
name: config.name,
version: config.version
});
const location = urlLib.format({
host: request.headers.host,
port: request.headers.port,
protocol: request.server.info.protocol,
pathname: `${request.path}/${id}`
});
/* eslint-disable consistent-return */
Platform.get(id, (error, data) => {
if (error) {
return reply(boom.wrap(error));
handler: (request, reply) => {
const Platform = new Model.Platform(datastore);
Platform.list(request.query, reply);
},
response: {