forked from docker-library/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-dockerfile-links-partial.tmpl
83 lines (66 loc) · 3.45 KB
/
generate-dockerfile-links-partial.tmpl
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{{- /*
This template defines the "Supported tags and Dockerfile links" portion of an image description.
*/ -}}
{{- $archSpecific := getenv "ARCH_SPECIFIC_DOCS" -}}
{{- $sharedTagGroups := .Manifest.GetSharedTagGroups -}}
{{- if (len $sharedTagGroups) -}}
(See ["What's the difference between 'Shared' and 'Simple' tags?" in the FAQ](https://github.com/docker-library/faq#whats-the-difference-between-shared-and-simple-tags).)
{{- "\n\n" -}}
## Simple Tags
{{- "\n\n" -}}
{{- end -}}
{{- range $i, $e := ($archSpecific | ternary (archFilter arch $.Entries) $.Entries) -}}
{{- $arch := $archSpecific | ternary arch ($e.HasArchitecture arch | ternary arch ($e.Architectures | first)) -}}
{{- /* force bashbrew to "fetch" the GitCommit so that it is fully resolved */ -}}
{{- $froms := $.ArchDockerFroms $arch $e -}}
{{- $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" -}}
{{- $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 -}}
{{- "\n" -}}
{{- end -}}
- {{- "\t" -}}
{{- if $url -}} [ {{- end -}}
` {{- $e.Tags | join "`, `" -}} `
{{- if $url -}} ]( {{- $url -}} ) {{- end -}}
{{- end -}}
{{- "\n\n" -}}
{{- if (len $sharedTagGroups) -}}
{{- "## Shared Tags\n\n" -}}
{{- range $sharedTagGroups -}}
{{- $entries := $archSpecific | ternary (archFilter arch .Entries) .Entries -}}
{{- if (len $entries) -}}
{{- "-\t`" -}}
{{ .SharedTags | join "`, `" }}
{{- "`:\n" -}}
{{- range $i, $e := $entries -}}
{{- $arch := $archSpecific | ternary arch ($e.HasArchitecture arch | ternary arch ($e.Architectures | first)) -}}
{{- /* force bashbrew to "fetch" the GitCommit so that it is fully resolved */ -}}
{{- $froms := $.ArchDockerFroms $arch $e -}}
{{- $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" -}}
{{- $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 -}} `
{{- if $url -}} ]( {{- $url -}} ) {{- end -}}
{{- "\n" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- "\n" -}}
{{- end -}}