-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathdocker-tags.ts
54 lines (43 loc) · 1.41 KB
/
docker-tags.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// eslint-disable-next-line import/extensions
import dockerContainerConfig from '../docker/containers.json'
export const PROXY_IMAGE_NAME = dockerContainerConfig.proxy
export function updaterImageName(packageManager: string): string {
return dockerContainerConfig[
packageManager as keyof typeof dockerContainerConfig
]
}
const updaterRegex = /ghcr.io\/dependabot\/dependabot-updater-([\w+])/
export function updaterImages(): string[] {
return Object.values(dockerContainerConfig).filter(image =>
image.match(updaterRegex)
)
}
const imageNamePattern =
'^(?<repository>(([a-zA-Z0-9._-]+([:[0-9]+[^/]))?([a-zA-Z0-9._/-]+)?))(:[a-zA-Z0-9._/-]+)?(?<digest>@sha256:[a-zA-Z0-9]{64})?$'
export function repositoryName(imageName: string): string {
const match = imageName.match(imageNamePattern)
if (match?.groups) {
return match.groups['repository']
} else {
throw Error('invalid image name')
}
}
export function hasDigest(imageName: string): boolean {
const match = imageName.match(imageNamePattern)
if (match?.groups) {
if (match?.groups['digest']) {
return true
}
return false
} else {
throw Error('invalid image name')
}
}
export function digestName(imageName: string): string {
const match = imageName.match(imageNamePattern)
if (match?.groups) {
return match.groups['repository'] + match.groups['digest']
} else {
throw Error('invalid image name')
}
}