Skip to content

Commit

Permalink
Closes byrnedo#9: conditional binary operator expected
Browse files Browse the repository at this point in the history
  • Loading branch information
vladkras committed May 22, 2019
1 parent a8924fb commit adff7ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Docker Registry Tool
[![Build Status](https://travis-ci.org/vladkras/docker-reg-tool.svg?branch=master)](https://travis-ci.org/vladkras/docker-reg-tool)

Small bash script to do repetitive things with docker registry > 2.1 ( I think, whichever version supports delete by manifest)

Expand All @@ -8,10 +9,10 @@ Small bash script to do repetitive things with docker registry > 2.1 ( I think,
[Jq](https://stedolan.github.io/jq/)

```
Usage:
Usage:
./docker_reg_tool REGISTRY_BASE_URL ACTION [OPTIONS..]
Actions:
- list list repos
Expand All @@ -38,7 +39,7 @@ Usage:
...are sniffed out of ~/.docker/config.json. So you need to do `docker login...` before you can use this tool.

They can also be set with the `BASIC_AUTH` environment variable.

BASIC_AUTH=user:pass ./docker_reg_tool ...

Only been tested on Basic auth.
Expand All @@ -58,6 +59,3 @@ Set the `TRACE` environment variable to true to turn on `set -x`
## Docker Image

See https://hub.docker.com/r/byrnedo/reg-tool/



15 changes: 7 additions & 8 deletions docker_reg_tool
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -euo pipefail
set -eo pipefail

CMD=$0

Expand All @@ -12,18 +12,18 @@ function isTruthy {

}

if [[ -v "TRACE" ]] && [[ $(isTruthy "$TRACE") ]]; then
if [[ ${TRACE} ]] && [[ $(isTruthy "$TRACE") ]]; then
set -x
fi


function usage {
cat <<EOU
Usage:
Usage:
$CMD REGISTRY_BASE_URL ACTION [OPTIONS..]
Actions:
- list list repos
Expand Down Expand Up @@ -67,7 +67,7 @@ shift
CREDS=""
DOCKER_CONFIG="$HOME/.docker/config.json"

if [[ -v "BASIC_AUTH" ]]; then
if [[ ${BASIC_AUTH} ]]; then
CREDS="Authorization: Basic $(echo -n $BASIC_AUTH|base64)"
elif [[ -f "$DOCKER_CONFIG" ]]; then
AUTH_INFO=$(jq -r '.auths["'$REG'"].auth' < "$DOCKER_CONFIG")
Expand All @@ -83,7 +83,7 @@ fi

SEC_FLAG=""

if [[ -v "INSECURE_REGISTRY" ]] && [[ $(isTruthy "$INSECURE_REGISTRY") ]]; then
if [[ ${INSECURE_REGISTRY} ]] && [[ $(isTruthy "$INSECURE_REGISTRY") ]]; then
SEC_FLAG="-k"
fi

Expand Down Expand Up @@ -116,10 +116,9 @@ case "$ACTION" in
if [ $result -eq 202 ]; then
echo "Successfully deleted"
exit 0
else
else
echo "Failed to delete"
exit 3
fi
;;
esac

0 comments on commit adff7ef

Please sign in to comment.