add in
and check
scripts
`out` was failing without them
This commit is contained in:
parent
96314b8a7c
commit
f3ce24d31d
7 changed files with 88 additions and 4 deletions
|
@ -14,4 +14,4 @@ Requires Docker.
|
|||
1. Modify `config.json`.
|
||||
* See [the instructions for getting your AWS credentials](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup).
|
||||
* Exclude the `s3://` prefix/protocol for the `bucket`.
|
||||
1. Run `./script/run </full/path/to/dir/or/file>`.
|
||||
1. Run `./test/run </full/path/to/dir/or/file>`.
|
||||
|
|
11
assets/check
Executable file
11
assets/check
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
# http://concourse.ci/implementing-resources.html#resource-check
|
||||
|
||||
set -e
|
||||
|
||||
echo "[
|
||||
{
|
||||
\"timestamp\": \"foo\"
|
||||
}
|
||||
]"
|
40
assets/in
Executable file
40
assets/in
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
|
||||
# http://concourse.ci/implementing-resources.html#in:-fetch-a-given-resource.
|
||||
|
||||
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L4-L16
|
||||
set -e
|
||||
set -x
|
||||
|
||||
exec 3>&1 # make stdout available as fd 3 for the result
|
||||
exec 1>&2 # redirect all output to stderr for logging
|
||||
|
||||
dest=$1
|
||||
|
||||
if [ -z "$dest" ]; then
|
||||
echo "usage: $0 <path/to/volume>"
|
||||
exit 1
|
||||
fi
|
||||
#######################################
|
||||
|
||||
# parse incoming config data
|
||||
payload=`cat`
|
||||
bucket=$(echo "$payload" | jq -r '.source.bucket')
|
||||
|
||||
|
||||
echo "Downloading from S3..."
|
||||
|
||||
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment
|
||||
export AWS_ACCESS_KEY_ID=$(echo "$payload" | jq -r '.source.access_key_id')
|
||||
export AWS_SECRET_ACCESS_KEY=$(echo "$payload" | jq -r '.source.secret_access_key')
|
||||
|
||||
aws s3 sync "s3://$bucket" $dest
|
||||
|
||||
echo "...done."
|
||||
|
||||
|
||||
# use a hard-coded version, so that the check passes
|
||||
jq -n "{
|
||||
version: {
|
||||
timestamp: \"foo\"}
|
||||
}" >&3
|
|
@ -33,9 +33,8 @@ aws s3 sync $source "s3://$bucket"
|
|||
echo "...done."
|
||||
|
||||
|
||||
# use the current UNIX time as the version
|
||||
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L133-L136
|
||||
# use a hard-coded version, so that the check passes
|
||||
jq -n "{
|
||||
version: {
|
||||
timestamp: \"$(date +%s)\"}
|
||||
timestamp: \"foo\"}
|
||||
}" >&3
|
||||
|
|
13
test/check
Executable file
13
test/check
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
json=$(cat config.json)
|
||||
|
||||
docker build -t 18fgsa/s3-resource-simple .
|
||||
|
||||
echo $json | docker run \
|
||||
-i \
|
||||
--rm \
|
||||
18fgsa/s3-resource-simple \
|
||||
/opt/resource/check
|
21
test/in
Executable file
21
test/in
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
dest=$1
|
||||
|
||||
if [ -z "$dest" ]; then
|
||||
echo "usage: $0 </full/path/to/dest>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
json=$(cat config.json)
|
||||
|
||||
docker build -t 18fgsa/s3-resource-simple .
|
||||
|
||||
echo $json | docker run \
|
||||
-i \
|
||||
--rm \
|
||||
-v $dest:/tmp/output \
|
||||
18fgsa/s3-resource-simple \
|
||||
/opt/resource/in /tmp/output
|
Loading…
Reference in a new issue