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

DBPW - Update Cassandra to adhere to v5 Database interface #10051

Merged
merged 6 commits into from
Oct 12, 2020

Conversation

pcman312
Copy link
Contributor

@pcman312 pcman312 commented Sep 28, 2020

Overview

Updates the Cassandra Database plugin to adhere to the v5 Database interface.

Prerequisites

Base automatically changed from dbpw-usernames to master September 29, 2020 22:54
m := map[string]string{
"username": req.Username,
}
err := session.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is purely stylistic, but I don't think we tend to break chained function calls into multiple lines unless that's broken out by a multi-line struct declaration in the function's input param. Breaking out object's instantiation field values into multiple lines, like with m above, is fine though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up doing this because the line was getting fairly long with a lot of parenthesis. I can change it back if you want though.


c.rawConfig["password"] = password
return c.rawConfig, nil
return newdbplugin.DeleteUserResponse{}, result.ErrorOrNil()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant to ask this offline earlier, but can you remind me why the interface doesn't return pointer response values so that we can return nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't a particular need to do so. Plus it opens up the problem of having to do nil checks in other parts of the code and having some potentially inconsistent or confusing behavior.

@pcman312 pcman312 requested a review from calvn October 7, 2020 19:57
Copy link
Member

@tvoran tvoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 plus a couple questions.

plugins/database/cassandra/cassandra.go Show resolved Hide resolved
err = db.RevokeUser(context.Background(), statements, username)
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err = db.DeleteUser(context.Background(), deleteReq)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_, err = db.DeleteUser(context.Background(), deleteReq)
_, err = db.DeleteUser(ctx, deleteReq)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

func testCredsExist(address string, port int, username, password string) error {
func assertNoCreds(t testing.TB, address string, port int, username, password string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why assertCreds() needs a retry with backoff, but assertNoCreds() doesn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I neglected to put it in assertNoCreds.

plugins/database/cassandra/cassandra_test.go Outdated Show resolved Hide resolved
@pcman312 pcman312 merged commit 1eff3f7 into master Oct 12, 2020
@pcman312 pcman312 deleted the dbpw-cassandra branch October 12, 2020 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants