jamsocket
Version:
A CLI for the Jamsocket platform
39 lines (38 loc) • 1.7 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const jamsocket_1 = require("../../jamsocket");
const formatting_1 = require("../../lib/formatting");
class UseImage extends core_1.Command {
async run() {
const { args, flags } = await this.parse(UseImage);
const jamsocket = jamsocket_1.Jamsocket.fromEnvironment();
const parts = args.service.split('/');
if (parts.length > 2 || parts[0] === '' || parts[1] === '') {
this.error(`Invalid service name: ${args.service}`);
}
const service = parts[0];
const environment = parts[1] ?? null;
await jamsocket.updateEnvironment(service, environment, flags.image);
const fullServiceName = environment ? `${service}/${environment}` : service;
this.log(`Updated ${(0, formatting_1.lightMagenta)(fullServiceName)} to use image ${(0, formatting_1.blue)(flags.image)}`);
this.log(`Run ${(0, formatting_1.lightBlue)(`jamsocket service info ${service}`)} for more information about your service.`);
}
}
UseImage.description = 'Sets the image tag or digest to use when spawning a service';
UseImage.examples = ['<%= config.bin %> <%= command.id %> my-service -i latest'];
UseImage.flags = {
image: core_1.Flags.string({
char: 'i',
required: true,
description: 'image tag or digest for the service to use (Run `jamsocket images` for a list of images you can use.)',
}),
};
UseImage.args = [
{
name: 'service',
required: true,
description: 'Name of service whose spawning image should be updated.',
},
];
exports.default = UseImage;
;