Search in sources :

Example 26 with PackageRepositories

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") }));
}
Also used : PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 27 with PackageRepositories

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);
}
Also used : PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 28 with PackageRepositories

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);
}
Also used : PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 29 with 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);
}
Also used : PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories)

Example 30 with 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();
}
Also used : PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories)

Aggregations

PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)52 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)40 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)29 Test (org.junit.jupiter.api.Test)29 Packages (com.thoughtworks.go.domain.packagerepository.Packages)14 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)9 Test (org.junit.Test)8 Username (com.thoughtworks.go.server.domain.Username)7 BeforeEach (org.junit.jupiter.api.BeforeEach)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 XsdValidationException (com.thoughtworks.go.util.XsdValidationException)4 ArrayList (java.util.ArrayList)4 Arrays.asList (java.util.Arrays.asList)4 List (java.util.List)4 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)3 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)3 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)2 GoCipher (com.thoughtworks.go.security.GoCipher)2