Merge "init: configure "Non-Interactive Users" as batch priority"
This commit is contained in:
@@ -23,6 +23,7 @@ import com.google.gerrit.common.data.LabelType;
|
|||||||
import com.google.gerrit.common.data.LabelValue;
|
import com.google.gerrit.common.data.LabelValue;
|
||||||
import com.google.gerrit.common.data.Permission;
|
import com.google.gerrit.common.data.Permission;
|
||||||
import com.google.gerrit.common.data.PermissionRule;
|
import com.google.gerrit.common.data.PermissionRule;
|
||||||
|
import com.google.gerrit.common.data.PermissionRule.Action;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
||||||
@@ -50,6 +51,7 @@ public class AllProjectsCreator {
|
|||||||
private final PersonIdent serverUser;
|
private final PersonIdent serverUser;
|
||||||
|
|
||||||
private GroupReference admin;
|
private GroupReference admin;
|
||||||
|
private GroupReference batch;
|
||||||
private GroupReference anonymous;
|
private GroupReference anonymous;
|
||||||
private GroupReference registered;
|
private GroupReference registered;
|
||||||
private GroupReference owners;
|
private GroupReference owners;
|
||||||
@@ -79,6 +81,11 @@ public class AllProjectsCreator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AllProjectsCreator setBatchUsers(GroupReference batch) {
|
||||||
|
this.batch = batch;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public void create() throws IOException, ConfigInvalidException {
|
public void create() throws IOException, ConfigInvalidException {
|
||||||
Repository git = null;
|
Repository git = null;
|
||||||
try {
|
try {
|
||||||
@@ -132,6 +139,13 @@ public class AllProjectsCreator {
|
|||||||
grant(config, cap, GlobalCapability.ADMINISTRATE_SERVER, admin);
|
grant(config, cap, GlobalCapability.ADMINISTRATE_SERVER, admin);
|
||||||
grant(config, all, Permission.READ, admin, anonymous);
|
grant(config, all, Permission.READ, admin, anonymous);
|
||||||
|
|
||||||
|
if (batch != null) {
|
||||||
|
Permission priority = cap.getPermission(GlobalCapability.PRIORITY, true);
|
||||||
|
PermissionRule r = rule(config, batch);
|
||||||
|
r.setAction(Action.BATCH);
|
||||||
|
priority.add(r);
|
||||||
|
}
|
||||||
|
|
||||||
LabelType cr = initCodeReviewLabel(config);
|
LabelType cr = initCodeReviewLabel(config);
|
||||||
grant(config, heads, cr, -1, 1, registered);
|
grant(config, heads, cr, -1, 1, registered);
|
||||||
grant(config, heads, cr, -2, 2, admin, owners);
|
grant(config, heads, cr, -2, 2, admin, owners);
|
||||||
|
@@ -51,6 +51,7 @@ public class SchemaCreator {
|
|||||||
private AccountGroup anonymous;
|
private AccountGroup anonymous;
|
||||||
private AccountGroup registered;
|
private AccountGroup registered;
|
||||||
private AccountGroup owners;
|
private AccountGroup owners;
|
||||||
|
private AccountGroup batch;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SchemaCreator(SitePaths site,
|
public SchemaCreator(SitePaths site,
|
||||||
@@ -90,6 +91,7 @@ public class SchemaCreator {
|
|||||||
initSystemConfig(db);
|
initSystemConfig(db);
|
||||||
allProjectsCreator
|
allProjectsCreator
|
||||||
.setAdministrators(GroupReference.forGroup(admin))
|
.setAdministrators(GroupReference.forGroup(admin))
|
||||||
|
.setBatchUsers(GroupReference.forGroup(batch))
|
||||||
.create();
|
.create();
|
||||||
dataSourceType.getIndexScript().run(db);
|
dataSourceType.getIndexScript().run(db);
|
||||||
}
|
}
|
||||||
@@ -131,13 +133,13 @@ public class SchemaCreator {
|
|||||||
c.accountGroupNames().insert(
|
c.accountGroupNames().insert(
|
||||||
Collections.singleton(new AccountGroupName(registered)));
|
Collections.singleton(new AccountGroupName(registered)));
|
||||||
|
|
||||||
final AccountGroup batchUsers = newGroup(c, "Non-Interactive Users", null);
|
batch = newGroup(c, "Non-Interactive Users", null);
|
||||||
batchUsers.setDescription("Users who perform batch actions on Gerrit");
|
batch.setDescription("Users who perform batch actions on Gerrit");
|
||||||
batchUsers.setOwnerGroupUUID(admin.getGroupUUID());
|
batch.setOwnerGroupUUID(admin.getGroupUUID());
|
||||||
batchUsers.setType(AccountGroup.Type.INTERNAL);
|
batch.setType(AccountGroup.Type.INTERNAL);
|
||||||
c.accountGroups().insert(Collections.singleton(batchUsers));
|
c.accountGroups().insert(Collections.singleton(batch));
|
||||||
c.accountGroupNames().insert(
|
c.accountGroupNames().insert(
|
||||||
Collections.singleton(new AccountGroupName(batchUsers)));
|
Collections.singleton(new AccountGroupName(batch)));
|
||||||
|
|
||||||
owners = newGroup(c, "Project Owners", AccountGroup.PROJECT_OWNERS);
|
owners = newGroup(c, "Project Owners", AccountGroup.PROJECT_OWNERS);
|
||||||
owners.setDescription("Any owner of the project");
|
owners.setDescription("Any owner of the project");
|
||||||
|
Reference in New Issue
Block a user