Add initial support for GitLab-hosted images

This was specifically tested against a modified `library/archlinux` file pointing at `GitRepo: https://gitlab.archlinux.org/archlinux/archlinux-docker.git`:

- [`latest`, `base`, `base-20201213.0.11146`](f70853f3a0/Dockerfile.base)
- [`base-devel`, `base-devel-20201213.0.11146`](f70853f3a0/Dockerfile.base-devel)
This commit is contained in:
Tianon Gravi 2020-12-21 16:35:34 -08:00
parent 2e9acbcc35
commit 47d155da7c
1 changed files with 20 additions and 16 deletions

View File

@ -21,22 +21,24 @@ This template defines the "Supported tags and Dockerfile links" portion of an im
{{- $froms := $.ArchDockerFroms $arch $e -}} {{- $froms := $.ArchDockerFroms $arch $e -}}
{{- $gitRepo := $e.ArchGitRepo $arch -}} {{- $gitRepo := $e.ArchGitRepo $arch -}}
{{- $gitCommit := $e.ArchGitCommit $arch -}}
{{- $dir := .ArchDirectory $arch -}}
{{- $dockerfile := .ArchFile $arch -}}
{{- $dockerfilePath := eq $dir "." | ternary $dockerfile (join "/" $dir $dockerfile) -}}
{{- $repoUrlBase := $gitRepo | replace "git://" "https://" | trimSuffixes ".git" -}} {{- $repoUrlBase := $gitRepo | replace "git://" "https://" | trimSuffixes ".git" -}}
{{- $isGitHub := hasPrefix "https://github.com/" $repoUrlBase -}} {{- $url := hasPrefix "https://github.com/" $repoUrlBase | ternary (join "/" $repoUrlBase "blob" $gitCommit $dockerfilePath) "" -}}
{{- /* handle https://gitlab.../.../... style URLs (by reasonably assuming they're a gitlab instance) */ -}}
{{- $url = $url | ternary $url (hasPrefix "https://gitlab." $repoUrlBase | ternary (join "/" $repoUrlBase "-/blob" $gitCommit $dockerfilePath) "") -}}
{{- /* TODO decide what to do (if anything) about other non-GitHub repos with respect to URL */ -}}
{{- if $i -}} {{- if $i -}}
{{- "\n" -}} {{- "\n" -}}
{{- end -}} {{- end -}}
- {{- "\t" -}} - {{- "\t" -}}
{{- if $isGitHub -}} [ {{- end -}} {{- if $url -}} [ {{- end -}}
{{- $dir := .ArchDirectory $arch -}}
{{- $dockerfile := .ArchFile $arch -}}
{{- $dockerfilePath := eq $dir "." | ternary $dockerfile (join "/" $dir $dockerfile) -}}
` {{- $e.Tags | join "`, `" -}} ` ` {{- $e.Tags | join "`, `" -}} `
{{- $gitCommit := $e.ArchGitCommit $arch -}} {{- if $url -}} ]( {{- $url -}} ) {{- end -}}
{{- if $isGitHub -}} ]( {{- $repoUrlBase -}} /blob/ {{- $gitCommit -}} / {{- $dockerfilePath -}} ) {{- end -}}
{{- /* TODO decide what to do (if anything) about non-GitHub repos with respect to URL */ -}}
{{- end -}} {{- end -}}
{{- "\n\n" -}} {{- "\n\n" -}}
@ -58,18 +60,20 @@ This template defines the "Supported tags and Dockerfile links" portion of an im
{{- $froms := $.ArchDockerFroms $arch $e -}} {{- $froms := $.ArchDockerFroms $arch $e -}}
{{- $gitRepo := $e.ArchGitRepo $arch -}} {{- $gitRepo := $e.ArchGitRepo $arch -}}
{{- $repoUrlBase := $gitRepo | replace "git://" "https://" | trimSuffixes ".git" -}} {{- $gitCommit := $e.ArchGitCommit $arch -}}
{{- $isGitHub := hasPrefix "https://github.com/" $repoUrlBase -}}
{{- "\t-\t" -}}
{{- if $isGitHub -}} [ {{- end -}}
{{- $dir := .ArchDirectory $arch -}} {{- $dir := .ArchDirectory $arch -}}
{{- $dockerfile := .ArchFile $arch -}} {{- $dockerfile := .ArchFile $arch -}}
{{- $dockerfilePath := eq $dir "." | ternary $dockerfile (join "/" $dir $dockerfile) -}} {{- $dockerfilePath := eq $dir "." | ternary $dockerfile (join "/" $dir $dockerfile) -}}
{{- $repoUrlBase := $gitRepo | replace "git://" "https://" | trimSuffixes ".git" -}}
{{- $url := hasPrefix "https://github.com/" $repoUrlBase | ternary (join "/" $repoUrlBase "blob" $gitCommit $dockerfilePath) "" -}}
{{- /* handle https://gitlab.../.../... style URLs (by reasonably assuming they're a gitlab instance) */ -}}
{{- $url = $url | ternary $url (hasPrefix "https://gitlab." $repoUrlBase | ternary (join "/" $repoUrlBase "-/blob" $gitCommit $dockerfilePath) "") -}}
{{- /* TODO decide what to do (if anything) about other non-GitHub repos with respect to URL */ -}}
{{- "\t-\t" -}}
{{- if $url -}} [ {{- end -}}
` {{- $e.Tags | first -}} ` ` {{- $e.Tags | first -}} `
{{- $gitCommit := $e.ArchGitCommit $arch -}} {{- if $url -}} ]( {{- $url -}} ) {{- end -}}
{{- if $isGitHub -}} ]( {{- $repoUrlBase -}} /blob/ {{- $gitCommit -}} / {{- $dockerfilePath -}} ) {{- end -}}
{{- /* TODO decide what to do (if anything) about non-GitHub repos with respect to URL */ -}}
{{- "\n" -}} {{- "\n" -}}
{{- end -}} {{- end -}}