Search in sources :

Example 31 with ClusterProfile

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

the class UpdateClusterProfileCommandTest method shouldValidateElasticAgentProfilesAsPartOfUpdateClusterProfile.

@Test
void shouldValidateElasticAgentProfilesAsPartOfUpdateClusterProfile() {
    ElasticConfig elasticConfig = new ElasticConfig();
    elasticConfig.getClusterProfiles().add(new ClusterProfile("cluster1", "ecs"));
    elasticConfig.getProfiles().add(new ElasticProfile("profile1", "cluster1"));
    config.setElasticConfig(elasticConfig);
    RecordNotFoundException exception = assertThrows(RecordNotFoundException.class, () -> command.isValid(config));
    assertThat(exception.getMessage()).isEqualTo("Cluster profile with id 'cluster-id' was not found!");
}
Also used : RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) ElasticConfig(com.thoughtworks.go.config.elastic.ElasticConfig) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Test(org.junit.jupiter.api.Test)

Example 32 with ClusterProfile

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

the class ClusterProfileRepresenter method fromJSON.

public static ClusterProfile fromJSON(JsonReader jsonReader) {
    ClusterProfile clusterProfile = new ClusterProfile(jsonReader.getString("id"), jsonReader.getString("plugin_id"));
    clusterProfile.addConfigurations(ConfigurationPropertyRepresenter.fromJSONArray(jsonReader, "properties"));
    return clusterProfile;
}
Also used : ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Example 33 with ClusterProfile

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

the class ClusterProfilesControllerV1 method getClusterProfile.

public String getClusterProfile(Request request, Response response) throws IOException {
    final ClusterProfile clusterProfile = fetchEntityFromConfig(request.params("cluster_id"));
    String etag = etagFor(clusterProfile);
    if (fresh(request, etag)) {
        return notModified(response);
    }
    setEtagHeader(response, etag);
    return writerForTopLevelObject(request, response, jsonWriter(clusterProfile));
}
Also used : ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Example 34 with ClusterProfile

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

the class ElasticProfileControllerV2 method create.

public String create(Request request, Response response) {
    final ElasticProfile elasticProfileToCreate = buildEntityFromRequestBody(request);
    haltIfEntityWithSameIdExists(elasticProfileToCreate);
    ClusterProfile associatedClusterProfile = clusterProfilesService.findProfile(elasticProfileToCreate.getClusterProfileId());
    haltIfSpecifiedClusterProfileDoesntExists(associatedClusterProfile, elasticProfileToCreate);
    final HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
    elasticProfileService.create(currentUsername(), elasticProfileToCreate, operationResult);
    return handleCreateOrUpdateResponse(request, response, elasticProfileToCreate, operationResult);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Example 35 with ClusterProfile

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

the class ElasticProfileControllerV2 method update.

public String update(Request request, Response response) {
    final String profileId = request.params(PROFILE_ID_PARAM);
    final ElasticProfile existingElasticProfile = fetchEntityFromConfig(profileId);
    final ElasticProfile newElasticProfile = buildEntityFromRequestBody(request);
    if (isRenameAttempt(profileId, newElasticProfile.getId())) {
        throw haltBecauseRenameOfEntityIsNotSupported("elasticProfile");
    }
    if (isPutRequestStale(request, existingElasticProfile)) {
        throw haltBecauseEtagDoesNotMatch("elasticProfile", existingElasticProfile.getId());
    }
    ClusterProfile associatedClusterProfile = clusterProfilesService.findProfile(newElasticProfile.getClusterProfileId());
    haltIfSpecifiedClusterProfileDoesntExists(associatedClusterProfile, newElasticProfile);
    final HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
    elasticProfileService.update(currentUsername(), etagFor(existingElasticProfile), newElasticProfile, operationResult);
    return handleCreateOrUpdateResponse(request, response, newElasticProfile, operationResult);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) 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