@Override public void onConfigChange(CruiseConfig newCruiseConfig) { ConfigReposConfig partSources = newCruiseConfig.getConfigRepos(); this.reposConfig = partSources; notifyListeners(partSources); }
@Override public void update(CruiseConfig preprocessedConfig) { preprocessedConfig.getConfigRepos().add(configRepo); } }
@Override public ConfigReposConfig getConfigRepos() { return getCruiseConfig().getConfigRepos(); }
public ConfigReposConfig getConfigRepos() { return goConfigService.getConfigForEditing().getConfigRepos(); }
private boolean doesConfigRepoExist(CruiseConfig cruiseConfig) { return cruiseConfig.getConfigRepos().getConfigRepo(repoId) != null; }
public boolean isRemovedFromConfig(CruiseConfig cruiseConfig, String materialScope) { for (ConfigRepoConfig configRepoConfig : cruiseConfig.getConfigRepos()) { if (HealthStateScope.forPartialConfigRepo(configRepoConfig).getScope().equals(materialScope)) { return false; } } return true; } },
@Autowired public GoConfigWatchList(CachedGoConfig cachedGoConfig, GoConfigService goConfigService) { this.reposConfig = cachedGoConfig.currentConfig().getConfigRepos(); this.goConfigService = goConfigService; cachedGoConfig.registerListener(this); }
@Override public void update(CruiseConfig preprocessedConfig) { ConfigReposConfig configRepos = preprocessedConfig.getConfigRepos(); configRepos.replace(configRepos.getConfigRepo(repoIdToUpdate), newConfigRepo); }
@Override public void update(CruiseConfig preprocessedConfig) { ConfigReposConfig configRepos = preprocessedConfig.getConfigRepos(); preprocessedConfigRepo = configRepos.getConfigRepo(repoId); configRepos.remove(preprocessedConfigRepo); }
public ConfigRepoConfig getConfigRepo(String repoId) { return goConfigService.getConfigForEditing().getConfigRepos().getConfigRepo(repoId); }
private void validateUniquenessOfId(ValidationContext validationContext) { if (!validationContext.getCruiseConfig().getConfigRepos().isUniqueId(id)) { this.errors.add(ID, format("You have defined multiple configuration repositories with the same id - '%s'.", id)); } }
private boolean isRequestFresh(CruiseConfig cruiseConfig) { ConfigRepoConfig configRepo = cruiseConfig.getConfigRepos().getConfigRepo(repoIdToUpdate); boolean freshRequest = entityHashingService.md5ForEntity(configRepo).equals(md5); if (!freshRequest) { result.stale(staleResourceConfig("Config repo", repoIdToUpdate)); } return freshRequest; } }
private void validateMaterialUniqueness(ValidationContext validationContext) { if (this.getMaterialConfig() != null) { if (!validationContext.getCruiseConfig().getConfigRepos().isUniqueMaterial(this.getMaterialConfig().getFingerprint())) { this.errors.add("material", format( "You have defined multiple configuration repositories with the same repository - '%s'.", this.repo.getDisplayName())); } } }
@Test public void shouldReturnConfigRepos() { assertNotNull(cruiseConfig.getConfigRepos()); }
@Test public void shouldLoadConfigWithConfigRepo() throws Exception { CruiseConfig cruiseConfig = xmlLoader.loadConfigHolder(ONE_CONFIG_REPO).config; assertThat(cruiseConfig.getConfigRepos().size(), is(1)); ConfigRepoConfig configRepo = cruiseConfig.getConfigRepos().get(0); assertThat(configRepo.getMaterialConfig(), is(new GitMaterialConfig("https://github.com/tomzo/gocd-indep-config-part.git"))); }
@Test public void shouldLoadConfigWithConfigRepoAndPluginName() throws Exception { CruiseConfig cruiseConfig = xmlLoader.loadConfigHolder(configWithConfigRepos( " <config-repos>\n" + " <config-repo pluginId=\"myplugin\" id=\"repo-id\">\n" + " <git url=\"https://github.com/tomzo/gocd-indep-config-part.git\" />\n" + " </config-repo >\n" + " </config-repos>\n" )).config; assertThat(cruiseConfig.getConfigRepos().size(), is(1)); ConfigRepoConfig configRepo = cruiseConfig.getConfigRepos().get(0); assertThat(configRepo.getPluginId(), is("myplugin")); }
@Override public void onEntityConfigChange(ConfigRepoConfig newConfigRepo) { this.reposConfig.remove(this.reposConfig.getConfigRepo(newConfigRepo.getId())); if(goConfigService.currentCruiseConfig().getConfigRepos().getConfigRepo(newConfigRepo.getId()) != null) { this.reposConfig.add(newConfigRepo); } notifyListeners(this.reposConfig); }
@Override public boolean isValid(CruiseConfig preprocessedConfig) { validateConfigRepoId(this.configRepo); validateConfigRepoPluginId(this.configRepo); if (!this.configRepo.errors().isEmpty()) { return false; } preprocessedConfigRepo = preprocessedConfig.getConfigRepos().getConfigRepo(this.configRepo.getId()); if (!preprocessedConfigRepo.validateTree(new ConfigSaveValidationContext(preprocessedConfig))) { BasicCruiseConfig.copyErrors(preprocessedConfigRepo, configRepo); return false; } return true; }
@Test public void shouldNotRemoveScopeWhenMaterialBelongsToConfigRepoMaterial() throws Exception { HgMaterialConfig hgMaterialConfig = MaterialConfigsMother.hgMaterialConfig(); CruiseConfig config = GoConfigMother.pipelineHavingJob("blahPipeline", "blahStage", "blahJob", "fii", "baz"); config.getConfigRepos().add(new ConfigRepoConfig(hgMaterialConfig, "id1", "foo")); assertThat(HealthStateScope.forMaterialConfig(hgMaterialConfig).isRemovedFromConfig(config),is(false)); }
@Test public void shouldNotRemoveScopeWhenMaterialUpdateBelongsToConfigRepoMaterial() throws Exception { HgMaterialConfig hgMaterialConfig = MaterialConfigsMother.hgMaterialConfig(); CruiseConfig config = GoConfigMother.pipelineHavingJob("blahPipeline", "blahStage", "blahJob", "fii", "baz"); config.getConfigRepos().add(new ConfigRepoConfig(hgMaterialConfig, "id1", "foo")); assertThat(HealthStateScope.forMaterialConfigUpdate(hgMaterialConfig).isRemovedFromConfig(config),is(false)); }