mirror of
https://github.com/docker/docs.git
synced 2026-03-27 14:28:47 +07:00
fetch-upstream-resources: simplify parsing of _config.yml
This part of the script was setting variables for any "_version" property in the configuration file. We (currently) only need the engine API version, so simplifying the code to just do that, and fix some spaces -> tabs indentations. With this change the script only uses standard (POSIX) scripting, so switching to use the standard (/bin/sh) shell. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -74,7 +74,7 @@ COPY ./_scripts/fetch-upstream-resources.sh ./_scripts/
|
||||
# TODO find a different mechanism for substituting the API version, to prevent invalidating the cache
|
||||
COPY ./_config.yml .
|
||||
COPY ./_data/toc.yaml ./_data/
|
||||
RUN bash ./_scripts/fetch-upstream-resources.sh .
|
||||
RUN ./_scripts/fetch-upstream-resources.sh .
|
||||
|
||||
|
||||
# Build the static HTML for the current docs.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
# Fetches upstream resources from docker/docker and docker/distribution
|
||||
# before handing off the site to Jekyll to build
|
||||
@@ -10,29 +10,19 @@
|
||||
# Helper function to deal with sed differences between osx and Linux
|
||||
# See https://stackoverflow.com/a/38595160
|
||||
sedi () {
|
||||
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@"
|
||||
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@"
|
||||
}
|
||||
|
||||
# Do some sanity-checking to make sure we are running this from the right place
|
||||
if ! [ -f _config.yml ]; then
|
||||
echo "Could not find _config.yml. We may not be in the right place. Bailing."
|
||||
exit 1
|
||||
echo "Could not find _config.yml. We may not be in the right place. Bailing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Parse some variables from _config.yml and make them available to this script
|
||||
# This only finds top-level variables with _version in them that don't have any
|
||||
# leading space. This is brittle!
|
||||
|
||||
while read i; do
|
||||
# Store the key as a variable name and the value as the variable value
|
||||
varname=$(echo "$i" | sed 's/"//g' | awk -F ':' {'print $1'} | tr -d '[:space:]')
|
||||
varvalue=$(echo "$i" | sed 's/"//g' | awk -F ':' {'print $2'} | tr -d '[:space:]')
|
||||
echo "Setting \$${varname} to $varvalue"
|
||||
declare "$varname=$varvalue"
|
||||
done < <(cat ./_config.yml |grep '_version:' |grep '^[a-z].*')
|
||||
|
||||
# Replace variable in toc.yml with value from above
|
||||
sedi "s/{{ site.latest_engine_api_version }}/$latest_engine_api_version/g" ./_data/toc.yaml
|
||||
# Parse latest_engine_api_version variables from _config.yml to replace the value
|
||||
# in toc.yaml. This is brittle!
|
||||
latest_engine_api_version="$(grep 'latest_engine_api_version:' ./_config.yml | grep -oh '"[0-9].*"$' | sed 's/"//g')"
|
||||
sedi "s/{{ site.latest_engine_api_version }}/${latest_engine_api_version}/g" ./_data/toc.yaml
|
||||
|
||||
# Translate branches for use by svn
|
||||
engine_svn_branch="branches/${ENGINE_BRANCH}"
|
||||
|
||||
Reference in New Issue
Block a user