Compare commits

...

7 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
90ab3a1191 Release 1.13.0 2021-02-02 21:50:08 -05:00
Jose Diaz-Gonzalez
23681960bf Merge pull request #157 from gyfis/patch-1
Don't fill $SERVICE as username in REDIS_URL
2021-02-02 21:49:47 -05:00
Tomas Hromada
872ed9c540 Merge branch 'patch-1' of https://github.com/gyfis/dokku-redis into patch-1 2020-11-22 09:00:53 +01:00
Tomas Hromada
c85770a873 💄 README.md from bin/generate 2020-11-22 09:00:44 +01:00
Tomáš Hromada
facd80f5bc 💄 Remove last empty line from README 2020-11-22 08:13:04 +01:00
Tomas Hromada
bc5985881a purge mentions of the faux-username from the codebase 2020-11-21 21:17:55 +01:00
Tomáš Hromada
4170c0b993 Don't fill $SERVICE as username in service_url()
The URL generated by this plugin is invalid, but since Redis on versions 5 and lower didn't have a notion of usernames, it pretty much went unnoticed. 

Let's fix this by not setting the $SERVICE as the username in the service_url returned by this plugin.

I believe that clients ignore the username (otherwise the Redis connection wouldn't go through), so this should be a non-breaking change.

Fixes #155
2020-11-21 20:53:49 +01:00
8 changed files with 25 additions and 25 deletions

View File

@@ -203,7 +203,7 @@ DOKKU_REDIS_LOLIPOP_PORT_6379_TCP_ADDR=172.17.0.1
The following will be set on the linked application by default: The following will be set on the linked application by default:
``` ```
REDIS_URL=redis://lolipop:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop REDIS_URL=redis://:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop
``` ```
The host exposed here only works internally in docker containers. If you want your container to be reachable from outside, you should use the 'expose' subcommand. Another service can be linked to your app: The host exposed here only works internally in docker containers. If you want your container to be reachable from outside, you should use the 'expose' subcommand. Another service can be linked to your app:
@@ -222,7 +222,7 @@ dokku redis:link lolipop playground
This will cause `REDIS_URL` to be set as: This will cause `REDIS_URL` to be set as:
``` ```
redis2://lolipop:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop redis2://:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop
``` ```
### unlink the redis service from the app ### unlink the redis service from the app
@@ -312,7 +312,7 @@ dokku redis:promote <service> <app>
If you have a redis service linked to an app and try to link another redis service another link environment variable will be generated automatically: If you have a redis service linked to an app and try to link another redis service another link environment variable will be generated automatically:
``` ```
DOKKU_REDIS_BLUE_URL=redis://other_service:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service DOKKU_REDIS_BLUE_URL=redis://:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service
``` ```
You can promote the new service to be the primary one: You can promote the new service to be the primary one:
@@ -326,9 +326,9 @@ dokku redis:promote other_service playground
This will replace `REDIS_URL` with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example: This will replace `REDIS_URL` with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example:
``` ```
REDIS_URL=redis://other_service:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service REDIS_URL=redis://:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service
DOKKU_REDIS_BLUE_URL=redis://other_service:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service DOKKU_REDIS_BLUE_URL=redis://:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service
DOKKU_REDIS_SILVER_URL=redis://lolipop:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop DOKKU_REDIS_SILVER_URL=redis://:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop
``` ```
### start a previously stopped redis service ### start a previously stopped redis service

View File

@@ -155,5 +155,5 @@ service_url() {
local SERVICE="$1" local SERVICE="$1"
local PASSWORD="$(service_password "$SERVICE")" local PASSWORD="$(service_password "$SERVICE")"
local SERVICE_DNS_HOSTNAME="$(service_dns_hostname "$SERVICE")" local SERVICE_DNS_HOSTNAME="$(service_dns_hostname "$SERVICE")"
echo "$PLUGIN_SCHEME://$SERVICE:$PASSWORD@$SERVICE_DNS_HOSTNAME:${PLUGIN_DATASTORE_PORTS[0]}" echo "$PLUGIN_SCHEME://:$PASSWORD@$SERVICE_DNS_HOSTNAME:${PLUGIN_DATASTORE_PORTS[0]}"
} }

View File

@@ -1,4 +1,4 @@
[plugin] [plugin]
description = "dokku redis service plugin" description = "dokku redis service plugin"
version = "1.12.6" version = "1.13.0"
[plugin.config] [plugin.config]

View File

@@ -23,7 +23,7 @@ service-link-cmd() {
#E #E
#E the following will be set on the linked application by default: #E the following will be set on the linked application by default:
#E #E
#E ${PLUGIN_DEFAULT_ALIAS}_URL=${PLUGIN_SCHEME}://lolipop:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop #E ${PLUGIN_DEFAULT_ALIAS}_URL=${PLUGIN_SCHEME}://:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop
#E #E
#E the host exposed here only works internally in docker containers. #E the host exposed here only works internally in docker containers.
#E if you want your container to be reachable from outside, you should #E if you want your container to be reachable from outside, you should
@@ -37,7 +37,7 @@ service-link-cmd() {
#E dokku $PLUGIN_COMMAND_PREFIX:link lolipop playground #E dokku $PLUGIN_COMMAND_PREFIX:link lolipop playground
#E this will cause ${PLUGIN_DEFAULT_ALIAS}_URL to be set as: #E this will cause ${PLUGIN_DEFAULT_ALIAS}_URL to be set as:
#E #E
#E ${PLUGIN_SCHEME}2://lolipop:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop #E ${PLUGIN_SCHEME}2://:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop
#A service, service to run command against #A service, service to run command against
#A app, app to run command against #A app, app to run command against
#F -a|--alias "BLUE_DATABASE", an alternative alias to use for linking to an app via environment variable #F -a|--alias "BLUE_DATABASE", an alternative alias to use for linking to an app via environment variable

View File

@@ -9,7 +9,7 @@ service-promote-cmd() {
#E if you have a $PLUGIN_COMMAND_PREFIX service linked to an app and try to link another $PLUGIN_COMMAND_PREFIX service #E if you have a $PLUGIN_COMMAND_PREFIX service linked to an app and try to link another $PLUGIN_COMMAND_PREFIX service
#E another link environment variable will be generated automatically: #E another link environment variable will be generated automatically:
#E #E
#E DOKKU_${PLUGIN_DEFAULT_ALIAS}_BLUE_URL=${PLUGIN_SCHEME}://other_service:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service #E DOKKU_${PLUGIN_DEFAULT_ALIAS}_BLUE_URL=${PLUGIN_SCHEME}://:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service
#E #E
#E you can promote the new service to be the primary one #E you can promote the new service to be the primary one
#E > NOTE: this will restart your app #E > NOTE: this will restart your app
@@ -18,9 +18,9 @@ service-promote-cmd() {
#E another environment variable to hold the previous value if necessary. #E another environment variable to hold the previous value if necessary.
#E you could end up with the following for example: #E you could end up with the following for example:
#E #E
#E ${PLUGIN_DEFAULT_ALIAS}_URL=${PLUGIN_SCHEME}://other_service:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service #E ${PLUGIN_DEFAULT_ALIAS}_URL=${PLUGIN_SCHEME}://:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service
#E DOKKU_${PLUGIN_DEFAULT_ALIAS}_BLUE_URL=${PLUGIN_SCHEME}://other_service:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service #E DOKKU_${PLUGIN_DEFAULT_ALIAS}_BLUE_URL=${PLUGIN_SCHEME}://:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service
#E DOKKU_${PLUGIN_DEFAULT_ALIAS}_SILVER_URL=${PLUGIN_SCHEME}://lolipop:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop #E DOKKU_${PLUGIN_DEFAULT_ALIAS}_SILVER_URL=${PLUGIN_SCHEME}://:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop
#A service, service to run command against #A service, service to run command against
#A app, app to run command against #A app, app to run command against
declare desc="promote service <service> as ${PLUGIN_DEFAULT_ALIAS}_URL in <app>" declare desc="promote service <service> as ${PLUGIN_DEFAULT_ALIAS}_URL in <app>"

View File

@@ -22,21 +22,21 @@ teardown() {
@test "($PLUGIN_COMMAND_PREFIX:info) success" { @test "($PLUGIN_COMMAND_PREFIX:info) success" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l run dokku "$PLUGIN_COMMAND_PREFIX:info" l
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "${lines[*]}" "redis://l:$password@dokku-redis-l:6379" assert_contains "${lines[*]}" "redis://:$password@dokku-redis-l:6379"
} }
@test "($PLUGIN_COMMAND_PREFIX:info) replaces underscores by dash in hostname" { @test "($PLUGIN_COMMAND_PREFIX:info) replaces underscores by dash in hostname" {
dokku "$PLUGIN_COMMAND_PREFIX:create" test_with_underscores dokku "$PLUGIN_COMMAND_PREFIX:create" test_with_underscores
run dokku "$PLUGIN_COMMAND_PREFIX:info" test_with_underscores run dokku "$PLUGIN_COMMAND_PREFIX:info" test_with_underscores
password="$(sudo cat "$PLUGIN_DATA_ROOT/test_with_underscores/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/test_with_underscores/PASSWORD")"
assert_contains "${lines[*]}" "redis://test_with_underscores:$password@dokku-redis-test-with-underscores:6379" assert_contains "${lines[*]}" "redis://:$password@dokku-redis-test-with-underscores:6379"
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" test_with_underscores dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" test_with_underscores
} }
@test "($PLUGIN_COMMAND_PREFIX:info) success with flag" { @test "($PLUGIN_COMMAND_PREFIX:info) success with flag" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --dsn run dokku "$PLUGIN_COMMAND_PREFIX:info" l --dsn
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_output "redis://l:$password@dokku-redis-l:6379" assert_output "redis://:$password@dokku-redis-l:6379"
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --config-dir run dokku "$PLUGIN_COMMAND_PREFIX:info" l --config-dir
assert_success assert_success

View File

@@ -63,7 +63,7 @@ teardown() {
echo "status: $status" echo "status: $status"
url=$(dokku config:get my_app REDIS_URL) url=$(dokku config:get my_app REDIS_URL)
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "$url" "redis://l:$password@dokku-redis-l:6379" assert_contains "$url" "redis://:$password@dokku-redis-l:6379"
assert_success assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
} }
@@ -96,7 +96,7 @@ teardown() {
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
url=$(dokku config:get my_app REDIS_URL) url=$(dokku config:get my_app REDIS_URL)
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "$url" "redis2://l:$password@dokku-redis-l:6379" assert_contains "$url" "redis2://:$password@dokku-redis-l:6379"
assert_success assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
} }
@@ -113,7 +113,7 @@ teardown() {
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app --alias "ALIAS" dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app --alias "ALIAS"
url=$(dokku config:get my_app ALIAS_URL) url=$(dokku config:get my_app ALIAS_URL)
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "$url" "redis://l:$password@dokku-redis-l:6379" assert_contains "$url" "redis://:$password@dokku-redis-l:6379"
assert_success assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
} }

View File

@@ -40,15 +40,15 @@ teardown() {
@test "($PLUGIN_COMMAND_PREFIX:promote) changes REDIS_URL" { @test "($PLUGIN_COMMAND_PREFIX:promote) changes REDIS_URL" {
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
dokku config:set my_app "REDIS_URL=redis://u:p@host:6379/db" "DOKKU_REDIS_BLUE_URL=redis://l:$password@dokku-redis-l:6379" dokku config:set my_app "REDIS_URL=redis://:p@host:6379/db" "DOKKU_REDIS_BLUE_URL=redis://:$password@dokku-redis-l:6379"
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
url=$(dokku config:get my_app REDIS_URL) url=$(dokku config:get my_app REDIS_URL)
assert_equal "$url" "redis://l:$password@dokku-redis-l:6379" assert_equal "$url" "redis://:$password@dokku-redis-l:6379"
} }
@test "($PLUGIN_COMMAND_PREFIX:promote) creates new config url when needed" { @test "($PLUGIN_COMMAND_PREFIX:promote) creates new config url when needed" {
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
dokku config:set my_app "REDIS_URL=redis://u:p@host:6379/db" "DOKKU_REDIS_BLUE_URL=redis://l:$password@dokku-redis-l:6379" dokku config:set my_app "REDIS_URL=redis://:p@host:6379/db" "DOKKU_REDIS_BLUE_URL=redis://:$password@dokku-redis-l:6379"
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
run dokku config my_app run dokku config my_app
assert_contains "${lines[*]}" "DOKKU_REDIS_" assert_contains "${lines[*]}" "DOKKU_REDIS_"
@@ -56,8 +56,8 @@ teardown() {
@test "($PLUGIN_COMMAND_PREFIX:promote) uses REDIS_DATABASE_SCHEME variable" { @test "($PLUGIN_COMMAND_PREFIX:promote) uses REDIS_DATABASE_SCHEME variable" {
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
dokku config:set my_app "REDIS_DATABASE_SCHEME=redis2" "REDIS_URL=redis://u:p@host:6379" "DOKKU_REDIS_BLUE_URL=redis2://l:$password@dokku-redis-l:6379" dokku config:set my_app "REDIS_DATABASE_SCHEME=redis2" "REDIS_URL=redis://:p@host:6379" "DOKKU_REDIS_BLUE_URL=redis2://:$password@dokku-redis-l:6379"
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
url=$(dokku config:get my_app REDIS_URL) url=$(dokku config:get my_app REDIS_URL)
assert_equal "$url" "redis2://l:$password@dokku-redis-l:6379" assert_equal "$url" "redis2://:$password@dokku-redis-l:6379"
} }