diff --git a/README.md b/README.md index 83c7a39..96ad9fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # File URL Resource 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). ## Source Configuration @@ -36,10 +37,12 @@ resources: ### `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". +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. To verify if a file URL returns the `Last-Modified` information in its HTTP response header, issue the `curl` command below and search for field "Last-Modified" in its output. + ```curl -I ``` diff --git a/assets/check b/assets/check index 24a2024..26cc01d 100755 --- a/assets/check +++ b/assets/check @@ -12,8 +12,8 @@ payload=$(mktemp $TMPDIR/concoure-curl-resource-request.XXXXXX) cat > $payload <&0 url=$(jq -r '.source.url // ""' < $payload) -# username=$(jq -r '.source.username // ""' < $payload) -# password=$(jq -r '.source.password // ""' < $payload) +username=$(jq -r '.source.username // ""' < $payload) +password=$(jq -r '.source.password // ""' < $payload) skip_ssl_verification=$(jq -r '.source.skip_ssl_verification // ""' < $payload) if [ -z "$url" ]; then @@ -23,8 +23,8 @@ fi args_security= -# [ -n "$username" ] && args_security="-u $username"; -# [ -n "$password" ] && args_security="$args_security:$password"; +[ -n "$username" ] && args_security="-u $username"; +[ -n "$username" ] && [ -n "$password" ] && args_security="$args_security:$password"; trueValue="true" [ -n "$skip_ssl_verification" ] && [ "${skip_ssl_verification,,}" = "${trueValue,,}" ] && args_security="$args_security -k"; diff --git a/assets/in b/assets/in index 3b6ec3d..77da935 100755 --- a/assets/in +++ b/assets/in @@ -25,6 +25,8 @@ cat $payload url=$(jq -r '.source.url // ""' < $payload) filename=$(jq -r '.source.filename // ""' < $payload) skip_ssl_verification=$(jq -r '.source.skip_ssl_verification // ""' < $payload) +username=$(jq -r '.source.username // ""' < $payload) +password=$(jq -r '.source.password // ""' < $payload) if [ -z "$url" ]; then echo "invalid payload (missing url)" @@ -39,8 +41,9 @@ fi args_url="$url" args_security= -# [ -n "$username" ] && args_security="-u $username"; -# [ -n "$password" ] && args_security="$args_security:$password"; +[ -n "$username" ] && args_security="-u $username"; +[ -n "$username" ] && [ -n "$password" ] && args_security="$args_security:$password"; + trueValue="true" [ -n "$skip_ssl_verification" ] && [ "${skip_ssl_verification,,}" = "${trueValue,,}" ] && args_security="$args_security -k";