use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class GoConfigMigratorIntegrationTest method shouldAllowOnlyRepositoryConfiguration.
@Test
public void shouldAllowOnlyRepositoryConfiguration() throws Exception {
String configString = "<cruise schemaVersion='66'>" + "<repositories>" + "<repository id='go-repo' name='go-repo'>" + " <pluginConfiguration id='plugin-id' version='1.0'/>" + " <configuration>" + " <property><key>url</key><value>http://fake-yum-repo</value></property>" + " <property><key>username</key><value>godev</value></property>" + " <property><key>password</key><value>password</value></property>" + " </configuration>" + "</repository>" + "</repositories>" + "</cruise>";
CruiseConfig cruiseConfig = loadConfigFileWithContent(configString);
PackageRepositories packageRepositories = cruiseConfig.getPackageRepositories();
assertThat(packageRepositories.size()).isEqualTo(1);
assertThat(packageRepositories.get(0).getId()).isEqualTo("go-repo");
assertThat(packageRepositories.get(0).getName()).isEqualTo("go-repo");
assertThat(packageRepositories.get(0).getPluginConfiguration().getId()).isEqualTo("plugin-id");
assertThat(packageRepositories.get(0).getPluginConfiguration().getVersion()).isEqualTo("1.0");
assertThat(packageRepositories.get(0).getConfiguration()).isNotNull();
assertThat(packageRepositories.get(0).getPackages().size()).isEqualTo(0);
assertConfiguration(packageRepositories.get(0).getConfiguration(), asList(new List[] { asList("url", Boolean.FALSE, "http://fake-yum-repo"), asList("username", Boolean.FALSE, "godev"), asList("password", Boolean.FALSE, "password") }));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class UpdatePackageConfigCommand method update.
@Override
public void update(CruiseConfig modifiedConfig) {
PackageRepositories packageRepositories = modifiedConfig.getPackageRepositories();
PackageRepository repository = packageRepositories.findPackageRepositoryHaving(oldPackageId);
int index = packageRepositories.indexOf(repository);
newPackage.setRepository(repository);
repository.removePackage(oldPackageId);
repository.addPackage(this.newPackage);
packageRepositories.replace(index, repository);
modifiedConfig.setPackageRepositories(packageRepositories);
updatePackageConfigurationOnAssociatedPipelines(modifiedConfig);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class CreatePackageConfigCommand method update.
@Override
public void update(CruiseConfig modifiedConfig) {
PackageRepositories packageRepositories = modifiedConfig.getPackageRepositories();
PackageRepository packageRepository = packageRepositories.find(repositoryId);
int index = packageRepositories.indexOf(packageRepository);
packageDefinition.setRepository(packageRepository);
packageRepository.addPackage(this.packageDefinition);
packageRepositories.replace(index, packageRepository);
modifiedConfig.setPackageRepositories(packageRepositories);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class DeletePackageRepositoryCommand method update.
@Override
public void update(CruiseConfig modifiedConfig) {
existingPackageRepository = modifiedConfig.getPackageRepositories().find(repository.getRepoId());
PackageRepositories packageRepositories = modifiedConfig.getPackageRepositories();
packageRepositories.removePackageRepository(this.repository.getId());
modifiedConfig.setPackageRepositories(packageRepositories);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class PackageRepositoryCommand method isValid.
@Override
public boolean isValid(CruiseConfig preprocessedConfig) {
PackageRepositories repositories = preprocessedConfig.getPackageRepositories();
this.preprocessedRepository = repositories.find(this.repository.getRepoId());
preprocessedRepository.validate(null);
repositories.validate(null);
boolean isValidConfiguration = packageRepositoryService.validatePluginId(preprocessedRepository) && packageRepositoryService.validateRepositoryConfiguration(preprocessedRepository);
BasicCruiseConfig.copyErrors(preprocessedRepository, this.repository);
return getAllErrors(this.repository).isEmpty() && isValidConfiguration && result.isSuccessful();
}
Aggregations