Merge pull request #1286 from infosiftr/archFilter

Implement "archFilter" to fix arch-specific "Shared Tags" lists
This commit is contained in:
yosifkit 2018-08-23 13:29:01 -07:00 committed by GitHub
commit 35942faa57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 38 deletions

View File

@ -11,10 +11,9 @@ This template defines the "Supported tags and Dockerfile links" portion of an im
{{- "## Simple Tags\n\n" -}} {{- "## Simple Tags\n\n" -}}
{{- end -}} {{- end -}}
{{- range $i, $e := $.Entries -}} {{- range $i, $e := ($archSpecific | ternary (archFilter arch $.Entries) $.Entries) -}}
{{- $arch := $archSpecific | ternary arch ($e.HasArchitecture arch | ternary arch ($e.Architectures | first)) -}} {{- $arch := $archSpecific | ternary arch ($e.HasArchitecture arch | ternary arch ($e.Architectures | first)) -}}
{{- if $e.HasArchitecture $arch -}}
{{- /* force bashbrew to "fetch" the GitCommit so that it is fully resolved */ -}} {{- /* force bashbrew to "fetch" the GitCommit so that it is fully resolved */ -}}
{{- $from := $.ArchDockerFrom $arch $e -}} {{- $from := $.ArchDockerFrom $arch $e -}}
@ -35,20 +34,22 @@ This template defines the "Supported tags and Dockerfile links" portion of an im
{{- if $isGitHub -}} ]( {{- $repoUrlBase -}} /blob/ {{- $gitCommit -}} / {{- $dockerfilePath -}} ) {{- end -}} {{- if $isGitHub -}} ]( {{- $repoUrlBase -}} /blob/ {{- $gitCommit -}} / {{- $dockerfilePath -}} ) {{- end -}}
{{- /* TODO decide what to do (if anything) about non-GitHub repos with respect to URL */ -}} {{- /* TODO decide what to do (if anything) about non-GitHub repos with respect to URL */ -}}
{{- end -}} {{- end -}}
{{- end -}}
{{- "\n\n" -}} {{- "\n\n" -}}
{{- if (len $sharedTagGroups) -}} {{- if (len $sharedTagGroups) -}}
{{- "## Shared Tags\n\n" -}} {{- "## Shared Tags\n\n" -}}
{{- range $sharedTagGroups -}} {{- range $sharedTagGroups -}}
{{- $entries := $archSpecific | ternary (archFilter arch .Entries) .Entries -}}
{{- if (len $entries) -}}
{{- "-\t`" -}} {{- "-\t`" -}}
{{ .SharedTags | join "`, `" }} {{ .SharedTags | join "`, `" }}
{{- "`:\n" -}} {{- "`:\n" -}}
{{- range $i, $e := .Entries -}}
{{- range $i, $e := $entries -}}
{{- $arch := $archSpecific | ternary arch ($e.HasArchitecture arch | ternary arch ($e.Architectures | first)) -}} {{- $arch := $archSpecific | ternary arch ($e.HasArchitecture arch | ternary arch ($e.Architectures | first)) -}}
{{- if $e.HasArchitecture $arch -}}
{{- /* force bashbrew to "fetch" the GitCommit so that it is fully resolved */ -}} {{- /* force bashbrew to "fetch" the GitCommit so that it is fully resolved */ -}}
{{- $from := $.ArchDockerFrom $arch $e -}} {{- $from := $.ArchDockerFrom $arch $e -}}

View File

@ -42,14 +42,12 @@ fi
bashbrewFetchTemplate=' bashbrewFetchTemplate='
'"$templateHeader"' '"$templateHeader"'
{{- range $i, $e := $.Entries -}} {{- range $i, $e := ($archSpecific | ternary (archFilter arch $.Entries) $.Entries) -}}
'"$templateArchVar"' '"$templateArchVar"'
{{- if $e.HasArchitecture $arch -}}
{{- join "/" "refs/tags" $arch $.RepoName ($e.Tags | first) -}} {{- join "/" "refs/tags" $arch $.RepoName ($e.Tags | first) -}}
{{- ":" -}} {{- ":" -}}
{{- "\n" -}} {{- "\n" -}}
{{- end -}} {{- end -}}
{{- end -}}
' '
bashbrew cat --format "$bashbrewFetchTemplate" "$repo" \ bashbrew cat --format "$bashbrewFetchTemplate" "$repo" \

View File

@ -20,14 +20,10 @@ IFS=$'\n'
tags=( $(bashbrew cat -f ' tags=( $(bashbrew cat -f '
{{- $archSpecific := getenv "ARCH_SPECIFIC_DOCS" -}} {{- $archSpecific := getenv "ARCH_SPECIFIC_DOCS" -}}
{{- range .Entries -}} {{- range ($archSpecific | ternary (archFilter arch .Entries) .Entries) -}}
{{- $arch := $archSpecific | ternary arch (.HasArchitecture arch | ternary arch (.Architectures | first)) -}}
{{- if .HasArchitecture $arch -}}
{{- join "\n" .Tags -}} {{- join "\n" .Tags -}}
{{- "\n" -}} {{- "\n" -}}
{{- end -}} {{- end -}}
{{- end -}}
' "$repo") ) ' "$repo") )
unset IFS unset IFS