--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")
|
usage = "Path to jar providing SecureStore implementation class")
|
||||||
private String secureStoreLib;
|
private String secureStoreLib;
|
||||||
|
|
||||||
|
@Option(name = "--dev",
|
||||||
|
usage = "Setup site with default options suitable for developers")
|
||||||
|
private boolean dev;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Browser browser;
|
Browser browser;
|
||||||
|
|
||||||
@@ -137,6 +141,11 @@ public class Init extends BaseInit {
|
|||||||
return skipPlugins;
|
return skipPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isDev() {
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getSecureStoreLib() {
|
protected String getSecureStoreLib() {
|
||||||
return secureStoreLib;
|
return secureStoreLib;
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ public class BaseInit extends SiteProgram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init.flags.autoStart = getAutoStart() && init.site.isNew;
|
init.flags.autoStart = getAutoStart() && init.site.isNew;
|
||||||
|
init.flags.dev = isDev() && init.site.isNew;
|
||||||
init.flags.skipPlugins = skipPlugins();
|
init.flags.skipPlugins = skipPlugins();
|
||||||
|
|
||||||
final SiteRun run;
|
final SiteRun run;
|
||||||
@@ -446,4 +447,8 @@ public class BaseInit extends SiteProgram {
|
|||||||
System.err.println(msg + path);
|
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.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Config;
|
|
||||||
|
|
||||||
/** Initialize the {@code auth} configuration section. */
|
/** Initialize the {@code auth} configuration section. */
|
||||||
@Singleton
|
@Singleton
|
||||||
class InitAuth implements InitStep {
|
class InitAuth implements InitStep {
|
||||||
private static final String RECEIVE = "receive";
|
private static final String RECEIVE = "receive";
|
||||||
private static final String ENABLE_SIGNED_PUSH = "enableSignedPush";
|
private static final String ENABLE_SIGNED_PUSH = "enableSignedPush";
|
||||||
|
|
||||||
private final Config cfg;
|
|
||||||
private final ConsoleUI ui;
|
private final ConsoleUI ui;
|
||||||
private final Section auth;
|
private final Section auth;
|
||||||
private final Section ldap;
|
private final Section ldap;
|
||||||
private final Section receive;
|
private final Section receive;
|
||||||
private final Libraries libraries;
|
private final Libraries libraries;
|
||||||
|
private final InitFlags flags;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
InitAuth(InitFlags flags,
|
InitAuth(InitFlags flags,
|
||||||
ConsoleUI ui,
|
ConsoleUI ui,
|
||||||
Libraries libraries,
|
Libraries libraries,
|
||||||
Section.Factory sections) {
|
Section.Factory sections) {
|
||||||
this.cfg = flags.cfg;
|
this.flags = flags;
|
||||||
this.ui = ui;
|
this.ui = ui;
|
||||||
this.auth = sections.get("auth", null);
|
this.auth = sections.get("auth", null);
|
||||||
this.ldap = sections.get("ldap", null);
|
this.ldap = sections.get("ldap", null);
|
||||||
@@ -66,8 +64,8 @@ class InitAuth implements InitStep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initAuthType() {
|
private void initAuthType() {
|
||||||
AuthType authType =
|
AuthType authType = auth.select("Authentication method", "type",
|
||||||
auth.select("Authentication method", "type", AuthType.OPENID);
|
flags.dev ? AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT : AuthType.OPENID);
|
||||||
switch (authType) {
|
switch (authType) {
|
||||||
case HTTP:
|
case HTTP:
|
||||||
case HTTP_LDAP: {
|
case HTTP_LDAP: {
|
||||||
@@ -129,7 +127,7 @@ class InitAuth implements InitStep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initSignedPush() {
|
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");
|
boolean enable = ui.yesno(def, "Enable signed push support");
|
||||||
receive.set("enableSignedPush", Boolean.toString(enable));
|
receive.set("enableSignedPush", Boolean.toString(enable));
|
||||||
if (enable) {
|
if (enable) {
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ public class InitFlags {
|
|||||||
/** Skip plugins */
|
/** Skip plugins */
|
||||||
public boolean skipPlugins;
|
public boolean skipPlugins;
|
||||||
|
|
||||||
|
/** Dev mode */
|
||||||
|
public boolean dev;
|
||||||
|
|
||||||
public final FileBasedConfig cfg;
|
public final FileBasedConfig cfg;
|
||||||
public final SecureStore sec;
|
public final SecureStore sec;
|
||||||
public final List<String> installPlugins;
|
public final List<String> installPlugins;
|
||||||
|
|||||||
Reference in New Issue
Block a user