diff --git a/NOTICE.md b/NOTICE.md new file mode 100644 index 0000000..80dc1a1 --- /dev/null +++ b/NOTICE.md @@ -0,0 +1,12 @@ +Copyright 2017 Luciano Silva + +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. diff --git a/README.md b/README.md index 851ec3e..6672b42 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,49 @@ -# Concourse CURL Resource +# File URL Resource -Retrieves artifacts from a repository using curl commands. +Downloads and tracks the update of a single URL-addressable file. +This is a useful resource for pipeline development time, while a required artifact is temporarily available from a URL-addressable location, until it is moved to a more robust file management repository such as [git](https://github.com/concourse/git-resource) or [S3](https://github.com/concourse/s3-resource). -##Work in progress - stay tuned +## Source Configuration + +* `url`: *Required.* The url location of the file. It has to be publicly available, no user authentication supported in v0.0.1. + +* `filename`: *Optional.* The name of the file for the downloaded artifact to be save as. If not provided, the file will be saved using the full url string as its name. + +* `skip_ssl_verification`: *Optional.* Skips ssl verification if defined as `true`. Default is `false`. + +### Example + +Resource configuration: + +``` yaml +resource_types: +- name: file-url + type: docker-image + source: + repository: pivotalservices/concourse-curl-resource + tag: latest + +resources: +- name: my-file + type: file-url + source: + url: https://raw.githubusercontent.com/pivotalservices/concourse-curl-resource/master/test/data/pivotal-1.0.0.txt + filename: pivotal-1.0.0.txt +``` + +## Behavior + +### `check`: Check for the latest version of the file. + +The resource uses `curl` under-the-covers to post a GET request and retrieve the HTTP header info for the file URL provided. +If field `Last-Modified` is returned as part of the HTTP response header, then the resource will use that to build a version number timestamp with format "YYYYMMDDHHMMSS". +Otherwise, the timestamp string will be built using the request's current time, which will result in a new version being returned every time `check` is executed for that file. + +### `in`: Download the latest version of the file. + +Downloads the latest version of the file issuing a `curl` command under-the-covers. + + +### `out`: Not supported. + +Write actions are not supported by this resource at this moment. diff --git a/assets/out b/assets/out index f8987c1..5d26eb3 100755 --- a/assets/out +++ b/assets/out @@ -5,19 +5,5 @@ set -e exec 3>&1 # make stdout available as fd 3 for the result exec 1>&2 # redirect all output to stderr for logging -source $(dirname $0)/common.sh - -source=$1 - -if [ -z "$source" ]; then - echo "usage: $0 " - exit 1 -fi - -cd $source - -payload=$(mktemp $TMPDIR/artifactory-resource-request.XXXXXX) - -cat > $payload <&0 - -cat $payload +echo "OUT action not supported by this resource" +exit 1 diff --git a/pipeline.yml b/pipeline.yml index 8e97a2a..d1441e5 100644 --- a/pipeline.yml +++ b/pipeline.yml @@ -1,21 +1,21 @@ resource_types: -- name: curl +- name: file-url type: docker-image source: repository: pivotalservices/concourse-curl-resource tag: latest resources: -- name: single-file - type: curl +- name: my-file + type: file-url source: - url: https://s3-us-west-1.amazonaws.com/lsilva-bpws/PCF_usage/pcf-sandbox-usage-from-2016-09-01-to-2016-09-30_1475771124.json - filename: pcf-sandbox.json + url: https://raw.githubusercontent.com/pivotalservices/concourse-curl-resource/master/test/data/pivotal-1.0.0.txt + filename: pivotal-1.0.0.txt jobs: - name: run-and-get-file plan: - - get: single-file + - get: my-file - task: run-and-get-file config: platform: linux @@ -25,7 +25,7 @@ jobs: repository: ubuntu tag: "latest" inputs: - - name: single-file + - name: my-file run: path: sh args: diff --git a/test/test-out.sh b/test/test-out.sh index 4ea08aa..7b4ff18 100755 --- a/test/test-out.sh +++ b/test/test-out.sh @@ -4,49 +4,4 @@ set -e source $(dirname $0)/helpers.sh -it_can_deploy_release_to_artifactory() { - - # local local_ip=$(find_docker_host_ip) - #local_ip=localhost - - artifactory_ip=$ART_IP - TMPDIR=/tmp - - local src=$(mktemp -d $TMPDIR/in-src.XXXXXX) - local endpoint="http://${artifactory_ip}:8081/artifactory" - local regex="ecd-front-(?.*).tar.gz" - local folder="/generic/ecd-front" - local version="20161109222826" - local username="${ART_USER}" - local password="${ART_PWD}" - - local repository="/generic/ecd-front" - local file="ecd-front-(?.*).tar.gz" - - local version=20161109222826 - - deploy_without_credentials $endpoint $regex $repository $file $version $src -} - -it_can_deploy_release_to_artifactory_with_credentials() { - - artifactory_ip=$ART_IP - TMPDIR=/tmp - - local src=$(mktemp -d $TMPDIR/in-src.XXXXXX) - local endpoint="http://${artifactory_ip}:8081/artifactory" - local regex="ecd-front-(?.*).tar.gz" - - local username="${ART_USER}" - local password="${ART_PWD}" - - local repository="/generic/ecd-front" - local file="ecd-front-(?.*).tar.gz" - - local version=20161109222826 - - deploy_with_credentials $endpoint $regex $repository $file $version $src $username $password -} - -run it_can_deploy_release_to_artifactory_with_credentials -run it_can_deploy_release_to_artifactory +exit 1