Skip to content

Commit df9c88d

Browse files
authored
Merge pull request #1854 from infosiftr/gitlab
Add initial support for GitLab-hosted images
2 parents 3afa8d9 + 47d155d commit df9c88d

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

.template-helpers/generate-dockerfile-links-partial.tmpl

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,24 @@ This template defines the "Supported tags and Dockerfile links" portion of an im
2121
{{- $froms := $.ArchDockerFroms $arch $e -}}
2222

2323
{{- $gitRepo := $e.ArchGitRepo $arch -}}
24+
{{- $gitCommit := $e.ArchGitCommit $arch -}}
25+
{{- $dir := .ArchDirectory $arch -}}
26+
{{- $dockerfile := .ArchFile $arch -}}
27+
{{- $dockerfilePath := eq $dir "." | ternary $dockerfile (join "/" $dir $dockerfile) -}}
2428
{{- $repoUrlBase := $gitRepo | replace "git://" "https://" | trimSuffixes ".git" -}}
25-
{{- $isGitHub := hasPrefix "https://github.com/" $repoUrlBase -}}
29+
{{- $url := hasPrefix "https://github.com/" $repoUrlBase | ternary (join "/" $repoUrlBase "blob" $gitCommit $dockerfilePath) "" -}}
30+
{{- /* handle https://gitlab.../.../... style URLs (by reasonably assuming they're a gitlab instance) */ -}}
31+
{{- $url = $url | ternary $url (hasPrefix "https://gitlab." $repoUrlBase | ternary (join "/" $repoUrlBase "-/blob" $gitCommit $dockerfilePath) "") -}}
32+
{{- /* TODO decide what to do (if anything) about other non-GitHub repos with respect to URL */ -}}
2633

2734
{{- if $i -}}
2835
{{- "\n" -}}
2936
{{- end -}}
3037

3138
- {{- "\t" -}}
32-
{{- if $isGitHub -}} [ {{- end -}}
33-
{{- $dir := .ArchDirectory $arch -}}
34-
{{- $dockerfile := .ArchFile $arch -}}
35-
{{- $dockerfilePath := eq $dir "." | ternary $dockerfile (join "/" $dir $dockerfile) -}}
39+
{{- if $url -}} [ {{- end -}}
3640
` {{- $e.Tags | join "`, `" -}} `
37-
{{- $gitCommit := $e.ArchGitCommit $arch -}}
38-
{{- if $isGitHub -}} ]( {{- $repoUrlBase -}} /blob/ {{- $gitCommit -}} / {{- $dockerfilePath -}} ) {{- end -}}
39-
{{- /* TODO decide what to do (if anything) about non-GitHub repos with respect to URL */ -}}
41+
{{- if $url -}} ]( {{- $url -}} ) {{- end -}}
4042
{{- end -}}
4143
{{- "\n\n" -}}
4244

@@ -58,18 +60,20 @@ This template defines the "Supported tags and Dockerfile links" portion of an im
5860
{{- $froms := $.ArchDockerFroms $arch $e -}}
5961

6062
{{- $gitRepo := $e.ArchGitRepo $arch -}}
61-
{{- $repoUrlBase := $gitRepo | replace "git://" "https://" | trimSuffixes ".git" -}}
62-
{{- $isGitHub := hasPrefix "https://github.com/" $repoUrlBase -}}
63-
64-
{{- "\t-\t" -}}
65-
{{- if $isGitHub -}} [ {{- end -}}
63+
{{- $gitCommit := $e.ArchGitCommit $arch -}}
6664
{{- $dir := .ArchDirectory $arch -}}
6765
{{- $dockerfile := .ArchFile $arch -}}
6866
{{- $dockerfilePath := eq $dir "." | ternary $dockerfile (join "/" $dir $dockerfile) -}}
67+
{{- $repoUrlBase := $gitRepo | replace "git://" "https://" | trimSuffixes ".git" -}}
68+
{{- $url := hasPrefix "https://github.com/" $repoUrlBase | ternary (join "/" $repoUrlBase "blob" $gitCommit $dockerfilePath) "" -}}
69+
{{- /* handle https://gitlab.../.../... style URLs (by reasonably assuming they're a gitlab instance) */ -}}
70+
{{- $url = $url | ternary $url (hasPrefix "https://gitlab." $repoUrlBase | ternary (join "/" $repoUrlBase "-/blob" $gitCommit $dockerfilePath) "") -}}
71+
{{- /* TODO decide what to do (if anything) about other non-GitHub repos with respect to URL */ -}}
72+
73+
{{- "\t-\t" -}}
74+
{{- if $url -}} [ {{- end -}}
6975
` {{- $e.Tags | first -}} `
70-
{{- $gitCommit := $e.ArchGitCommit $arch -}}
71-
{{- if $isGitHub -}} ]( {{- $repoUrlBase -}} /blob/ {{- $gitCommit -}} / {{- $dockerfilePath -}} ) {{- end -}}
72-
{{- /* TODO decide what to do (if anything) about non-GitHub repos with respect to URL */ -}}
76+
{{- if $url -}} ]( {{- $url -}} ) {{- end -}}
7377

7478
{{- "\n" -}}
7579
{{- end -}}

0 commit comments

Comments
 (0)