generate-dockerfile-links-partial.tmpl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {{- /*
  2. This template defines the "Supported tags and Dockerfile links" portion of an image description.
  3. */ -}}
  4. {{- define "dockerfilePath" -}}
  5. {{- if ne .Directory "." -}}
  6. {{- .Directory -}}
  7. /
  8. {{- end -}}
  9. Dockerfile
  10. {{- end -}}
  11. {{- range $i, $e := $.Entries -}}
  12. {{- /* force bashbrew to "fetch" the GitCommit so that it is fully resolved */ -}}
  13. {{- $from := $.DockerFrom $e -}}
  14. {{- $repoUrlBase := $e.GitRepo | replace "git://" "https://" | trimSuffixes ".git" -}}
  15. {{- $isGitHub := hasPrefix "https://github.com/" $repoUrlBase -}}
  16. {{- if $i -}}
  17. {{- "\n" -}}
  18. {{- end -}}
  19. - {{- "\t" -}}
  20. {{- if $isGitHub -}} [ {{- end -}}
  21. ` {{- $e.Tags | join "`, `" -}} ` (* {{- template "dockerfilePath" $e -}} *)
  22. {{- if $isGitHub -}} ]( {{- $repoUrlBase -}} /blob/ {{- $e.GitCommit -}} / {{- template "dockerfilePath" $e -}} ) {{- end -}}
  23. {{- /* TODO decide what to do (if anything) about non-GitHub repos with respect to URL */ -}}
  24. {{- end -}}
  25. {{- "\n\n" -}}
  26. [![](
  27. {{- "https://badge.imagelayers.io/" -}}
  28. {{- /* either "repo:latest" or "repo:first-tag" */ -}}
  29. {{- printf "%s:%s" .RepoName (.Manifest.GetTag "latest" | ternary "latest" ((.Entries | first).Tags | first)) -}}
  30. {{- ".svg" -}}
  31. )](
  32. {{- "https://imagelayers.io/?images=" -}}
  33. {{- /* list all "repo:tag" combinations, comma separated */ -}}
  34. {{- range $i, $e := $.Entries -}}
  35. {{- if $i -}} , {{- end -}}
  36. {{- printf "%s:%s" $.RepoName ($e.Tags | first) -}}
  37. {{- end -}}
  38. )
  39. {{- "\n\n" -}}