Skip to content

Commit

Permalink
Attempt to determine registry service IP and port if not env var not set
Browse files Browse the repository at this point in the history
If the offline registry is started without the correct environment
variable, instead of failing to start, attempt to use k8s env vars to
determine the devfile registry's service ip and port.

This is fragile and experimental, so a warning is printed.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
  • Loading branch information
amisevsk committed Oct 7, 2019
1 parent b44ef22 commit 3a61f90
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions build/dockerfiles/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ if [ -n "$PUBLIC_URL" ]; then
echo "Updating devfiles to point at internal project zip files"
PUBLIC_URL=${PUBLIC_URL%/}
sed -i "s|{{ DEVFILE_REGISTRY_URL }}|${PUBLIC_URL}|" "${devfiles[@]}"
else
else
if grep -q '{{ DEVFILE_REGISTRY_URL }}' "${devfiles[@]}"; then
echo "This devfile registry was built for offline usage and will only function" \
"with environment variable 'PUBLIC_URL' set to the devfile registry's" \
"endpoint." >> /dev/stderr
exit 1
echo "WARNING: environment variable 'CHE_DEVFILE_HTTPS_ENDPOINT' not configured" \
"for an offline build of this registry. This may cause issues with importing" \
"projects in a workspace."
# Experimental workaround -- detect service IP for che-devfile-registry
# Depends on service used being named 'che-devfile-registry'
URL="http://${CHE_DEVFILE_REGISTRY_SERVICE_HOST}:${CHE_DEVFILE_REGISTRY_SERVICE_PORT}"
sed -i "s|{{ DEVFILE_REGISTRY_URL }}|${URL}|" "${devfiles[@]}"
fi
fi

Expand Down

0 comments on commit 3a61f90

Please sign in to comment.