Search in sources :

Example 16 with ClusterProfile

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);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Example 17 with ClusterProfile

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);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Example 18 with ClusterProfile

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);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Example 19 with ClusterProfile

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"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) GoCipher(com.thoughtworks.go.security.GoCipher) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) ConfigParamPreprocessor(com.thoughtworks.go.config.preprocessor.ConfigParamPreprocessor) Test(org.junit.jupiter.api.Test)

Example 20 with ClusterProfile

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);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Aggregations

ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)69 Test (org.junit.jupiter.api.Test)39 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)32 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)14 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)12 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)10 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)10 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)10 ClusterProfiles (com.thoughtworks.go.config.elastic.ClusterProfiles)8 Username (com.thoughtworks.go.server.domain.Username)8 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 ElasticConfig (com.thoughtworks.go.config.elastic.ElasticConfig)6 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)6 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)5 JobAgentMetadata (com.thoughtworks.go.domain.JobAgentMetadata)4 ElasticAgentInformation (com.thoughtworks.go.plugin.access.elastic.models.ElasticAgentInformation)4 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)4 GoCipher (com.thoughtworks.go.security.GoCipher)4