-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Josh Dolitsky <josh@dolit.ski>
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash -ex | ||
|
||
# Copyright The ORAS Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
cd $DIR/../ | ||
|
||
LOCAL_REGISTRY_HOSTNAME="${LOCAL_REGISTRY_HOSTNAME:-localhost}" | ||
|
||
# Cleanup from previous runs | ||
rm -f hello.txt | ||
rm -f bin/oras-acceptance || true | ||
docker rm -f oras-acceptance-registry || true | ||
|
||
# Build the example into a binary | ||
CGO_ENABLED=0 go build -v -o bin/oras-acceptance ./examples/ | ||
|
||
# Run a test registry and expose at localhost:5000 | ||
trap "docker rm -f oras-acceptance-registry" EXIT | ||
docker run -d -p 5000:5000 \ | ||
--name oras-acceptance-registry \ | ||
index.docker.io/registry | ||
|
||
# Wait for a connection to port 5000 (timeout after 1 minute) | ||
WAIT_TIME=0 | ||
while true; do | ||
if nc -w 1 -z "${LOCAL_REGISTRY_HOSTNAME}" 5000; then | ||
echo "Able to connect to ${LOCAL_REGISTRY_HOSTNAME} port 5000" | ||
break | ||
else | ||
if (( ${WAIT_TIME} >= 60 )); then | ||
echo "Timed out waiting for connection to ${LOCAL_REGISTRY_HOSTNAME} on port 5000. Exiting." | ||
exit 1 | ||
fi | ||
echo "Waiting to connect to ${LOCAL_REGISTRY_HOSTNAME} on port 5000. Sleeping 5 seconds.." | ||
sleep 5 | ||
WAIT_TIME=$((WAIT_TIME + 5)) | ||
fi | ||
done | ||
|
||
# Wait another 5 seconds for good measure | ||
sleep 5 | ||
|
||
# Run the example binary | ||
bin/oras-acceptance | ||
|
||
# Ensure hello.txt exists and contains expected content | ||
grep '^Hello World!$' hello.txt |