Line data Source code
1 : // Copyright (C) 2009 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.pgm.init.api; 16 : 17 : import com.google.common.annotations.VisibleForTesting; 18 : import com.google.gerrit.server.config.SitePaths; 19 : import com.google.gerrit.server.securestore.SecureStore; 20 : import com.google.inject.Inject; 21 : import com.google.inject.Singleton; 22 : import java.io.IOException; 23 : import java.util.List; 24 : import org.eclipse.jgit.errors.ConfigInvalidException; 25 : import org.eclipse.jgit.storage.file.FileBasedConfig; 26 : import org.eclipse.jgit.util.FS; 27 : 28 : /** Global variables used by the 'init' command. */ 29 : @Singleton 30 : public class InitFlags { 31 : /** Recursively delete the site path if initialization fails. */ 32 : public boolean deleteOnFailure; 33 : 34 : /** Site is being newly created */ 35 : public boolean isNew; 36 : 37 : /** Run the daemon (and open the web UI in a browser) after initialization. */ 38 : public boolean autoStart; 39 : 40 : /** Skip plugins */ 41 : public boolean skipPlugins; 42 : 43 : /** Delete all cache files */ 44 : public boolean deleteCaches; 45 : 46 : /** Dev mode */ 47 : public boolean dev; 48 : 49 : public final FileBasedConfig cfg; 50 : public final SecureStore sec; 51 : public final List<String> installPlugins; 52 : public final boolean installAllPlugins; 53 : 54 : @VisibleForTesting 55 : @Inject 56 : public InitFlags( 57 : final SitePaths site, 58 : final SecureStore secureStore, 59 : @InstallPlugins final List<String> installPlugins, 60 : @InstallAllPlugins final Boolean installAllPlugins) 61 16 : throws IOException, ConfigInvalidException { 62 16 : sec = secureStore; 63 16 : this.installPlugins = installPlugins; 64 16 : this.installAllPlugins = installAllPlugins; 65 16 : cfg = new FileBasedConfig(site.gerrit_config.toFile(), FS.DETECTED); 66 16 : cfg.load(); 67 16 : } 68 : }