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
1diff --git a/helpers/registry-login.sh b/helpers/registry-login.sh
2index fa68362..7071451 100644
3--- a/helpers/registry-login.sh
4+++ b/helpers/registry-login.sh
5@@ -19,17 +19,17 @@ export DOCKERHUB_URL DOCKERHUB_REGISTRY_URL
6 # further requests.
7 _login_docker ()
8 {
9- if [ -z "$USERNAME" ]; then
10- read -rp "Username: " USERNAME
11+ if [ -z "$DOCKER_USERNAME" ]; then
12+ read -rp "Docker username: " DOCKER_USERNAME
13 fi
14- if [ -z "$PASSWORD" ]; then
15- read -rsp "Password: " PASSWORD
16+ if [ -z "$DOCKER_PASSWORD" ]; then
17+ read -rsp "Docker password: " DOCKER_PASSWORD
18 echo > /dev/stderr
19 fi
20
21 AUTH_TOKEN=$(curl -s \
22 -H "Content-Type: application/json" \
23- -X POST -d '{"username": "'"${USERNAME}"'", "password": "'"${PASSWORD}"'"}' \
24+ -X POST -d '{"username": "'"${DOCKER_USERNAME}"'", "password": "'"${DOCKER_PASSWORD}"'"}' \
25 "${DOCKERHUB_URL}/v2/users/login/" | jq -r .token)
26
27 if [ -z "$AUTH_TOKEN" ]; then
28@@ -42,8 +42,8 @@ _login_docker ()
29 printf 'AUTH_TOKEN=%s\n' "$AUTH_TOKEN" > /dev/stderr
30 fi
31
32- REGISTRY_USERNAME="$USERNAME"
33- REGISTRY_PASSWORD="$PASSWORD"
34+ REGISTRY_USERNAME="$DOCKER_USERNAME"
35+ REGISTRY_PASSWORD="$DOCKER_PASSWORD"
36 }
37
38 # Log into dockerhub's registry1, asking the user and the password.
39diff --git a/list-manifest-for-image-and-tag.sh b/list-manifest-for-image-and-tag.sh
40index 6f1d489..dbcf08d 100755
41--- a/list-manifest-for-image-and-tag.sh
42+++ b/list-manifest-for-image-and-tag.sh
43@@ -97,11 +97,13 @@ validate_args ()
44 exit 1
45 fi
46
47- if [ -n "$REGISTRY_USERNAME" ]; then
48- export USERNAME="$REGISTRY_USERNAME"
49- fi
50- if [ -n "$REGISTRY_PASSWORD" ]; then
51- export PASSWORD="$REGISTRY_PASSWORD"
52+ if [ "${REGISTRY}" = "docker" ]; then
53+ if [ -n "$REGISTRY_USERNAME" ]; then
54+ export DOCKER_USERNAME="$REGISTRY_USERNAME"
55+ fi
56+ if [ -n "$REGISTRY_PASSWORD" ]; then
57+ export DOCKER_PASSWORD="$REGISTRY_PASSWORD"
58+ fi
59 fi
60
61 do_login
62diff --git a/multi-arch-tagger.sh b/multi-arch-tagger.sh
63index 2b63ee5..c51bb4d 100755
64--- a/multi-arch-tagger.sh
65+++ b/multi-arch-tagger.sh
66@@ -101,11 +101,13 @@ validate_args ()
67 exit 1
68 fi
69
70- if [ -n "$REGISTRY_USERNAME" ]; then
71- export USERNAME="$REGISTRY_USERNAME"
72- fi
73- if [ -n "$REGISTRY_PASSWORD" ]; then
74- export PASSWORD="$REGISTRY_PASSWORD"
75+ if [ "${REGISTRY}" = "docker" ]; then
76+ if [ -n "$REGISTRY_USERNAME" ]; then
77+ export DOCKER_USERNAME="$REGISTRY_USERNAME"
78+ fi
79+ if [ -n "$REGISTRY_PASSWORD" ]; then
80+ export DOCKER_PASSWORD="$REGISTRY_PASSWORD"
81+ fi
82 fi
83
84 do_login
85diff --git a/tag-images.sh b/tag-images.sh
86index b4db4d5..c920c50 100755
87--- a/tag-images.sh
88+++ b/tag-images.sh
89@@ -284,7 +284,7 @@ validate_args ()
90 unset NEW_IMAGES
91 fi
92
93- _login_"${REGISTRY}"_registry1 "${IMAGES[*]}" "$USERNAME" "$PASSWORD"
94+ _login_"${REGISTRY}"_registry1 "${IMAGES[*]}" "$REGISTRY_USERNAME" "$REGISTRY_PASSWORD"
95 }
96
97 if [ $# -lt 2 ]; then

Subscribers

People subscribed via source and target branches

to all changes: