-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(versioning/ubuntu): support suffixed codename versions (#33308)
Signed-off-by: ivan katliarchuk <[email protected]> Co-authored-by: Rhys Arkins <[email protected]>
- Loading branch information
1 parent
e9bc921
commit 2b2d306
Showing
3 changed files
with
161 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,40 @@ | ||
import { regEx } from '../../../util/regex'; | ||
|
||
const regex = regEx(/^(?<codename>\w+)-(?<date>\d{8})(?<suffix>\.\d{1,2})?$/); | ||
|
||
function isDatedCodeName(input: string): boolean { | ||
return regEx(/^(?<codename>\w+)-(?<date>\d{8})$/).test(input); | ||
return regex.test(input); | ||
} | ||
|
||
function getDatedContainerImageCodename(version: string): null | string { | ||
const groups = regEx(/^(?<codename>\w+)-(?<date>\d{8})$/).exec(version); | ||
const groups = regex.exec(version); | ||
if (!groups?.groups) { | ||
return null; | ||
} | ||
return groups.groups.codename; | ||
} | ||
|
||
function getDatedContainerImageVersion(version: string): null | number { | ||
const groups = regEx(/^(?<codename>\w+)-(?<date>\d{8})$/).exec(version); | ||
const groups = regex.exec(version); | ||
if (!groups?.groups) { | ||
return null; | ||
} | ||
|
||
return parseInt(groups.groups.date, 10); | ||
} | ||
|
||
function getDatedContainerImageSuffix(version: string): null | string { | ||
const groups = regex.exec(version); | ||
if (!groups?.groups?.suffix) { | ||
return null; | ||
} | ||
|
||
return groups.groups.suffix; | ||
} | ||
|
||
export { | ||
isDatedCodeName, | ||
getDatedContainerImageCodename, | ||
getDatedContainerImageVersion, | ||
getDatedContainerImageSuffix, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters