Skip to content

Allow creating roles for PostgreSQL#33

Merged
asfgit merged 3 commits intoapache:masterfrom
ivanayov:postgresql-roles
Jun 7, 2016
Merged

Allow creating roles for PostgreSQL#33
asfgit merged 3 commits intoapache:masterfrom
ivanayov:postgresql-roles

Conversation

@ivanayov
Copy link
Copy Markdown
Contributor

@ivanayov ivanayov commented May 5, 2016

No description provided.

createRolesQuery = createRolesQuery.concat(";");
}

if (((Map) role.getValue()).containsKey("privilages")) {
Copy link
Copy Markdown
Contributor

@geomacy geomacy May 5, 2016

Choose a reason for hiding this comment

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

typo "privilages" -> "privileges"

also couple of lines below (could put this in a constant)

@ivanayov ivanayov force-pushed the postgresql-roles branch from d266a85 to f9e1187 Compare May 5, 2016 16:20
@ivanayov
Copy link
Copy Markdown
Contributor Author

ivanayov commented May 5, 2016

Thanks @geomacy

"Set roles with properties and permissions. Shoud be a map with keys equal to role names and values a map of the type:" +
"key equal to `properties` and value - the role properties that should be in the query after `WITH` statement" +
"key equal to `privileges` and value - the `GRANT` query value between the `GRANT` and `TO` statements"
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe worth to add an actual example within the description of what the map should look like?

@ivanayov ivanayov force-pushed the postgresql-roles branch from f9e1187 to 7efc11b Compare May 6, 2016 12:17
@ivanayov
Copy link
Copy Markdown
Contributor Author

ivanayov commented May 6, 2016

Thanks @geomacy @tbouron @duncangrant
Using prepared statement requires big refactoring of the current code, because we generate and execute a script now and don't connect to the database in the code. Validating looks the simpler approach.

@nakomis
Copy link
Copy Markdown
Contributor

nakomis commented May 6, 2016

I was a little late getting to this, but it looks like @tbouron, @geomacy, and @duncangrant have already raised the concerns I had

Still not completely convinced that this is required in addition to the database initialisation script. Any thoughts anyone?

@ivanayov
Copy link
Copy Markdown
Contributor Author

ivanayov commented May 6, 2016

I agree, the user writing the queries in the yaml is the one who's deploying the entity and creating the database and can do whatever would like with them. But if this code is used for effectors in future or reused for anything, it's good to be secure from now.


private String buildCreateRolesQuery() {
Map<String, Map> roles = entity.getConfig(PostgreSqlNode.ROLES);
String createRolesQuery = "\"";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is better to use StringBuilder.

@ivanayov ivanayov force-pushed the postgresql-roles branch 2 times, most recently from 615dc3b to 844aa67 Compare May 10, 2016 15:06
String DEFAULT_USERNAME = "postgresqluser";

@SetFromFlag("roles")
ConfigKey<Map<String, Map>> ROLES = new MapConfigKey(Map.class, "postgresql.roles",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we have a test for this?

@ivanayov ivanayov force-pushed the postgresql-roles branch from 844aa67 to fc808a4 Compare June 1, 2016 16:09
@ivanayov
Copy link
Copy Markdown
Contributor Author

ivanayov commented Jun 6, 2016

@aledsage are you ok with merging this?
I couldn't run the tests and after I resolve my issue with them, can make changes to PostgreSqlInitializeDatabaseLiveTest in another PR if needed.

@aledsage
Copy link
Copy Markdown
Contributor

aledsage commented Jun 6, 2016

@iyovcheva I've opened ivanayov#1 for some additional changes to the roles code. Can you take a look and see what you think please?

If you merge that, it should appear automatically on this PR.

@ivanayov ivanayov force-pushed the postgresql-roles branch from 2a011e5 to fec0b9d Compare June 7, 2016 09:41
@aledsage
Copy link
Copy Markdown
Contributor

aledsage commented Jun 7, 2016

@iyovcheva there's a merge conflict - can you rebase against master please?

@ivanayov ivanayov force-pushed the postgresql-roles branch from fec0b9d to 2f24577 Compare June 7, 2016 11:40
location: localhost
services:
- type: org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppCluster
- serviceType: org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppCluster
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why change this? type should work as well. This file seems unrelated to the rest of the pull request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test JavaWebAppsMatchingTest works for me locally. Can you explain these changes please?

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.

9 participants