use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ClusterProfilesControllerV1 method create.
public String create(Request request, Response response) throws IOException {
ClusterProfile clusterProfile = buildEntityFromRequestBody(request);
haltIfEntityWithSameIdExists(clusterProfile);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
clusterProfilesService.create(clusterProfile, currentUsername(), result);
return handleCreateOrUpdateResponse(request, response, clusterProfile, result);
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ClusterProfilesControllerV1 method update.
public String update(Request request, Response response) throws IOException {
final String profileId = request.params("cluster_id");
final ClusterProfile existingClusterProfile = fetchEntityFromConfig(profileId);
final ClusterProfile newClusterProfile = buildEntityFromRequestBody(request);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
if (isRenameAttempt(profileId, newClusterProfile.getId())) {
throw haltBecauseRenameOfEntityIsNotSupported("Cluster Profile");
}
if (isPutRequestStale(request, existingClusterProfile)) {
throw haltBecauseEtagDoesNotMatch("Cluster Profile", existingClusterProfile.getId());
}
clusterProfilesService.update(newClusterProfile, currentUsername(), result);
return handleCreateOrUpdateResponse(request, response, newClusterProfile, result);
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ClusterProfilesControllerV1 method deleteClusterProfile.
String deleteClusterProfile(Request req, Response res) {
ClusterProfile clusterProfile = fetchEntityFromConfig(req.params("cluster_id"));
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
clusterProfilesService.delete(clusterProfile, currentUsername(), result);
return handleSimpleMessageResponse(res, result);
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class BasicCruiseConfigTest method shouldEncryptElasticAgentProfileConfigProperties.
@Test
public void shouldEncryptElasticAgentProfileConfigProperties(ResetCipher resetCipher) throws IOException, CryptoException {
setEAPluginInfo();
resetCipher.setupAESCipherFile();
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.getElasticConfig().getClusterProfiles().add(new ClusterProfile("prod-cluster", "ecs"));
ElasticProfile elasticProfile = new ElasticProfile("profile1", "prod-cluster");
elasticProfile.addConfigurations(asList(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("pub_v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("pub_v2")), new ConfigurationProperty(new ConfigurationKey("k3"), new ConfigurationValue("pub_v3"))));
cruiseConfig.getElasticConfig().getProfiles().add(elasticProfile);
BasicCruiseConfig preprocessed = GoConfigMother.deepClone(cruiseConfig);
new ConfigParamPreprocessor().process(preprocessed);
cruiseConfig.encryptSecureProperties(preprocessed);
Configuration properties = cruiseConfig.getElasticConfig().getProfiles().get(0);
GoCipher goCipher = new GoCipher();
assertThat(properties.getProperty("k1").getEncryptedValue(), is(goCipher.encrypt("pub_v1")));
assertThat(properties.getProperty("k1").getConfigValue(), is(nullValue()));
assertThat(properties.getProperty("k1").getValue(), is("pub_v1"));
assertThat(properties.getProperty("k2").getEncryptedValue(), is(nullValue()));
assertThat(properties.getProperty("k2").getConfigValue(), is("pub_v2"));
assertThat(properties.getProperty("k2").getValue(), is("pub_v2"));
assertThat(properties.getProperty("k3").getEncryptedValue(), is(goCipher.encrypt("pub_v3")));
assertThat(properties.getProperty("k3").getConfigValue(), is(nullValue()));
assertThat(properties.getProperty("k3").getValue(), is("pub_v3"));
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class JobInstanceMother method jobPlanWithAssociatedEntities.
public static JobPlan jobPlanWithAssociatedEntities(String jobName, long id, List<ArtifactPlan> artifactPlans) {
ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey("image"), new ConfigurationValue("elastic-agent"));
ConfigurationProperty clusterconfigurationProperty = new ConfigurationProperty(new ConfigurationKey("Url"), new ConfigurationValue("aws.com"));
ElasticProfile elasticProfile = new ElasticProfile("elastic", "clusterId", configurationProperty);
ClusterProfile clusterProfile = new ClusterProfile("clusterId", "plugin", clusterconfigurationProperty);
EnvironmentVariables variables = new EnvironmentVariables();
variables.add("some_var", "blah");
return new DefaultJobPlan(new Resources(new Resource("foo"), new Resource("bar")), artifactPlans, id, defaultJobIdentifier(jobName), null, variables, new EnvironmentVariables(), elasticProfile, clusterProfile);
}
Aggregations