Add exposed DSN option for postgres:info command#162
Add exposed DSN option for postgres:info command#162nicolas-brousse wants to merge 1 commit intodokku:masterfrom
Conversation
Should work the same way. |
$ ssh dokku@dokku.me config:get <app> DATABASE_URLMust returns the same value as |
| local PORTS=($(cat "$PORT_FILE")) | ||
| local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" | ||
| local DATABASE_NAME="$(get_database_name "$SERVICE")" | ||
| local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST" |
There was a problem hiding this comment.
What happens when this file does not exist?
There was a problem hiding this comment.
Good question, I missed it. Thanks for the point
There was a problem hiding this comment.
I did some changes here too.
| local PORT_FILE="$SERVICE_ROOT/PORT" | ||
| [[ ! -f $PORT_FILE ]] && echo '-' && return 0 | ||
|
|
||
| local PORTS=($(cat "$PORT_FILE")) |
There was a problem hiding this comment.
This port may not be exposed to the public, so this external dsn would fail to work.
There was a problem hiding this comment.
What do you mean by "This port may not be exposed to the public"?
You mean because of a firewall for example?
There was a problem hiding this comment.
The port is by default only on the internal ip address. You'd need to call SERVICE:expose on the service (with the port you want to map it to specified) and only then would this code work.
There was a problem hiding this comment.
Yes, maybe I missed some explanation. I currently run ssh dokku@dokku.me postgres:expose postgres-database before pgcli $(ssh dokku@dokku.me postgres:info postgres-database --external-dsn). If not External dsn returns - as Exposed ports do.
$ ssh dokku@dokku.me postgres:info postgres-database
=====> Container Information
Config dir: /var/lib/dokku/services/postgres/postgres-database/config
Data dir: /var/lib/dokku/services/postgres/postgres-database/data
Dsn: postgres://postgres:xxxxxxxxxxxx@dokku-postgres-postgres-database:5432/postgres_database
External dsn: -
Exposed ports: -
Id: 9dc918204b5fb0a4b8848a71
Internal ip: 172.17.0.3
Links: postgres-database
Service root: /var/lib/dokku/services/postgres/postgres-database
Status: running
Version: postgres:10.4
$ ssh dokku@dokku.me postgres:expose postgres-database
$ ssh dokku@dokku.me postgres:info postgres-database
=====> Container Information
Config dir: /var/lib/dokku/services/postgres/postgres-database/config
Data dir: /var/lib/dokku/services/postgres/postgres-database/data
Dsn: postgres://postgres:xxxxxxxxxxxx@dokku-postgres-postgres-database:5432/postgres_database
External dsn: postgres://postgres:xxxxxxxxxxxx@dokku.me:28804/postgres_database
Exposed ports: 5432->28804
Id: 9dc918204b5fb0a4b8848a71
Internal ip: 172.17.0.3
Links: postgres-database
Service root: /var/lib/dokku/services/postgres/postgres-database
Status: running
Version: postgres:10.4
Maybe I have to update the README for more explanation.
There was a problem hiding this comment.
Right I'm just concerned that if the db is not exposed, then people will get confused and start filing issues about how this doesn't work.
There was a problem hiding this comment.
You're right, I'll work on updating README and maybe add precision on command help info about the option.
There was a problem hiding this comment.
I do some changes on README and flag description.
There was a problem hiding this comment.
Should be empty if the service is not exposed.
There was a problem hiding this comment.
External dsn: already returns - if the service is not exposed.
There was a problem hiding this comment.
Does this fine for you?
a3bffba to
3879ff9
Compare
|
Also I'm not sure about |
|
|
|
I'll rename |
3879ff9 to
5f2a81d
Compare
df40c30 to
3cb5b59
Compare
|
Hey josegonzalez. Are you still interested on this changes? I could found time in following weeks to end the work 🙂 |
|
Yes but I'd like this to be in the common-functions, so therefore generic so that we could do this to each database plugin. |
|
The thing is like for Do we need to have something like for redis plugin? https://github.com/dokku/dokku-redis/blob/fb1b189aeac0411226f66e2099560fe2061601e9/functions#L158 Should I move both |
|
@nicolas-brousse do you mean hostname, not user? |
|
A The connection user ( |
|
Ah I see what you mean. In that case, ignore my comment. Can you rebase this and provide the same PR to the other database plugins? |
|
Yes sure. But just to know, I noticed that for redis plugin, there is the variable |
|
Not sure thats always valid for all plugins. |
|
Not sure either. I'll just rebase then, and do the same in other database plugins 🙂 |
3cb5b59 to
f617bdb
Compare
I love to use
pgclion my laptop. I use it to log on my heroku databases (pgcli $(heroku config:get DATABASE_URL)). And I would like to be able to do the same on dokku, so I created this PR.I tested it on one dokku instance and it works correclty. And I'm able to do the following now.
$ pgcli $(ssh dokku@dokku.me postgres:info postgres-database --external-dsn)I'm new in dokku usage, so I don't know all your conventions. Maybe this could not be done for some reason, or you want I do some changes. Let me know 🙂