use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class PipelineConfigSaveValidationContextTest method isValidProfileIdShouldBeInValidInAbsenceOfElasticProfileForTheGivenId.
@Test
public void isValidProfileIdShouldBeInValidInAbsenceOfElasticProfileForTheGivenId() {
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.setProfiles(new ElasticProfiles(new ElasticProfile("docker.unit-test", "docker")));
cruiseConfig.setServerConfig(new ServerConfig(elasticConfig));
ValidationContext context = PipelineConfigSaveValidationContext.forChain(true, "group", cruiseConfig, new PipelineConfig());
assertFalse(context.isValidProfileId("invalid.profile-id"));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class JobAgentMetadata method elasticProfile.
public ElasticProfile elasticProfile() {
Gson gson = new Gson();
Map map = gson.fromJson(metadata, LinkedHashMap.class);
String pluginId = (String) map.get("pluginId");
String id = (String) map.get("id");
Map<String, String> properties = (Map<String, String>) map.get("properties");
Collection<ConfigurationProperty> configProperties = MapUtil.collect(properties, new ListUtil.Transformer<Map.Entry<String, String>, ConfigurationProperty>() {
@Override
public ConfigurationProperty transform(Map.Entry<String, String> entry) {
return new ConfigurationProperty(new ConfigurationKey(entry.getKey()), new ConfigurationValue(entry.getValue()));
}
});
return new ElasticProfile(id, pluginId, configProperties);
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class CreateAgentMessageTest method shouldGetPluginId.
@Test
public void shouldGetPluginId() {
List<ConfigurationProperty> properties = Arrays.asList(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
ElasticProfile jobAgentConfig = new ElasticProfile("foo", "plugin-id", properties);
CreateAgentMessage message = new CreateAgentMessage("key", "env", jobAgentConfig);
assertThat(message.pluginId(), is(jobAgentConfig.getPluginId()));
Map<String, String> configurationAsMap = jobAgentConfig.getConfigurationAsMap(true);
assertThat(message.configuration(), is(configurationAsMap));
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class InstanceFactory method createJobPlan.
public JobPlan createJobPlan(JobConfig config, SchedulingContext context) {
JobIdentifier identifier = new JobIdentifier();
String elasticProfileId = config.getElasticProfileId();
ElasticProfile elasticProfile = null;
if (elasticProfileId != null) {
elasticProfile = context.getElasticProfile(elasticProfileId);
}
return new DefaultJobPlan(config.resources(), config.artifactPlans(), config.getProperties(), -1, identifier, null, context.overrideEnvironmentVariables(config.getVariables()).getEnvironmentVariablesConfig(), new EnvironmentVariablesConfig(), elasticProfile);
}
use of com.thoughtworks.go.config.elastic.ElasticProfile in project gocd by gocd.
the class ElasticAgentProfileUpdateCommand method isRequestFresh.
private boolean isRequestFresh(CruiseConfig cruiseConfig) {
ElasticProfile existingProfile = findExistingProfile(cruiseConfig);
boolean freshRequest = hashingService.md5ForEntity(existingProfile).equals(md5);
if (!freshRequest) {
result.stale(LocalizedMessage.string("STALE_RESOURCE_CONFIG", getObjectDescriptor(), existingProfile.getId()));
}
return freshRequest;
}
Aggregations