--dev flag for Init
When using the --dev flag during init, parameters suitable for development are chosen by default. Devs that often setup new gerrit_testsites, may now use --batch to quickly get a new site up and running. As of now, only development_become_any_account is defaulted as the InitAuth method, but in the future we may use the flag to help populate the test_site with a test data (repo, change or other logic that may help gerrit developers quickly get up and running). Change-Id: I87dca7e325f27a35859925fbdb5cfe37367a73d9
This commit is contained in:
@@ -63,6 +63,10 @@ public class Init extends BaseInit {
|
||||
usage = "Path to jar providing SecureStore implementation class")
|
||||
private String secureStoreLib;
|
||||
|
||||
@Option(name = "--dev",
|
||||
usage = "Setup site with default options suitable for developers")
|
||||
private boolean dev;
|
||||
|
||||
@Inject
|
||||
Browser browser;
|
||||
|
||||
@@ -137,6 +141,11 @@ public class Init extends BaseInit {
|
||||
return skipPlugins;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDev() {
|
||||
return dev;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSecureStoreLib() {
|
||||
return secureStoreLib;
|
||||
|
||||
@@ -115,6 +115,7 @@ public class BaseInit extends SiteProgram {
|
||||
}
|
||||
|
||||
init.flags.autoStart = getAutoStart() && init.site.isNew;
|
||||
init.flags.dev = isDev() && init.site.isNew;
|
||||
init.flags.skipPlugins = skipPlugins();
|
||||
|
||||
final SiteRun run;
|
||||
@@ -446,4 +447,8 @@ public class BaseInit extends SiteProgram {
|
||||
System.err.println(msg + path);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isDev() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,27 +25,25 @@ import com.google.gwtjsonrpc.server.SignedToken;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
|
||||
/** Initialize the {@code auth} configuration section. */
|
||||
@Singleton
|
||||
class InitAuth implements InitStep {
|
||||
private static final String RECEIVE = "receive";
|
||||
private static final String ENABLE_SIGNED_PUSH = "enableSignedPush";
|
||||
|
||||
private final Config cfg;
|
||||
private final ConsoleUI ui;
|
||||
private final Section auth;
|
||||
private final Section ldap;
|
||||
private final Section receive;
|
||||
private final Libraries libraries;
|
||||
private final InitFlags flags;
|
||||
|
||||
@Inject
|
||||
InitAuth(InitFlags flags,
|
||||
ConsoleUI ui,
|
||||
Libraries libraries,
|
||||
Section.Factory sections) {
|
||||
this.cfg = flags.cfg;
|
||||
this.flags = flags;
|
||||
this.ui = ui;
|
||||
this.auth = sections.get("auth", null);
|
||||
this.ldap = sections.get("ldap", null);
|
||||
@@ -66,8 +64,8 @@ class InitAuth implements InitStep {
|
||||
}
|
||||
|
||||
private void initAuthType() {
|
||||
AuthType authType =
|
||||
auth.select("Authentication method", "type", AuthType.OPENID);
|
||||
AuthType authType = auth.select("Authentication method", "type",
|
||||
flags.dev ? AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT : AuthType.OPENID);
|
||||
switch (authType) {
|
||||
case HTTP:
|
||||
case HTTP_LDAP: {
|
||||
@@ -129,7 +127,7 @@ class InitAuth implements InitStep {
|
||||
}
|
||||
|
||||
private void initSignedPush() {
|
||||
boolean def = cfg.getBoolean(RECEIVE, ENABLE_SIGNED_PUSH, false);
|
||||
boolean def = flags.cfg.getBoolean(RECEIVE, ENABLE_SIGNED_PUSH, false);
|
||||
boolean enable = ui.yesno(def, "Enable signed push support");
|
||||
receive.set("enableSignedPush", Boolean.toString(enable));
|
||||
if (enable) {
|
||||
|
||||
@@ -39,6 +39,9 @@ public class InitFlags {
|
||||
/** Skip plugins */
|
||||
public boolean skipPlugins;
|
||||
|
||||
/** Dev mode */
|
||||
public boolean dev;
|
||||
|
||||
public final FileBasedConfig cfg;
|
||||
public final SecureStore sec;
|
||||
public final List<String> installPlugins;
|
||||
|
||||
Reference in New Issue
Block a user