Search in sources :

Example 51 with ConfigErrors

use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.

the class ConfigRepoCommand method isValid.

@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());
    preprocessedConfigRepo.validateTree(new ConfigSaveValidationContext(preprocessedConfig));
    List<ConfigErrors> allErrors = ErrorCollector.getAllErrors(preprocessedConfigRepo);
    if (!allErrors.isEmpty()) {
        BasicCruiseConfig.copyErrors(preprocessedConfigRepo, configRepo);
        return false;
    }
    return true;
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) ConfigErrors(com.thoughtworks.go.domain.ConfigErrors)

Example 52 with ConfigErrors

use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.

the class UpdatePipelineConfigCommandTest method updatePipelineConfigShouldValidateAllExternalArtifacts.

@Test
void updatePipelineConfigShouldValidateAllExternalArtifacts() {
    PluggableArtifactConfig s3 = mock(PluggableArtifactConfig.class);
    PluggableArtifactConfig docker = mock(PluggableArtifactConfig.class);
    when(goConfigService.artifactStores()).thenReturn(mock(ArtifactStores.class));
    when(goConfigService.findGroupNameByPipeline(new CaseInsensitiveString("P1"))).thenReturn("group");
    ConfigErrors configErrors = new ConfigErrors();
    when(s3.errors()).thenReturn(configErrors);
    when(docker.errors()).thenReturn(configErrors);
    JobConfig job1 = JobConfigMother.jobWithNoResourceRequirement();
    JobConfig job2 = JobConfigMother.jobWithNoResourceRequirement();
    job1.artifactTypeConfigs().add(s3);
    job2.artifactTypeConfigs().add(docker);
    PipelineConfig pipeline = PipelineConfigMother.pipelineConfig("P1", new StageConfig(new CaseInsensitiveString("S1"), new JobConfigs(job1)), new StageConfig(new CaseInsensitiveString("S2"), new JobConfigs(job2)));
    UpdatePipelineConfigCommand command = new UpdatePipelineConfigCommand(goConfigService, null, pipeline, "group", username, "stale_digest", localizedOperationResult, externalArtifactsService);
    BasicCruiseConfig preprocessedConfig = GoConfigMother.defaultCruiseConfig();
    preprocessedConfig.addPipelineWithoutValidation("group", pipeline);
    command.isValid(preprocessedConfig);
    verify(externalArtifactsService).validateExternalArtifactConfig(eq(s3), any(), eq(true));
    verify(externalArtifactsService).validateExternalArtifactConfig(eq(docker), any(), eq(true));
}
Also used : ConfigErrors(com.thoughtworks.go.domain.ConfigErrors) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigErrors (com.thoughtworks.go.domain.ConfigErrors)52 Test (org.junit.jupiter.api.Test)35 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)6 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Cloner (com.rits.cloning.Cloner)1 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 EnvironmentAgentConfig (com.thoughtworks.go.config.EnvironmentAgentConfig)1 EnvironmentConfig (com.thoughtworks.go.config.EnvironmentConfig)1 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)1 IgnoreTraversal (com.thoughtworks.go.config.IgnoreTraversal)1 Validatable (com.thoughtworks.go.config.Validatable)1 ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)1 GoConfigInvalidMergeException (com.thoughtworks.go.config.exceptions.GoConfigInvalidMergeException)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1