use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class BuildCauseProducerServiceTest method manualTrigger_shouldUpdatePipelineConfigWhenMaterialIsConfigRepo.
@Test
public void manualTrigger_shouldUpdatePipelineConfigWhenMaterialIsConfigRepo() {
HgMaterial material1 = new HgMaterial("url", null);
HgMaterialConfig materialConfig1 = new HgMaterialConfig("url", null);
pipelineConfig.addMaterialConfig(materialConfig1);
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig1, "plug"), "revision1"));
when(materialConfigConverter.toMaterial(materialConfig1)).thenReturn(material1);
when(goConfigService.hasPipelineNamed(pipelineConfig.name())).thenReturn(true);
buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(new HashMap<>(), new HashMap<>(), new HashMap<>()), new ServerHealthStateOperationResult());
verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
MaterialUpdateStatusListener statusListener = extractMaterialListenerInstanceFromRegisterCall();
statusListener.onMaterialUpdate(new MaterialUpdateSuccessfulMessage(material1, 0));
verify(mockMaterialUpdateStatusNotifier).removeListenerFor(pipelineConfig);
verify(goConfigService, times(2)).pipelineConfigNamed(pipelineConfig.name());
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class MergeOriginConfigTest method shouldShowDisplayName.
@Test
public void shouldShowDisplayName() {
FileConfigOrigin fileConfigOrigin = new FileConfigOrigin();
RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(new ConfigRepoConfig(new SvnMaterialConfig("http://mysvn", false), "myplugin"), "123");
MergeConfigOrigin mergeOrigin = new MergeConfigOrigin(fileConfigOrigin, repoConfigOrigin);
assertThat(mergeOrigin.displayName(), is("Merged: [ cruise-config.xml; http://mysvn at 123; ]"));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class GoConfigMother method configWithConfigRepo.
public static CruiseConfig configWithConfigRepo() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(new GitMaterialConfig("https://github.com/tomzo/gocd-indep-config-part.git"), "myplugin")));
return cruiseConfig;
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class GoRepoConfigDataSource method onCheckoutComplete.
public void onCheckoutComplete(MaterialConfig material, File folder, String revision) {
// called when pipelines/flyweight/[flyweight] has a clean checkout of latest material
// Having modifications in signature might seem like an overkill
// but on the other hand if plugin is smart enough it could
// parse only files that have changed, which is a huge performance gain where there are many pipelines
/* if this is material listed in config-repos
Then ask for config plugin implementation
Give it the directory and store partial config
post event about completed (successful or not) parsing
*/
String fingerprint = material.getFingerprint();
if (this.configWatchList.hasConfigRepoWithFingerprint(fingerprint)) {
PartialConfigProvider plugin = null;
ConfigRepoConfig repoConfig = configWatchList.getConfigRepoForMaterial(material);
HealthStateScope scope = HealthStateScope.forPartialConfigRepo(repoConfig);
try {
plugin = this.configPluginService.partialConfigProviderFor(repoConfig);
} catch (Exception ex) {
fingerprintOfPartialToLatestParseResultMap.put(fingerprint, new PartialConfigParseResult(revision, ex));
LOGGER.error(String.format("Failed to get config plugin for %s", material.getDisplayName()));
String message = String.format("Failed to obtain configuration plugin '%s' for material: %s", repoConfig.getConfigProviderPluginName(), material.getLongDescription());
String errorDescription = ex.getMessage() == null ? ex.toString() : ex.getMessage();
serverHealthService.update(ServerHealthState.error(message, errorDescription, HealthStateType.general(scope)));
notifyFailureListeners(repoConfig, ex);
return;
}
try {
//TODO put modifications and previous partial config in context
// the context is just a helper for plugin.
PartialConfigLoadContext context = new LoadContext(repoConfig);
PartialConfig newPart = plugin.load(folder, context);
if (newPart == null) {
LOGGER.warn(String.format("Parsed configuration material %s by %s is null", material.getDisplayName(), plugin.displayName()));
newPart = new PartialConfig();
}
newPart.setOrigins(new RepoConfigOrigin(repoConfig, revision));
fingerprintOfPartialToLatestParseResultMap.put(fingerprint, new PartialConfigParseResult(revision, newPart));
serverHealthService.removeByScope(scope);
notifySuccessListeners(repoConfig, newPart);
} catch (Exception ex) {
fingerprintOfPartialToLatestParseResultMap.put(fingerprint, new PartialConfigParseResult(revision, ex));
LOGGER.error(String.format("Failed to parse configuration material %s by %s", material.getDisplayName(), plugin.displayName()));
String message = String.format("Parsing configuration repository using %s failed for material: %s", plugin.displayName(), material.getLongDescription());
String errorDescription = ex.getMessage() == null ? ex.toString() : ex.getMessage();
serverHealthService.update(ServerHealthState.error(message, errorDescription, HealthStateType.general(scope)));
notifyFailureListeners(repoConfig, ex);
}
}
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class ConfigSaveDeadlockDetectionIntegrationTest method configRepoDeleteThread.
private Thread configRepoDeleteThread(final ConfigRepoConfig configRepoToBeDeleted, final int counter) throws InterruptedException {
return createThread(new Runnable() {
@Override
public void run() {
goConfigService.updateConfig(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
ConfigRepoConfig repoConfig = ListUtil.find(cruiseConfig.getConfigRepos(), new ListUtil.Condition() {
@Override
public <T> boolean isMet(T item) {
ConfigRepoConfig configRepoConfig = (ConfigRepoConfig) item;
return configRepoToBeDeleted.getMaterialConfig().equals(configRepoConfig.getMaterialConfig());
}
});
cruiseConfig.getConfigRepos().remove(repoConfig);
return cruiseConfig;
}
});
}
}, "config-repo-delete-thread" + counter);
}
Aggregations