dokku-postgres icon indicating copy to clipboard operation
dokku-postgres copied to clipboard

Add exposed DSN option for postgres:info command

Open nicolas-brousse opened this issue 6 years ago • 14 comments

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 🙂

nicolas-brousse avatar Nov 20 '18 17:11 nicolas-brousse

ssh [email protected] config:get <app> DATABASE_URL

Should work the same way.

joshmanders avatar Nov 20 '18 20:11 joshmanders

$ ssh [email protected] config:get <app> DATABASE_URL

Must returns the same value as ssh [email protected] postgres:info postgres-database --dsn does. In my case it returns the internal DSN. So it's not really the same.

nicolas-brousse avatar Nov 20 '18 21:11 nicolas-brousse

Also I'm not sure about external-dsn as flag name. Should it be exposed-dsn or something else?

nicolas-brousse avatar Nov 29 '18 22:11 nicolas-brousse

exposed-dsn sounds fine.

josegonzalez avatar Dec 01 '18 18:12 josegonzalez

I'll rename external-dsn to exposed-dsn so.

nicolas-brousse avatar Dec 01 '18 18:12 nicolas-brousse

Hey josegonzalez. Are you still interested on this changes? I could found time in following weeks to end the work 🙂

nicolas-brousse avatar Mar 19 '20 14:03 nicolas-brousse

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.

josegonzalez avatar Mar 19 '20 15:03 josegonzalez

The thing is like for service_url (that is in functions file too) we do not know the user that should be use to generate the URI.

  • https://github.com/dokku/dokku-postgres/blob/89f080cb513336c3773f539e0ccc74802dbae954/functions#L159
  • https://github.com/dokku/dokku-postgres/blob/3cb5b5940b10f8fb33104b6fa44af9291846f624/functions#L168

Do we need to have something like for redis plugin?

https://github.com/dokku/dokku-redis/blob/fb1b189aeac0411226f66e2099560fe2061601e9/functions#L158

Should I move both service_url and service_exposed_url inside common-functions?

nicolas-brousse avatar Mar 19 '20 22:03 nicolas-brousse

@nicolas-brousse do you mean hostname, not user?

josegonzalez avatar Mar 20 '20 14:03 josegonzalez

A user that is part of the hostname yes schema://user:password@host.

The connection user (postgres) is not currently contained in a variable.

nicolas-brousse avatar Mar 20 '20 14:03 nicolas-brousse

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?

josegonzalez avatar Mar 20 '20 14:03 josegonzalez

Yes sure.

But just to know, I noticed that for redis plugin, there is the variable $SERVICE used. Do you think we could apply the same here?

https://github.com/dokku/dokku-redis/blob/fb1b189aeac0411226f66e2099560fe2061601e9/functions#L154-L159

nicolas-brousse avatar Mar 20 '20 14:03 nicolas-brousse

Not sure thats always valid for all plugins.

josegonzalez avatar Mar 20 '20 15:03 josegonzalez

Not sure either. I'll just rebase then, and do the same in other database plugins 🙂

nicolas-brousse avatar Mar 20 '20 15:03 nicolas-brousse