How to use screwdriver-models - 4 common examples

To help you get started, we’ve selected a few screwdriver-models examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github screwdriver-cd / screwdriver / features / scripts / create-test-user.js View on Github external
// 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)
github screwdriver-cd / screwdriver / features / scripts / create-test-user.js View on Github external
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,
github screwdriver-cd / screwdriver / plugins / platforms / create.js View on Github external
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));
github screwdriver-cd / screwdriver / plugins / platforms / list.js View on Github external
handler: (request, reply) => {
            const Platform = new Model.Platform(datastore);

            Platform.list(request.query, reply);
        },
        response: {

screwdriver-models

Screwdriver models

BSD-3-Clause
Latest version published 1 month ago

Package Health Score

79 / 100
Full package analysis