public String getFileLocation() { return fileLocation().getAbsolutePath(); }
@Deprecated public synchronized GoConfigHolder write(String configFileContent, boolean shouldMigrate) throws Exception { File configFile = fileLocation(); try { if (shouldMigrate) { configFileContent = upgrader.upgradeIfNecessary(configFileContent); } GoConfigHolder configHolder = internalLoad(configFileContent, new ConfigModifyingUser(), new ArrayList<>()); String toWrite = configAsXml(configHolder.configForEdit, false); LOGGER.trace("Writing config file: {}", configFile.getAbsolutePath()); writeToConfigXmlFile(toWrite); return configHolder; } catch (Exception e) { LOGGER.error("Unable to write config file: {}\n{}", configFile.getAbsolutePath(), e.getMessage(), e); throw e; } }
public GoConfigHolder load() throws Exception { File configFile = fileLocation(); ReloadStrategy.ReloadTestResult result = reloadStrategy.requiresReload(configFile); if (!result.requiresReload) { reloadStrategy.hasLatest(result); return null; } synchronized (this) { result = reloadStrategy.requiresReload(configFile); if (!result.requiresReload) { reloadStrategy.hasLatest(result); return null; } reloadStrategy.performingReload(result); LOGGER.info("Config file changed at {}", result.modifiedTime); LOGGER.info("Reloading config file: {}", configFile); if (systemEnvironment.optimizeFullConfigSave()) { LOGGER.debug("Starting config reload using the optimized flow."); return forceLoad(); } else { encryptPasswords(configFile); LOGGER.debug("Detected change in config file."); return forceLoad(configFile); } } }
public void upgradeIfNecessary() { GoConfigMigrationResult migrationResult = this.upgrader.upgradeIfNecessary(fileLocation(), CurrentGoCDVersion.getInstance().formatted()); if (migrationResult.isUpgradeFailure()) { String message = migrationResult.message(); serverHealthService.update(ServerHealthState.warning("Invalid Configuration", message, HealthStateType.general(HealthStateScope.forInvalidConfig()))); LOGGER.warn(message); } }