generate-dockerfile-links-partial.tmpl 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {{- /*
  2. This template defines the "Supported tags and Dockerfile links" portion of an image description.
  3. */ -}}
  4. {{- $archSpecific := getenv "ARCH_SPECIFIC_DOCS" -}}
  5. {{- $sharedTagGroups := .Manifest.GetSharedTagGroups -}}
  6. {{- if (len $sharedTagGroups) -}}
  7. (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).)
  8. {{- "\n\n" -}}
  9. ## Simple Tags
  10. {{- "\n\n" -}}
  11. {{- end -}}
  12. {{- range $i, $e := ($archSpecific | ternary (archFilter arch $.Entries) $.Entries) -}}
  13. {{- $arch := $archSpecific | ternary arch ($e.HasArchitecture arch | ternary arch ($e.Architectures | first)) -}}
  14. {{- /* force bashbrew to "fetch" the GitCommit so that it is fully resolved */ -}}
  15. {{- $froms := $.ArchDockerFroms $arch $e -}}
  16. {{- $gitRepo := $e.ArchGitRepo $arch -}}
  17. {{- $gitCommit := $e.ArchGitCommit $arch -}}
  18. {{- $dir := .ArchDirectory $arch -}}
  19. {{- $dockerfile := .ArchFile $arch -}}
  20. {{- $dockerfilePath := eq $dir "." | ternary $dockerfile (join "/" $dir $dockerfile) -}}
  21. {{- $repoUrlBase := $gitRepo | replace "git://" "https://" | trimSuffixes ".git" -}}
  22. {{- $url := hasPrefix "https://github.com/" $repoUrlBase | ternary (join "/" $repoUrlBase "blob" $gitCommit $dockerfilePath) "" -}}
  23. {{- /* handle https://gitlab.../.../... style URLs (by reasonably assuming they're a gitlab instance) */ -}}
  24. {{- $url = $url | ternary $url (hasPrefix "https://gitlab." $repoUrlBase | ternary (join "/" $repoUrlBase "-/blob" $gitCommit $dockerfilePath) "") -}}
  25. {{- /* handle https://git.launchpad.net/ URLs */ -}}
  26. {{- $url = $url | ternary $url (hasPrefix "https://git.launchpad.net/" $repoUrlBase | ternary (print $repoUrlBase "/tree/" $dockerfilePath "?h=" ($e.ArchGitFetch $arch) "&id=" $gitCommit) "") -}}
  27. {{- /* TODO decide what to do (if anything) about other non-GitHub repos with respect to URL */ -}}
  28. - {{- "\t" -}}
  29. {{- if $url -}} [ {{- end -}}
  30. ` {{- $e.Tags | join "`, `" -}} `
  31. {{- if $url -}} ]( {{- $url -}} ) {{- end -}}
  32. {{- "\n\n" -}}
  33. {{- end -}}
  34. {{- if (len $sharedTagGroups) -}}
  35. {{- "## Shared Tags\n\n" -}}
  36. {{- range $sharedTagGroups -}}
  37. {{- $entries := $archSpecific | ternary (archFilter arch .Entries) .Entries -}}
  38. {{- if (len $entries) -}}
  39. {{- "-\t`" -}}
  40. {{ .SharedTags | join "`, `" }}
  41. {{- "`:\n\n" -}}
  42. {{- range $i, $e := $entries -}}
  43. {{- $arch := $archSpecific | ternary arch ($e.HasArchitecture arch | ternary arch ($e.Architectures | first)) -}}
  44. {{- /* force bashbrew to "fetch" the GitCommit so that it is fully resolved */ -}}
  45. {{- $froms := $.ArchDockerFroms $arch $e -}}
  46. {{- $gitRepo := $e.ArchGitRepo $arch -}}
  47. {{- $gitCommit := $e.ArchGitCommit $arch -}}
  48. {{- $dir := .ArchDirectory $arch -}}
  49. {{- $dockerfile := .ArchFile $arch -}}
  50. {{- $dockerfilePath := eq $dir "." | ternary $dockerfile (join "/" $dir $dockerfile) -}}
  51. {{- $repoUrlBase := $gitRepo | replace "git://" "https://" | trimSuffixes ".git" -}}
  52. {{- $url := hasPrefix "https://github.com/" $repoUrlBase | ternary (join "/" $repoUrlBase "blob" $gitCommit $dockerfilePath) "" -}}
  53. {{- /* handle https://gitlab.../.../... style URLs (by reasonably assuming they're a gitlab instance) */ -}}
  54. {{- $url = $url | ternary $url (hasPrefix "https://gitlab." $repoUrlBase | ternary (join "/" $repoUrlBase "-/blob" $gitCommit $dockerfilePath) "") -}}
  55. {{- /* handle https://git.launchpad.net/ URLs */ -}}
  56. {{- $url = $url | ternary $url (hasPrefix "https://git.launchpad.net/" $repoUrlBase | ternary (print $repoUrlBase "/tree/" $dockerfilePath "?h=" ($e.ArchGitFetch $arch) "&id=" $gitCommit) "") -}}
  57. {{- /* TODO decide what to do (if anything) about other non-GitHub repos with respect to URL */ -}}
  58. {{- "\t-\t" -}}
  59. {{- if $url -}} [ {{- end -}}
  60. ` {{- $e.Tags | first -}} `
  61. {{- if $url -}} ]( {{- $url -}} ) {{- end -}}
  62. {{- "\n" -}}
  63. {{- end -}}
  64. {{- "\n" -}}
  65. {{- end -}}
  66. {{- end -}}
  67. {{- "\n" -}}
  68. {{- end -}}