Skip to content
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

fix(pg-v5) only support default credential for connection pooling #1696

Merged
merged 1 commit into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions packages/pg-v5/commands/connection_pooling.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ function * run (context, heroku) {

let db = yield fetcher.addon(app, args.database)
let addon = yield heroku.get(`/addons/${encodeURIComponent(db.name)}`)
let credential = flags.credential || 'default'

if (util.starterPlan(db)) throw new Error('This operation is not supported by Hobby tier databases.')

let attachment = yield cli.action(
`Enabling Connection Pooling${credential === 'default' ? '' : ' for credential ' + cli.color.addon(credential)} on ${cli.color.addon(addon.name)} to ${cli.color.app(app)}`,
`Enabling Connection Pooling on ${cli.color.addon(addon.name)} to ${cli.color.app(app)}`,
heroku.post(`/client/v11/databases/${encodeURIComponent(db.name)}/connection-pooling`, {
body: { name: flags.as, credential: credential, app: app },
body: { name: flags.as, credential: 'default', app: app },
host: host(db)
})
)
Expand All @@ -44,12 +43,11 @@ module.exports = {
needsAuth: true,
help: `Example:

heroku pg:connection-pooling:attach postgresql-something-12345 --credential cred-name
heroku pg:connection-pooling:attach postgresql-something-12345
`,
args: [{ name: 'database', optional: true }],
flags: [
{ name: 'as', description: 'name for add-on attachment', hasValue: true },
{ name: 'credential', char: 'n', hasValue: true, required: false, description: 'name of the credential within the database' }
{ name: 'as', description: 'name for add-on attachment', hasValue: true }
],
run: cli.command({ preauth: true }, co.wrap(run))
}
16 changes: 0 additions & 16 deletions packages/pg-v5/test/commands/connection_pooling.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,6 @@ describe('pg:connection-polling:attach', () => {
api.done()
})

context('includes a credential', () => {
beforeEach(() => {
pg.post(`/client/v11/databases/${addon.name}/connection-pooling`, {
credential: readonlyCredential,
app: 'myapp'
}).reply(201, { name: 'HEROKU_COLOR' })
})

it('attaches pgbouncer with readonly credential', () => {
return cmd.run({ app: 'myapp', args: { database: 'postgres-1' }, flags: { credential: readonlyCredential } })
.then(() => expect(cli.stdout, 'to equal', ``))
.then(() => expect(cli.stderr, 'to contain', 'Enabling Connection Pooling for credential ' + readonlyCredential))
.then(() => expect(cli.stderr, 'to contain', 'Setting HEROKU_COLOR config vars and restarting myapp... done, v0\n'))
})
})

context('includes an attachment name', () => {
beforeEach(() => {
pg.post(`/client/v11/databases/${addon.name}/connection-pooling`, {
Expand Down