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

Database updates #4787

Merged
merged 2 commits into from
Jun 19, 2018
Merged

Database updates #4787

merged 2 commits into from
Jun 19, 2018

Conversation

jefferai
Copy link
Member

  • Add create/update distinction for connection config
  • Add create/update distinction for role config
  • Add db name and revocation statements to leases to give revocation a
    shot at working if the role has been deleted

Fixes #3544
Fixes #4782

* Add create/update distinction for connection config
* Add create/update distinction for role config
* Add db name and revocation statements to leases to give revocation a
shot at working if the role has been deleted

Fixes #3544
Fixes #4782
@jefferai jefferai added this to the 0.10.3 milestone Jun 18, 2018
if pluginNameRaw, ok := data.GetOk("plugin_name"); ok {
config.PluginName = pluginNameRaw.(string)
} else if req.Operation == logical.CreateOperation {
config.PluginName = data.Get("plugin_name").(string)
Copy link
Contributor

@kalafut kalafut Jun 18, 2018

Choose a reason for hiding this comment

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

In all of these else if blocks (in path_roles.go too), I think you can just initialize to the appropriate zero value ("" in this case). We already know the parameter doesn't exist and don't need to check it again.

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason we usually use this is in case we decide to provide/change a default value later. Instead of setitng the default in the schema and here, we just set it in the schema.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, TIL... That makes sense.

// Test existence check and an update to a single connection detail parameter
{
configData := map[string]interface{}{
"connection_url": "sample_convection_url",
Copy link
Contributor

@kalafut kalafut Jun 18, 2018

Choose a reason for hiding this comment

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

convection->connection (various places)

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, it's on purpose! Note that the previous check has connection and this has convection. The point is to check that it does indeed update, when other values that haven't been set stay the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps this is too subtle, I just enjoyed changing it to another real word with a single char substitution. :-)

@@ -554,8 +727,8 @@ func TestBackend_connectionCrud(t *testing.T) {
}

delete(resp.Data["connection_details"].(map[string]interface{}), "name")
if !reflect.DeepEqual(expected, resp.Data) {
t.Fatalf("bad: expected:%#v\nactual:%#v\n", expected, resp.Data)
if diff := deep.Equal(resp.Data, expected); diff != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the criteria for switching to deep.Equal()? It's fine, though I also see new code using reflect.Equal() in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

The new code is just where I've copied and pasted a test; where I've added further conditions I've tended towards deep.Equal.

There's no real criteria, I just tend to use it for new statements.

@kalafut
Copy link
Contributor

kalafut commented Jun 18, 2018

Minor comments, otherwise LGTM!

dbName = role.DBName
statements = role.Statements
} else {
if dbNameRaw, ok := req.Secret.InternalData["db_name"]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should just keep the current behavior of returning "role not found" if internal data does not have the fields.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean, instead of the more specific error messages? Having those makes debugging easier because we know exactly where things are failing.

chrishoffman
chrishoffman previously approved these changes Jun 18, 2018
calvn
calvn previously approved these changes Jun 18, 2018
@jefferai jefferai dismissed stale reviews from calvn and chrishoffman via df5b99f June 19, 2018 15:22
@jefferai jefferai merged commit df00e62 into master Jun 19, 2018
@jefferai jefferai deleted the database-updates branch June 19, 2018 15:24
@rwiggins
Copy link
Contributor

This is awesome. Thanks!

@jefferai
Copy link
Member Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants