|
| 1 | +const _ = require('lodash'); |
| 2 | +const debug = require('debug')('codefresh:cli:create:context:git:github'); |
| 3 | +const Command = require('../../../Command'); |
| 4 | +const CFError = require('cf-errors'); |
| 5 | +const createbase = require('./../create.cmd'); |
| 6 | +const { |
| 7 | + registry, |
| 8 | +} = require('../../../../../logic/index').api; |
| 9 | + |
| 10 | +const command = new Command({ |
| 11 | + command: 'standard <name>', |
| 12 | + parent: createbase, |
| 13 | + description: 'Integrate a standard container registry into Codefresh', |
| 14 | + webDocs: { |
| 15 | + category: 'Registries', |
| 16 | + title: 'Standard', |
| 17 | + subCategory: 'standard', |
| 18 | + weight: 10, |
| 19 | + }, |
| 20 | + builder: (yargs) => { |
| 21 | + yargs |
| 22 | + .positional('name', { |
| 23 | + describe: 'Registry name', |
| 24 | + }) |
| 25 | + .option('username', { |
| 26 | + describe: 'Username to access the docker registry', |
| 27 | + required: true, |
| 28 | + }) |
| 29 | + .option('password', { |
| 30 | + describe: 'Password to access the docker registry', |
| 31 | + required: true, |
| 32 | + }) |
| 33 | + .option('domain', { |
| 34 | + describe: 'Domain to access the docker registry', |
| 35 | + required: true, |
| 36 | + }) |
| 37 | + .option('behind-firewall', { |
| 38 | + describe: 'Set if the registry is behind a firewall', |
| 39 | + default: false, |
| 40 | + type: 'boolean', |
| 41 | + }); |
| 42 | + return yargs; |
| 43 | + }, |
| 44 | + handler: async (argv) => { |
| 45 | + const data = _.chain(argv) |
| 46 | + .pick(['username', 'password', 'domain', 'name', 'behindFirewall']) |
| 47 | + .merge({ provider: 'other' }) |
| 48 | + .value(); |
| 49 | + await registry.create(data); |
| 50 | + }, |
| 51 | +}); |
| 52 | + |
| 53 | +module.exports = command; |
0 commit comments