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
Feature:Postgres commands through http #893
Conversation
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.
Overall, looks great! Just a few notes.
cmd/postgres.go
Outdated
if !isPostgresApp(&app.ImageDetails) { | ||
return fmt.Errorf("%s is not a postgres app", cmdCtx.AppName) | ||
} | ||
// if !isPostgresApp(&app.ImageDetails) { |
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.
Are we checking this somewhere else?
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.
@davissp14 I only removed this temporary for testing, cause pg apps deployed with fly deploy
fail to pass this checks
cmd/postgres.go
Outdated
} | ||
|
||
pgCmd := NewPostgresCmd(cmdCtx, app, dialer) | ||
// pgCmd := NewPostgresCmd(cmdCtx, app, dialer) |
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.
We can probably just remove the commented code.
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.
Yeah will do, Just wanted to get a quick reaction before going to far with it.
pkg/flypg/http.go
Outdated
} | ||
defer res.Body.Close() | ||
|
||
if res.Status > "299" { |
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 are the expected status codes? Also, looks like you're comparing an int
with a string
here.
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.
True I'll work on it.
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.
Will we be working with any valid status codes, other than 200 and 201?
pkg/flypg/pg.go
Outdated
return false, nil | ||
} | ||
|
||
func (c *Client) GrantAccess(ctx context.Context, dbName, userName string) error { |
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 should probably be coupled with CreateUser. Given the complexity surrounding user permissions, we shouldn't expose this as its own endpoint.
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.
Makes sense
pkg/flypg/pg.go
Outdated
return nil | ||
} | ||
|
||
func (c *Client) RevokeAccess(ctx context.Context, dbName, userName string) error { |
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 should probably be coupled with DeleteUser. Like GrantAccess, let's not expose this as its own endpoint.
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.
Will do
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.
Great work! We just need to ensure that the version is bumped in postgres-ha
before this gets merged.
v0.0.19
ofpostgres-ha
This PR goes hand in hand with fly-apps/postgres-ha#64