Search in sources :

Example 46 with PackageRepositories

use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.

the class PackageConfigCommand method isValid.

public boolean isValid(CruiseConfig preprocessedConfig, String repositoryId) {
    PackageRepositories packageRepositories = preprocessedConfig.getPackageRepositories();
    PackageRepository repository = packageRepositories.find(repositoryId);
    Packages packages = repository.getPackages();
    preprocessedPackageDefinition = packages.find(this.packageDefinition.getId());
    preprocessedPackageDefinition.validate(null);
    if (preprocessedPackageDefinition.getAllErrors().isEmpty()) {
        packageRepositories.validate(null);
        packages.validate(null);
        packageDefinitionService.validatePackageConfiguration(preprocessedPackageDefinition);
        BasicCruiseConfig.copyErrors(preprocessedPackageDefinition, packageDefinition);
        return preprocessedPackageDefinition.getAllErrors().isEmpty() && result.isSuccessful();
    }
    BasicCruiseConfig.copyErrors(preprocessedPackageDefinition, packageDefinition);
    return false;
}
Also used : Packages(com.thoughtworks.go.domain.packagerepository.Packages) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 47 with PackageRepositories

use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.

the class CreatePackageRepositoryCommand method update.

@Override
public void update(CruiseConfig modifiedConfig) {
    PackageRepositories repositories = modifiedConfig.getPackageRepositories();
    repositories.add(this.repository);
    modifiedConfig.setPackageRepositories(repositories);
}
Also used : PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories)

Example 48 with PackageRepositories

use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.

the class ConfigConverterTest method shouldConvertPackageMaterialConfig.

@Test
void shouldConvertPackageMaterialConfig() {
    PackageRepositories repositories = new PackageRepositories();
    PackageRepository packageRepository = new PackageRepository();
    PackageDefinition definition = new PackageDefinition("package-id", "n", new Configuration());
    packageRepository.addPackage(definition);
    repositories.add(packageRepository);
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setPackageRepositories(repositories);
    when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
    PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(new CaseInsensitiveString("name"), "package-id", definition);
    CRPackageMaterial crPackageMaterial = (CRPackageMaterial) configConverter.materialToCRMaterial(packageMaterialConfig);
    assertThat(crPackageMaterial.getName()).isEqualTo("name");
    assertThat(crPackageMaterial.getPackageId()).isEqualTo("package-id");
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.jupiter.api.Test)

Example 49 with PackageRepositories

use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.

the class GoConfigMigratorIntegrationTest method shouldValidatePackageRepositoriesConfiguration.

@Test
public void shouldValidatePackageRepositoriesConfiguration() 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>" + "     <packages>" + "         <package id='go-server' name='go-server'>" + "             <configuration>" + "                 <property><key>name</key><value>go-server-13.2.0-1-i386</value></property>" + "             </configuration>" + "         </package>" + "     </packages>" + "</repository>" + "</repositories>" + "</cruise>";
    CruiseConfig cruiseConfig = migrateConfigAndLoadTheNewConfig(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(1);
    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") }));
    assertThat(packageRepositories.get(0).getPackages().get(0).getId()).isEqualTo("go-server");
    assertThat(packageRepositories.get(0).getPackages().get(0).getName()).isEqualTo("go-server");
    assertConfiguration(packageRepositories.get(0).getPackages().get(0).getConfiguration(), asList(new List[] { asList("name", Boolean.FALSE, "go-server-13.2.0-1-i386") }));
}
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 50 with PackageRepositories

use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.

the class PackageRepositoryServiceIntegrationTest method tearDown.

@AfterEach
public void tearDown() throws Exception {
    configHelper.onTearDown();
    pluginSqlMapDao.deleteAllPlugins();
    goConfigService.getConfigForEditing().setPackageRepositories(new PackageRepositories());
}
Also used : PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) AfterEach(org.junit.jupiter.api.AfterEach)

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