UNPKG

balena-cli

Version:

The official balena Command Line Interface

52 lines (50 loc) 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@oclif/core"); const lazy_1 = require("../../utils/lazy"); const pine_1 = require("../../utils/pine"); class FleetPinCmd extends core_1.Command { async run() { const { args: params } = await this.parse(FleetPinCmd); const balena = (0, lazy_1.getBalenaSdk)(); const fleet = await balena.models.application.get(params.slug, { $expand: { should_be_running__release: { $select: 'commit', }, }, }); const pinnedRelease = (0, pine_1.getExpandedProp)(fleet.should_be_running__release, 'commit'); const releaseToPinTo = params.releaseToPinTo; const slug = params.slug; if (!releaseToPinTo) { console.log(`${pinnedRelease ? `This fleet is currently pinned to ${pinnedRelease}.` : 'This fleet is not currently pinned to any release.'} \n\nTo see a list of all releases this fleet can be pinned to, run \`balena release list ${slug}\`.`); } else { await balena.models.application.pinToRelease(slug, releaseToPinTo); } } } FleetPinCmd.description = (0, lazy_1.stripIndent) ` Pin a fleet to a release. Pin a fleet to a release. Note, if the commit is omitted, the currently pinned release will be printed, with instructions for how to see a list of releases `; FleetPinCmd.examples = [ '$ balena fleet pin myfleet', '$ balena fleet pin myorg/myfleet 91165e5', ]; FleetPinCmd.args = { slug: core_1.Args.string({ description: 'the slug of the fleet to pin to a release', required: true, }), releaseToPinTo: core_1.Args.string({ description: 'the commit of the release for the fleet to get pinned to', }), }; FleetPinCmd.authenticated = true; exports.default = FleetPinCmd; //# sourceMappingURL=pin.js.map