Browse Source

Style changes and only process dockerfiles from github.com

William Blankenship 10 years ago
parent
commit
d50d315308
1 changed files with 17 additions and 14 deletions
  1. 17 14
      .template-helpers/variant.sh

+ 17 - 14
.template-helpers/variant.sh

@@ -9,10 +9,10 @@ if [ -z "$repo" ]; then
 fi
 
 dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
-url='https://raw.githubusercontent.com/docker-library/official-images/master/library/'"$repo" 
+url='https://raw.githubusercontent.com/docker-library/official-images/master/library/'"$repo"
 
 IFS=$'\n'
-tags=( $(curl -sSL $url | grep -vE '^$|^#' | cut -d':' -f1 | sort -u) )
+tags=( $(curl -sSL "$url" | grep -vE '^$|^#' | cut -d':' -f1 | sort -u) )
 unset IFS
 
 text=
@@ -24,16 +24,19 @@ for tag in "${tags[@]}"; do
 	fi
 done
 if [ "$text" ]; then
-  latest=($(curl -sSL $url | sed -e 's/git:\/\/github.com\///' -e 's/@/ /' - | grep "latest"))
-  dockerfile='https://raw.githubusercontent.com/'"${latest[1]}"'/'"${latest[2]}"'/'"${latest[3]}"'/Dockerfile'
-  base_image=$(curl -sSL $dockerfile | sed 's/:/\t/' | nawk '/^FROM .*$/ { print $2 }')
-  # give a little space
-  echo
-  echo
-  if [ "$base_image" = "buildpack-deps" ]; then
-    cat "$dir/variant-buildpacks.md"
-  else
-    cat "$dir/variant.md"
-  fi
-  echo "$text"
+	latest=($(curl -sSL "$url" | grep "latest.*github.com" | sed -e 's!git://github.com/!!' -e 's/@/ /' -))
+	if [ -z "latest" ]; then
+		exit 0 # If not github or no latest tag, we are done here
+	fi
+	dockerfile='https://raw.githubusercontent.com/'"${latest[1]}"'/'"${latest[2]}"'/'"${latest[3]}"'/Dockerfile'
+	baseImage=$(curl -sSL $dockerfile | sed 's/:/\t/' | awk '$1 == "FROM" { print $2 }')
+	# give a little space
+	echo
+	echo
+	if [ "$baseImage" = "buildpack-deps" ]; then
+		cat "$dir/variant-buildpacks.md"
+	else
+		cat "$dir/variant.md"
+	fi
+	echo "$text"
 fi