Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x | import { defineCommand } from '../../lib/define-command.js';
import { k8sList } from '../../lib/k8s.js';
import { styleText } from '../../lib/style-text.js';
import { Logger } from '../../logger.js';
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
export const k8sListCommand = defineCommand({
description: 'List Kubernetes clusters',
since: '4.3.0',
options: {
org: orgaIdOrNameOption,
format: humanJsonOutputFormatOption,
},
args: [],
async handler(options) {
const { format, org: orgIdOrName } = options;
const clusters = await k8sList(orgIdOrName, format);
switch (format) {
case 'json':
Logger.printJson(clusters);
break;
case 'human':
default:
if (clusters.length === 0) {
Logger.println(`🔎 No cluster found, create one with ${styleText('blue', `clever k8s create`)} command`);
return;
}
Logger.println(`🔎 Found ${clusters.length} cluster${clusters.length > 1 ? 's' : ''}:`);
Object.values(clusters).forEach((c) => {
Logger.println(` • ${styleText('white', `${c.name} (${c.id})`)} - ${c.status}`);
});
break;
}
},
});
|