Search in sources :

Example 11 with ElasticProfiles

use of com.thoughtworks.go.config.elastic.ElasticProfiles in project gocd by gocd.

the class PipelineConfigSaveValidationContextTest method isValidProfileIdShouldBeValidInPresenceOfElasticProfile.

@Test
void isValidProfileIdShouldBeValidInPresenceOfElasticProfile() {
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    ElasticConfig elasticConfig = new ElasticConfig();
    elasticConfig.setProfiles(new ElasticProfiles(new ElasticProfile("docker.unit-test", "prod-cluster")));
    cruiseConfig.setElasticConfig(elasticConfig);
    ValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig, new PipelineConfig());
    assertTrue(context.isValidProfileId("docker.unit-test"));
}
Also used : ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.jupiter.api.Test)

Example 12 with ElasticProfiles

use of com.thoughtworks.go.config.elastic.ElasticProfiles in project gocd by gocd.

the class PipelineConfigSaveValidationContextTest method isValidProfileIdShouldBeInValidInAbsenceOfElasticProfileForTheGivenId.

@Test
void isValidProfileIdShouldBeInValidInAbsenceOfElasticProfileForTheGivenId() {
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    ElasticConfig elasticConfig = new ElasticConfig();
    elasticConfig.setProfiles(new ElasticProfiles(new ElasticProfile("docker.unit-test", "prod-cluster")));
    cruiseConfig.setElasticConfig(elasticConfig);
    ValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig, new PipelineConfig());
    assertThat(context.isValidProfileId("invalid.profile-id")).isFalse();
}
Also used : ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.jupiter.api.Test)

Example 13 with ElasticProfiles

use of com.thoughtworks.go.config.elastic.ElasticProfiles in project gocd by gocd.

the class ElasticAgentProfileUpdateCommand method update.

@Override
public void update(CruiseConfig preprocessedConfig) {
    ElasticProfile existingProfile = findExistingProfile(preprocessedConfig);
    ElasticProfiles profiles = getPluginProfiles(preprocessedConfig);
    profiles.set(profiles.indexOf(existingProfile), elasticProfile);
}
Also used : ElasticProfiles(com.thoughtworks.go.config.elastic.ElasticProfiles) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile)

Aggregations

ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)13 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)12 Test (org.junit.jupiter.api.Test)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Test (org.junit.Test)4 ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)2 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)1 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)1 ClusterProfiles (com.thoughtworks.go.config.elastic.ClusterProfiles)1 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1 ConfigErrors (com.thoughtworks.go.domain.ConfigErrors)1