Merge ~ubuntu-docker-images/ubuntu-docker-images/+git/utils:rename-userpass-vars into ~ubuntu-docker-images/ubuntu-docker-images/+git/utils:master

Proposed by Sergio Durigan Junior
Status: Merged
Merged at revision: 3d46d7abc3e1bed645609a1a16934e3c143c4614
Proposed branch: ~ubuntu-docker-images/ubuntu-docker-images/+git/utils:rename-userpass-vars
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/utils:master
Diff against target: 97 lines (+22/-18)
4 files modified
helpers/registry-login.sh (+7/-7)
list-manifest-for-image-and-tag.sh (+7/-5)
multi-arch-tagger.sh (+7/-5)
tag-images.sh (+1/-1)
Reviewer Review Type Date Requested Status
Bryce Harrington Approve
Canonical Server Pending
Review via email: mp+401340@code.launchpad.net

Description of the change

Very trivial MP to rename the USERNAME/PASSWORD variables to DOCKER_USERNAME/DOCKER_PASSWORD, since they're used only for Docker.

To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote :

Looks good, I checked via `grep USERNAME * -sr`.

The usage docs also have bare 'USERNAME' and 'PASSWORD' but those are in context and are just placeholders anyway.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/helpers/registry-login.sh b/helpers/registry-login.sh
index fa68362..7071451 100644
--- a/helpers/registry-login.sh
+++ b/helpers/registry-login.sh
@@ -19,17 +19,17 @@ export DOCKERHUB_URL DOCKERHUB_REGISTRY_URL
19# further requests.19# further requests.
20_login_docker ()20_login_docker ()
21{21{
22 if [ -z "$USERNAME" ]; then22 if [ -z "$DOCKER_USERNAME" ]; then
23 read -rp "Username: " USERNAME23 read -rp "Docker username: " DOCKER_USERNAME
24 fi24 fi
25 if [ -z "$PASSWORD" ]; then25 if [ -z "$DOCKER_PASSWORD" ]; then
26 read -rsp "Password: " PASSWORD26 read -rsp "Docker password: " DOCKER_PASSWORD
27 echo > /dev/stderr27 echo > /dev/stderr
28 fi28 fi
2929
30 AUTH_TOKEN=$(curl -s \30 AUTH_TOKEN=$(curl -s \
31 -H "Content-Type: application/json" \31 -H "Content-Type: application/json" \
32 -X POST -d '{"username": "'"${USERNAME}"'", "password": "'"${PASSWORD}"'"}' \32 -X POST -d '{"username": "'"${DOCKER_USERNAME}"'", "password": "'"${DOCKER_PASSWORD}"'"}' \
33 "${DOCKERHUB_URL}/v2/users/login/" | jq -r .token)33 "${DOCKERHUB_URL}/v2/users/login/" | jq -r .token)
3434
35 if [ -z "$AUTH_TOKEN" ]; then35 if [ -z "$AUTH_TOKEN" ]; then
@@ -42,8 +42,8 @@ _login_docker ()
42 printf 'AUTH_TOKEN=%s\n' "$AUTH_TOKEN" > /dev/stderr42 printf 'AUTH_TOKEN=%s\n' "$AUTH_TOKEN" > /dev/stderr
43 fi43 fi
4444
45 REGISTRY_USERNAME="$USERNAME"45 REGISTRY_USERNAME="$DOCKER_USERNAME"
46 REGISTRY_PASSWORD="$PASSWORD"46 REGISTRY_PASSWORD="$DOCKER_PASSWORD"
47}47}
4848
49# Log into dockerhub's registry1, asking the user and the password.49# Log into dockerhub's registry1, asking the user and the password.
diff --git a/list-manifest-for-image-and-tag.sh b/list-manifest-for-image-and-tag.sh
index 6f1d489..dbcf08d 100755
--- a/list-manifest-for-image-and-tag.sh
+++ b/list-manifest-for-image-and-tag.sh
@@ -97,11 +97,13 @@ validate_args ()
97 exit 197 exit 1
98 fi98 fi
9999
100 if [ -n "$REGISTRY_USERNAME" ]; then100 if [ "${REGISTRY}" = "docker" ]; then
101 export USERNAME="$REGISTRY_USERNAME"101 if [ -n "$REGISTRY_USERNAME" ]; then
102 fi102 export DOCKER_USERNAME="$REGISTRY_USERNAME"
103 if [ -n "$REGISTRY_PASSWORD" ]; then103 fi
104 export PASSWORD="$REGISTRY_PASSWORD"104 if [ -n "$REGISTRY_PASSWORD" ]; then
105 export DOCKER_PASSWORD="$REGISTRY_PASSWORD"
106 fi
105 fi107 fi
106108
107 do_login109 do_login
diff --git a/multi-arch-tagger.sh b/multi-arch-tagger.sh
index 2b63ee5..c51bb4d 100755
--- a/multi-arch-tagger.sh
+++ b/multi-arch-tagger.sh
@@ -101,11 +101,13 @@ validate_args ()
101 exit 1101 exit 1
102 fi102 fi
103103
104 if [ -n "$REGISTRY_USERNAME" ]; then104 if [ "${REGISTRY}" = "docker" ]; then
105 export USERNAME="$REGISTRY_USERNAME"105 if [ -n "$REGISTRY_USERNAME" ]; then
106 fi106 export DOCKER_USERNAME="$REGISTRY_USERNAME"
107 if [ -n "$REGISTRY_PASSWORD" ]; then107 fi
108 export PASSWORD="$REGISTRY_PASSWORD"108 if [ -n "$REGISTRY_PASSWORD" ]; then
109 export DOCKER_PASSWORD="$REGISTRY_PASSWORD"
110 fi
109 fi111 fi
110112
111 do_login113 do_login
diff --git a/tag-images.sh b/tag-images.sh
index b4db4d5..c920c50 100755
--- a/tag-images.sh
+++ b/tag-images.sh
@@ -284,7 +284,7 @@ validate_args ()
284 unset NEW_IMAGES284 unset NEW_IMAGES
285 fi285 fi
286286
287 _login_"${REGISTRY}"_registry1 "${IMAGES[*]}" "$USERNAME" "$PASSWORD"287 _login_"${REGISTRY}"_registry1 "${IMAGES[*]}" "$REGISTRY_USERNAME" "$REGISTRY_PASSWORD"
288}288}
289289
290if [ $# -lt 2 ]; then290if [ $# -lt 2 ]; then

Subscribers

People subscribed via source and target branches

to all changes: