Skip to content

Commit

Permalink
Merge pull request #321 from headwaymaps/mkirk/configure-link-configu…
Browse files Browse the repository at this point in the history
…ration

dynamic/k8s configuration for about and contact links
  • Loading branch information
michaelkirk authored Feb 7, 2024
2 parents c9886a2 + 77076a0 commit 2b850ab
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ HEADWAY_PUBLIC_URL=http://127.0.0.1:8080

HEADWAY_HTTP_PORT=8080

HEADWAY_ABOUT_URL="https://about.maps.earth"
HEADWAY_ABOUT_LINK_TEXT="About maps.earth"
HEADWAY_CONTACT_URL="mailto:[email protected]?subject=Hello,%20Earth"
HEADWAY_CONTACT_LINK_TEXT="Contact Us"

##
# The following are only needed for the scripts in bin/*
# If you're not using them, we can leave these blank.
Expand Down
4 changes: 4 additions & 0 deletions builds/planet/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export HEADWAY_ENABLE_TRANSIT_ROUTING=1
export HEADWAY_TRANSIT_AREAS="Barcelona LosAngeles PugetSound"
export PELIAS_ELASTICSEARCH_MEMORY_REQUEST=8Gi
export VALHALLA_MEMORY_REQUEST=4Gi
export HEADWAY_ABOUT_URL="https://about.maps.earth"
export HEADWAY_ABOUT_LINK_TEXT="About maps.earth"
export HEADWAY_CONTACT_URL="mailto:[email protected]?subject=Hello,%20Earth"
export HEADWAY_CONTACT_LINK_TEXT="Contact Us"
4 changes: 4 additions & 0 deletions builds/seattle/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export HEADWAY_TRANSIT_AREAS=Seattle
export HEADWAY_BBOX="-122.462 47.394 -122.005 47.831"
export PELIAS_ELASTICSEARCH_MEMORY_REQUEST=750Mi
export VALHALLA_MEMORY_REQUEST=250Mi
export HEADWAY_ABOUT_URL="https://about.maps.earth"
export HEADWAY_ABOUT_LINK_TEXT="About maps.earth"
export HEADWAY_CONTACT_URL="mailto:[email protected]?subject=Hello,%20Earth"
export HEADWAY_CONTACT_LINK_TEXT="Contact Us"
4 changes: 4 additions & 0 deletions k8s/_template/deployment-config.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ data:
public-url: ${HEADWAY_PUBLIC_URL}
bbox: "${HEADWAY_BBOX}"
enable-transit-routing: "${HEADWAY_ENABLE_TRANSIT_ROUTING}"
www-about-url: "${HEADWAY_ABOUT_URL}"
www-about-link-text: "${HEADWAY_ABOUT_LINK_TEXT}"
www-contact-url: "${HEADWAY_CONTACT_URL}"
www-contact-link-text: "${HEADWAY_CONTACT_LINK_TEXT}"
terrain-source-url: ${HEADWAY_K8S_ARTIFACT_ROOT}/${HEADWAY_DATA_TAG}/terrain.mbtiles
landcover-source-url: ${HEADWAY_K8S_ARTIFACT_ROOT}/${HEADWAY_DATA_TAG}/landcover.mbtiles
areamap-source-url: ${HEADWAY_K8S_ARTIFACT_ROOT}/${HEADWAY_DATA_TAG}/${HEADWAY_AREA_TAG}/${HEADWAY_AREA}.mbtiles
Expand Down
20 changes: 20 additions & 0 deletions k8s/_template/frontend-deployment.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ spec:
configMapKeyRef:
name: deployment-config
key: enable-transit-routing
- name: HEADWAY_ABOUT_URL
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-about-url
- name: HEADWAY_ABOUT_LINK_TEXT
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-about-link-text
- name: HEADWAY_CONTACT_URL
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-contact-url
- name: HEADWAY_CONTACT_LINK_TEXT
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-contact-link-text
resources:
limits:
memory: 100Mi
Expand Down
4 changes: 4 additions & 0 deletions k8s/configs/planet-dev/deployment-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ data:
public-url: https://maps.earth
bbox: ""
enable-transit-routing: "1"
www-about-url: "https://about.maps.earth"
www-about-link-text: "About maps.earth"
www-contact-url: "mailto:[email protected]?subject=Hello,%20Earth"
www-contact-link-text: "Contact Us"
terrain-source-url: https://data.example.com/0.6.0/terrain.mbtiles
landcover-source-url: https://data.example.com/0.6.0/landcover.mbtiles
areamap-source-url: https://data.example.com/0.6.0/maps-earth-planet-v1.36/maps-earth-planet-v1.36.mbtiles
Expand Down
20 changes: 20 additions & 0 deletions k8s/configs/planet-dev/frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ spec:
configMapKeyRef:
name: deployment-config
key: enable-transit-routing
- name: HEADWAY_ABOUT_URL
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-about-url
- name: HEADWAY_ABOUT_LINK_TEXT
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-about-link-text
- name: HEADWAY_CONTACT_URL
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-contact-url
- name: HEADWAY_CONTACT_LINK_TEXT
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-contact-link-text
resources:
limits:
memory: 100Mi
Expand Down
4 changes: 4 additions & 0 deletions k8s/configs/planet/deployment-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ data:
public-url: https://maps.earth
bbox: ""
enable-transit-routing: "1"
www-about-url: "https://about.maps.earth"
www-about-link-text: "About maps.earth"
www-contact-url: "mailto:[email protected]?subject=Hello,%20Earth"
www-contact-link-text: "Contact Us"
terrain-source-url: https://data.example.com/0.6.0/terrain.mbtiles
landcover-source-url: https://data.example.com/0.6.0/landcover.mbtiles
areamap-source-url: https://data.example.com/0.6.0/maps-earth-planet-v1.36/maps-earth-planet-v1.36.mbtiles
Expand Down
20 changes: 20 additions & 0 deletions k8s/configs/planet/frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ spec:
configMapKeyRef:
name: deployment-config
key: enable-transit-routing
- name: HEADWAY_ABOUT_URL
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-about-url
- name: HEADWAY_ABOUT_LINK_TEXT
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-about-link-text
- name: HEADWAY_CONTACT_URL
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-contact-url
- name: HEADWAY_CONTACT_LINK_TEXT
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-contact-link-text
resources:
limits:
memory: 100Mi
Expand Down
4 changes: 4 additions & 0 deletions k8s/configs/seattle-dev/deployment-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ data:
public-url: https://seattle.maps.earth
bbox: "-122.462 47.394 -122.005 47.831"
enable-transit-routing: "1"
www-about-url: "https://about.maps.earth"
www-about-link-text: "About maps.earth"
www-contact-url: "mailto:[email protected]?subject=Hello,%20Earth"
www-contact-link-text: "Contact Us"
terrain-source-url: https://data.example.com/dev/terrain.mbtiles
landcover-source-url: https://data.example.com/dev/landcover.mbtiles
areamap-source-url: https://data.example.com/dev/seattle-latest/Seattle.mbtiles
Expand Down
20 changes: 20 additions & 0 deletions k8s/configs/seattle-dev/frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ spec:
configMapKeyRef:
name: deployment-config
key: enable-transit-routing
- name: HEADWAY_ABOUT_URL
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-about-url
- name: HEADWAY_ABOUT_LINK_TEXT
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-about-link-text
- name: HEADWAY_CONTACT_URL
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-contact-url
- name: HEADWAY_CONTACT_LINK_TEXT
valueFrom:
configMapKeyRef:
name: deployment-config
key: www-contact-link-text
resources:
limits:
memory: 100Mi
Expand Down
34 changes: 31 additions & 3 deletions services/frontend/generate_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Examples:
EOS
}

if [ ! -z "$HEADWAY_BBOX" ]; then
if [ -n "$HEADWAY_BBOX" ]; then
# remove leading and trailing space, then comma separate
comma_seperated_bounds=$(echo $HEADWAY_BBOX | sed 's/^ *//' | sed 's/ *$//' | sed 's/ */,/g')
comma_seperated_bounds=$(echo "$HEADWAY_BBOX" | sed 's/^ *//' | sed 's/ *$//' | sed 's/ */,/g')
bbox_json="[${comma_seperated_bounds}]"
else
bbox_json="null"
Expand All @@ -39,10 +39,38 @@ else
transit_routing_enabled_json="true"
fi

if [[ -z "$HEADWAY_ABOUT_URL" ]]; then
about_url_json="null"
else
about_url_json="\"$HEADWAY_ABOUT_URL\""
fi

if [[ -z "$HEADWAY_ABOUT_LINK_TEXT" ]]; then
about_link_text_json="null"
else
about_link_text_json="\"$HEADWAY_ABOUT_LINK_TEXT\""
fi

if [[ -z "$HEADWAY_CONTACT_URL" ]]; then
contact_url_json="null"
else
contact_url_json="\"$HEADWAY_CONTACT_URL\""
fi

if [[ -z "$HEADWAY_CONTACT_LINK_TEXT" ]]; then
contact_link_text_json="null"
else
contact_link_text_json="\"$HEADWAY_CONTACT_LINK_TEXT\""
fi

cat << EOS
{
"maxBounds": $bbox_json,
"transitRoutingEnabled": $transit_routing_enabled_json
"transitRoutingEnabled": $transit_routing_enabled_json,
"aboutUrl": $about_url_json,
"aboutLinkText": $about_link_text_json,
"contactUrl": $contact_url_json,
"contactLinkText": $contact_link_text_json
}
EOS

0 comments on commit 2b850ab

Please sign in to comment.