How to use the screwdriver-models.TokenFactory function in screwdriver-models

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)

screwdriver-models

Screwdriver models

BSD-3-Clause
Latest version published 9 days ago

Package Health Score

79 / 100
Full package analysis