mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 22:23:07 +00:00
Add fleet releases
command for seeing releases on a fleet
Change-type: minor Signed-off-by: Matthew Yarmolinsky <matthew-timothy@balena.io>
This commit is contained in:
parent
f55dd81a19
commit
7e896e82d6
@ -15,7 +15,7 @@ _balena() {
|
|||||||
device_cmds=( deactivate identify init local-mode move os-update public-url purge reboot register rename restart rm shutdown )
|
device_cmds=( deactivate identify init local-mode move os-update public-url purge reboot register rename restart rm shutdown )
|
||||||
devices_cmds=( supported )
|
devices_cmds=( supported )
|
||||||
env_cmds=( add rename rm )
|
env_cmds=( add rename rm )
|
||||||
fleet_cmds=( create purge rename restart rm )
|
fleet_cmds=( create purge releases rename restart rm )
|
||||||
internal_cmds=( osinit )
|
internal_cmds=( osinit )
|
||||||
key_cmds=( add rm )
|
key_cmds=( add rm )
|
||||||
local_cmds=( configure flash )
|
local_cmds=( configure flash )
|
||||||
|
@ -14,7 +14,7 @@ _balena_complete()
|
|||||||
device_cmds="deactivate identify init local-mode move os-update public-url purge reboot register rename restart rm shutdown"
|
device_cmds="deactivate identify init local-mode move os-update public-url purge reboot register rename restart rm shutdown"
|
||||||
devices_cmds="supported"
|
devices_cmds="supported"
|
||||||
env_cmds="add rename rm"
|
env_cmds="add rename rm"
|
||||||
fleet_cmds="create purge rename restart rm"
|
fleet_cmds="create purge releases rename restart rm"
|
||||||
internal_cmds="osinit"
|
internal_cmds="osinit"
|
||||||
key_cmds="add rm"
|
key_cmds="add rm"
|
||||||
local_cmds="configure flash"
|
local_cmds="configure flash"
|
||||||
|
99
lib/commands/fleet/releases.ts
Normal file
99
lib/commands/fleet/releases.ts
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2016-2020 Balena Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { flags } from '@oclif/command';
|
||||||
|
|
||||||
|
import Command from '../../command';
|
||||||
|
import * as cf from '../../utils/common-flags';
|
||||||
|
import * as ca from '../../utils/common-args';
|
||||||
|
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
|
||||||
|
import { applicationIdInfo } from '../../utils/messages';
|
||||||
|
|
||||||
|
interface FlagsDef {
|
||||||
|
help: void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ArgsDef {
|
||||||
|
fleet: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class FleetReleasesCmd extends Command {
|
||||||
|
public static description = stripIndent`
|
||||||
|
See a fleet's releases.
|
||||||
|
|
||||||
|
See a fleet's releases.
|
||||||
|
|
||||||
|
${applicationIdInfo.split('\n').join('\n\t\t')}
|
||||||
|
`;
|
||||||
|
|
||||||
|
public static examples = ['$ balena fleet releases 1873608'];
|
||||||
|
|
||||||
|
public static args = [ca.fleetRequired];
|
||||||
|
|
||||||
|
public static usage = 'fleet releases <fleet>';
|
||||||
|
|
||||||
|
public static flags: flags.Input<FlagsDef> = {
|
||||||
|
help: cf.help,
|
||||||
|
};
|
||||||
|
|
||||||
|
public static authenticated = true;
|
||||||
|
|
||||||
|
public async run() {
|
||||||
|
const { args: params } = this.parse<FlagsDef, ArgsDef>(FleetReleasesCmd);
|
||||||
|
|
||||||
|
const { ExpectedError } = await import('../../errors');
|
||||||
|
|
||||||
|
const balena = getBalenaSdk();
|
||||||
|
|
||||||
|
// Disambiguate target application (if params.params is a number, it could either be an ID or a numerical name)
|
||||||
|
const { getApplication } = await import('../../utils/sdk');
|
||||||
|
const application = await getApplication(balena, params.fleet);
|
||||||
|
|
||||||
|
// Check app exists
|
||||||
|
if (!application) {
|
||||||
|
throw new ExpectedError(`Error: fleet ${params.fleet} not found.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cmdOutput = await balena.models.release.getAllByApplication(
|
||||||
|
params.fleet,
|
||||||
|
{
|
||||||
|
$select: [
|
||||||
|
'commit',
|
||||||
|
'end_timestamp',
|
||||||
|
'raw_version',
|
||||||
|
'is_final',
|
||||||
|
'is_invalidated',
|
||||||
|
],
|
||||||
|
$expand: { is_running_on__device: { $count: {} } },
|
||||||
|
},
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
getVisuals().table.horizontal(cmdOutput, [
|
||||||
|
'commit',
|
||||||
|
'end_timestamp',
|
||||||
|
'raw_version',
|
||||||
|
'is_final',
|
||||||
|
'is_invalidated',
|
||||||
|
'is_running_on__device => RUNNING ON',
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user