-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSH: use the new container name format #2648
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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]*)?$/; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about v which is slightly stricter?
Suggested change
As far as I can tell though a user naming a service There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch, unfortunately that doesn't work either :(
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without lazy
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Testing alternatives There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, 'december_12_2023_11_22` matches both syntaxes name 'december_12' It also matches name 'december_12_2023' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect the first one is the least of evils as container names have a release commit for a while There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think @thgreasi ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively since at this point we alredy have access to the device, we could test depending on SV version, although that sounds a bit overkill particularly since we want the service name list just for the error message |
||||||
|
||||||
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')}` | ||||||
: '' | ||||||
}`, | ||||||
); | ||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about v ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not really an OR, it can have numeric ids, numeric ids with commit or just commit. I think I can merge the numeric matching though