Share Fastly and Netlify redirects (#5619)

* consolidate netlify and fastly redirects

* remove validation check to support full url redirects
This commit is contained in:
Alvin Huang 2019-04-15 14:56:53 -04:00 committed by GitHub
parent 97104fb832
commit 2da7967106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 17 deletions

View File

@ -7,7 +7,7 @@ activate :hashicorp do |h|
end
# Netlify redirects/headers
proxy '_redirects', 'netlify-redirects', ignore: true
proxy '_redirects', 'redirects.txt', ignore: true
helpers do
# Returns a segment tracking ID such that local development is not

View File

@ -5,6 +5,7 @@ PROJECT="consul"
PROJECT_URL="www.consul.io"
FASTLY_SERVICE_ID="7GrxRJP3PVBuqQbyxYQ0MV"
FASTLY_DICTIONARY_ID="7d0yAgSHAQ2efWKeUC3kqW"
REDIRECTS_FILE="./source/redirects.txt"
# Ensure the proper AWS environment variables are set
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
@ -95,7 +96,8 @@ if [ -z "$NO_UPLOAD" ]; then
fi
# Add redirects if they exist
if [ -z "$NO_REDIRECTS" ] || [ ! test -f "./redirects.txt" ]; then
# The redirects file is in the source/ directory
if [ -z "$NO_REDIRECTS" ] || [ ! test -f $REDIRECTS_FILE ]; then
echo "Adding redirects..."
fields=()
while read -r line; do
@ -105,7 +107,7 @@ if [ -z "$NO_REDIRECTS" ] || [ ! test -f "./redirects.txt" ]; then
# Read fields
IFS=" " read -ra parts <<<"$line"
fields+=("${parts[@]}")
done < "./redirects.txt"
done < REDIRECTS_FILE
# Check we have pairs
if [ $((${#fields[@]} % 2)) -ne 0 ]; then
@ -126,11 +128,6 @@ if [ -z "$NO_REDIRECTS" ] || [ ! test -f "./redirects.txt" ]; then
echo "'$field' is > 256 characters!"
exit 1
fi
if [ "${field:0:1}" != "/" ]; then
echo "'$field' does not start with /!"
exit 1
fi
done
# Build the payload for single-request updates.

View File

@ -1,13 +1,13 @@
# Consul Redirects
/api.html /api/index.html
/api/acl.html /api/acl/acl.html
/docs/agent/acl-rules.html /docs/acl/acl-rules.html
/docs/agent/acl-system.html /docs/acl/acl-system.html
/docs/agent/http.html /api/index.html
/docs/guides/acl-legacy.html /docs/acl/acl-legacy.html
/docs/guides/acl-migrate-acl-tokens.html /docs/acl/acl-migrate-acl-tokens.html
/docs/guides/bootstrapping.html /docs/install/bootstrapping.html
/docs/guides/sentinel.html /docs/agent/sentinel.html
/api.html https://www.consul.io/api/index.html
/api/acl.html https://www.consul.io/api/acl/acl.html
/docs/agent/acl-rules.html https://www.consul.io/docs/acl/acl-rules.html
/docs/agent/acl-system.html https://www.consul.io/docs/acl/acl-system.html
/docs/agent/http.html https://www.consul.io/api/index.html
/docs/guides/acl-legacy.html https://www.consul.io/docs/acl/acl-legacy.html
/docs/guides/acl-migrate-acl-tokens.html https://www.consul.io/docs/acl/acl-migrate-acl-tokens.html
/docs/guides/bootstrapping.html https://www.consul.io/docs/install/bootstrapping.html
/docs/guides/sentinel.html https://www.consul.io/docs/agent/sentinel.html
# Consul Learn Redirects
/docs/guides/acl.html https://learn.hashicorp.com/consul/advanced/day-1-operations/acl-guide