accept the incoming JSON config data

This commit is contained in:
Aidan Feldman 2016-03-10 03:57:41 -05:00
parent bfb34616f4
commit 5dcef5d5f1
4 changed files with 20 additions and 9 deletions

View file

@ -1,6 +1,3 @@
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup
AWS_ACCESS_KEY_ID=<key>
AWS_SECRET_ACCESS_KEY=<secret>
# exclude the `s3://` prefix/protocol
S3_BUCKET=<bucket name>

View file

@ -12,6 +12,9 @@ Requires Docker.
```bash
cp .env.example .env
# modify .env
./script/run /full/path/to/dir/or/file
# exclude the `s3://` prefix/protocol for the `bucket`
./script/run </full/path/to/dir/or/file> <bucket>
```

View file

@ -1,5 +1,7 @@
#!/bin/sh
# http://concourse.ci/implementing-resources.html#out:-update-a-resource.
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L4-L16
set -e
@ -14,9 +16,15 @@ if [ -z "$source" ]; then
fi
#######################################
# parse incoming config data
payload=`cat`
bucket=$(echo "$payload" | jq -r '.source.bucket')
echo "Uploading to S3..."
# credentials are provided via environment variables
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment
aws s3 sync $source "s3://$S3_BUCKET"
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

View file

@ -1,19 +1,22 @@
#!/bin/sh
set -e
set -x
source=$1
bucket=$2
if [ -z "$source" ]; then
echo "usage: $0 </full/path/to/dir/or/file>"
if [ -z "$source" ] || [ -z "$bucket" ]; then
echo "usage: $0 </full/path/to/dir/or/file> <bucket>"
exit 1
fi
docker build -t 18fgsa/s3-resource-simple .
docker run \
json="{\"source\": {\"bucket\": \"$bucket\"}}"
echo $json | docker run \
--env-file .env \
-i \
--rm \
-v $source:/tmp/input \
18fgsa/s3-resource-simple \