mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
ssh: use the new container name format
The supervisor is changing the container name format from `<serviceName>_<imageId>_<releaseId>_<commit>` to `<serviceName>_<commit>`. This updates the SSH command to work with both formats. Change-type: minor Depends-on: balena-os/balena-supervisor#2136
This commit is contained in:
parent
d9fed9c34c
commit
d42812f202
@ -76,13 +76,21 @@ export async function getContainerIdForService(
|
||||
.filter((l) => l);
|
||||
|
||||
const { escapeRegExp } = await import('lodash');
|
||||
const regex = new RegExp(`(?:^|\\/)${escapeRegExp(opts.service)}_\\d+_\\d+`);
|
||||
const regex = new RegExp(
|
||||
`(?:^|\\/)${escapeRegExp(
|
||||
opts.service,
|
||||
)}_(?:\\d+_)?(?:\\d+_)?(?:[a-f0-9]*)?$`,
|
||||
);
|
||||
// Old balenaOS container name pattern:
|
||||
// main_1234567_2345678
|
||||
// New balenaOS container name patterns:
|
||||
// main_1234567_2345678_a000b111c222d333e444f555a666b777
|
||||
// main_1_1_localrelease
|
||||
const nameRegex = /(?:^|\/)([a-zA-Z0-9_-]+)_\d+_\d+(?:_.+)?$/;
|
||||
// Newer balenaOS container names just use commit
|
||||
// main_a000b111c222d333e444f555a666b777
|
||||
// main_10ca12e1ea5e
|
||||
const nameRegex =
|
||||
/(?:^|\/)([a-zA-Z0-9_-]+?)_(?:\d+_)?(?:\d+_)?(?:[a-f0-9]*)?$/;
|
||||
|
||||
const serviceNames: string[] = [];
|
||||
const containerNames: string[] = [];
|
||||
@ -116,7 +124,9 @@ export async function getContainerIdForService(
|
||||
throw new ExpectedError(
|
||||
`Could not find a container matching service name "${s}" on device "${d}".${
|
||||
serviceNames.length > 0
|
||||
? `\nAvailable services:\n\t${serviceNames.join('\n\t')}`
|
||||
? `\nAvailable services:\n\t${serviceNames
|
||||
.map((n) => `'${n}'`)
|
||||
.join('\n\t')}`
|
||||
: ''
|
||||
}`,
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user