|
| 1 | +const debug = require('debug')('codefresh:cli:create:pipelines2'); |
| 2 | +const Command = require('../../Command'); |
| 3 | +const _ = require('lodash'); |
| 4 | +const { runtimeEnvironments } = require('../../../../logic/index').api; |
| 5 | + |
| 6 | +const getRoot = require('../root/get.cmd'); |
| 7 | + |
| 8 | + |
| 9 | +const command = new Command({ |
| 10 | + command: 'runtime-environments [name] [version]', |
| 11 | + aliases: ['re', 'runtime-environment'], |
| 12 | + parent: getRoot, |
| 13 | + description: 'Get a runtime environments configuration', |
| 14 | + onPremCommand: true, |
| 15 | + webDocs: { |
| 16 | + category: 'Runtime-Environments (On Prem)', |
| 17 | + title: 'Get Runtime-Environments', |
| 18 | + }, |
| 19 | + builder: (yargs) => { |
| 20 | + return yargs |
| 21 | + .positional('name', { |
| 22 | + describe: 'Runtime environments name', |
| 23 | + default: 'default', |
| 24 | + }) |
| 25 | + .positional('version', { |
| 26 | + describe: 'Runtime environments version', |
| 27 | + }) |
| 28 | + .option('account', { |
| 29 | + describe: 'Return a specific account configuration from the current runtime environments by his name', |
| 30 | + }) |
| 31 | + .option('history', { |
| 32 | + describe: 'Return all the history of the specific runtime environments', |
| 33 | + type: 'boolean', |
| 34 | + }); |
| 35 | + }, |
| 36 | + handler: async (argv) => { |
| 37 | + const { name, version, history, account } = argv; |
| 38 | + let currruntimeEnvironments; |
| 39 | + if (account) { |
| 40 | + currruntimeEnvironments = await runtimeEnvironments.getRuntimeEvironment(account); |
| 41 | + } else { |
| 42 | + currruntimeEnvironments = await runtimeEnvironments.getRuntimeEvironmentsByName({ |
| 43 | + name, |
| 44 | + version, |
| 45 | + history, |
| 46 | + }); |
| 47 | + } |
| 48 | + console.log(JSON.stringify(currruntimeEnvironments, null, '\t')); |
| 49 | + }, |
| 50 | +}); |
| 51 | + |
| 52 | +module.exports = command; |
| 53 | + |
0 commit comments