-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exposed DSN option for postgres:info command #162
base: master
Are you sure you want to change the base?
Add exposed DSN option for postgres:info command #162
Conversation
Should work the same way. |
$ ssh [email protected] config:get <app> DATABASE_URL Must returns the same value as |
functions
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when this file does not exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I missed it. Thanks for the point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This port may not be exposed to the public, so this external dsn would fail to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, maybe I missed some explanation. I currently run ssh [email protected] postgres:expose postgres-database
before pgcli $(ssh [email protected] postgres:info postgres-database --external-dsn)
. If not External dsn
returns -
as Exposed ports
do.
$ ssh [email protected] 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 [email protected] postgres:expose postgres-database
$ ssh [email protected] 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:[email protected]: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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do some changes on README and flag description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be empty if the service is not exposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
External dsn:
already returns -
if the service is not exposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
pgcli
on 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 [email protected] 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 🙂