rmetzger commented on a change in pull request #31:
URL: https://github.com/apache/flink-docker/pull/31#discussion_r461573130
##########
File path: generate-stackbrew-library.sh
##########
@@ -41,21 +36,39 @@ dirCommit() {
)
}
-getArches() {
- local repo="$1"; shift
- local
officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
+# Inputs:
+# - tags: comma-seprated list of image tags
+# - latestVersion: latest version
+# Output: comma-separated list of tags with "latest" removed if not latest
version
+pruneTags() {
+ local inTagsString=$1
+ local latestVersion=$2
+ if [[ $inTagsString =~ $latestVersion ]]; then
+ # tagsString contains latest version. keep "latest" tag
+ echo $inTagsString
+ else
+ # split list of tags, remove anything containing "latest"
+ IFS=', ' read -r -a inTags <<< "$inTagsString"
+ local outString=""
+ for inTag in "${inTags[@]}"; do
Review comment:
Yeah, you are right. Regex can do the job here as well. After a few
hours of bash scripting, your brain is sometimes trying to make a problem seem
extra complicated :)
##########
File path: generate-stackbrew-library.sh
##########
@@ -41,21 +36,39 @@ dirCommit() {
)
}
-getArches() {
- local repo="$1"; shift
- local
officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
+# Inputs:
+# - tags: comma-seprated list of image tags
+# - latestVersion: latest version
+# Output: comma-separated list of tags with "latest" removed if not latest
version
+pruneTags() {
+ local inTagsString=$1
+ local latestVersion=$2
+ if [[ $inTagsString =~ $latestVersion ]]; then
+ # tagsString contains latest version. keep "latest" tag
+ echo $inTagsString
+ else
+ # split list of tags, remove anything containing "latest"
+ IFS=', ' read -r -a inTags <<< "$inTagsString"
+ local outString=""
+ for inTag in "${inTags[@]}"; do
+ if [[ $inTag =~ $PRUNE_FROM_NON_LATEST_VERSION ]]; then
+ continue;
+ fi
+ outString="$outString, $inTag"
+ done
+ echo ${outString:2}
+ fi
+}
- eval "declare -g -A parentRepoToArches=( $(
- find -name 'Dockerfile' -exec awk '
- toupper($1) == "FROM" && $2 !~
/^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
- print "'"$officialImagesUrl"'" $2
- }
- ' '{}' + \
- | sort -u \
- | xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName
}}]="{{ join " " .TagEntry.Architectures }}"'
- ) )"
+extractValue() {
+ local key="$1"
+ local file="$2"
+ local line=$(cat $file | grep "$key:")
+ echo $line | cut -d ':' -f 2 | xargs # remove key from line, remove
whitespace
Review comment:
I took xargs because it does not remove "internal" whitespaces (in the
value). However, xargs replaces double whitespaces with a single whitespace ...
so my whole intention of not modifying the value itself is gone anyways. I'll
use `tr`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]