Skip to content

Commit 47793e7

Browse files
committed
added secret_ops::docker_login
1 parent ba64520 commit 47793e7

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 0.7.0 (2019-May-01)
2+
* added `secret_ops::docker_login`
3+
14
### 0.6.3 (2019-Apr-23)
25

36
* added license notes

src/secret-ops

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,12 @@ function secret_ops::insert_vault_token_gocd_yaml {
104104
function secret_ops::insert_vault_token_gocd_yaml2 {
105105
secret_ops::insert_vault_token_gocd_yaml $1
106106
}
107+
108+
function secret_ops::docker_login {
109+
vault_user_path=$USER
110+
if [ $vault_user_path == "go" ]; then
111+
vault_user_path="gocd"
112+
fi
113+
dockerhub_user=$(vault read -field=user secret/$vault_user_path/dockerhub)
114+
vault read -field=password secret/$vault_user_path/dockerhub | docker login --username $dockerhub_user --password-stdin
115+
}

test/bats/01.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ load '/opt/bats-assert/load.bash'
6262
echo "output: $output"
6363
assert_equal "$status" 0
6464
}
65+
66+
@test "secret_ops::docker_login should succeed" {
67+
run /bin/bash -c "source src/secret-ops && secret_ops::docker_login"
68+
assert_line --partial "Login Succeeded"
69+
# this is printed on test failure
70+
echo "output: $output"
71+
assert_equal "$status" 0
72+
}

0 commit comments

Comments
 (0)