Search in sources :

Example 1 with PackageDefinition

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

the class PackageMaterialAddWithExistingPackageDefinitionCommand method updateConfig.

@Override
protected void updateConfig(CruiseConfig cruiseConfig) {
    PackageDefinition packageDefinition = getPackageDefinition(cruiseConfig);
    packageMaterialConfig.setPackageDefinition(packageDefinition);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline));
    pipelineConfig.addMaterialConfig(packageMaterialConfig);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 2 with PackageDefinition

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

the class PackageMaterialAddWithNewPackageDefinitionCommand method updateConfig.

@Override
protected void updateConfig(CruiseConfig cruiseConfig) {
    PackageDefinition packageDefinition = createNewPackageDefinition(cruiseConfig);
    packageMaterialConfig.setPackageDefinition(packageDefinition);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline));
    pipelineConfig.addMaterialConfig(packageMaterialConfig);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 3 with PackageDefinition

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

the class PackageMaterialUpdateWithExistingPackageDefinitionCommand method updateConfig.

@Override
protected void updateConfig(CruiseConfig cruiseConfig) {
    PackageDefinition packageDefinition = getPackageDefinition(cruiseConfig);
    packageMaterialConfig = (PackageMaterialConfig) cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline)).materialConfigs().get(packageMaterialConfig);
    packageMaterialConfig.setPackageDefinition(packageDefinition);
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 4 with PackageDefinition

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

the class PackageMaterialUpdateWithNewPackageDefinitionCommand method updateConfig.

@Override
protected void updateConfig(CruiseConfig cruiseConfig) {
    PackageDefinition packageDefinition = createNewPackageDefinition(cruiseConfig);
    packageMaterialConfig = (PackageMaterialConfig) cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline)).materialConfigs().get(packageMaterialConfig);
    packageMaterialConfig.setPackageDefinition(packageDefinition);
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 5 with PackageDefinition

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

the class UpdatePackageConfigCommandTest method shouldValidateDuplicateIdentity.

@Test
public void shouldValidateDuplicateIdentity() throws Exception {
    PackageRepository repository = cruiseConfig.getPackageRepositories().find("repoId");
    PackageDefinition pkg = new PackageDefinition("Id", "name", configuration);
    pkg.setRepository(repository);
    repository.addPackage(pkg);
    cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
    UpdatePackageConfigCommand command = new UpdatePackageConfigCommand(goConfigService, packageUuid, newPackageDefinition, currentUser, "md5", this.entityHashingService, result, packageDefinitionService);
    command.update(cruiseConfig);
    assertFalse(command.isValid(cruiseConfig));
    assertThat(newPackageDefinition.errors().size(), is(1));
    assertThat(newPackageDefinition.errors().firstError(), is("Cannot save package or repo, found duplicate packages. [Repo Name: 'repoName', Package Name: 'name'], [Repo Name: 'repoName', Package Name: 'prettyjson']"));
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Aggregations

PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)71 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)38 Test (org.junit.jupiter.api.Test)36 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)28 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)13 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 Packages (com.thoughtworks.go.domain.packagerepository.Packages)11 Test (org.junit.Test)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)8 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)8 Serializable (java.io.Serializable)7 Configuration (com.thoughtworks.go.domain.config.Configuration)6 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)4 SCM (com.thoughtworks.go.domain.scm.SCM)4 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)4 XsdValidationException (com.thoughtworks.go.util.XsdValidationException)4 Timestamp (java.sql.Timestamp)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4