use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ClusterProfileDTO method toDomainModel.
public ClusterProfile toDomainModel() {
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
this.properties.forEach((key, value) -> {
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey(key), new ConfigurationValue(value)));
});
ClusterProfile clusterProfile = new ClusterProfile(this.id, this.pluginId);
clusterProfile.addConfigurations(configurationProperties);
return clusterProfile;
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ReplaceElasticAgentInformationCommand method update.
@Override
public CruiseConfig update(CruiseConfig preprocessedConfig) throws Exception {
String pluginId = pluginDescriptor.id();
List<ClusterProfile> clusterProfiles = clusterProfilesService.getPluginProfiles().findByPluginId(pluginId);
List<ElasticProfile> elasticAgentProfiles = elasticProfileService.findElasticAgentProfilesByPluginId(pluginId);
ElasticAgentInformation elasticAgentInformation = new ElasticAgentInformation(pluginSettings, clusterProfiles, elasticAgentProfiles);
ElasticAgentInformation migratedElasticAgentInformation = elasticAgentExtension.migrateConfig(pluginId, elasticAgentInformation);
List<ClusterProfile> migratedClusterProfiles = migratedElasticAgentInformation.getClusterProfiles();
List<ElasticProfile> migratedElasticAgentProfiles = migratedElasticAgentInformation.getElasticAgentProfiles();
preprocessedConfig.getElasticConfig().getClusterProfiles().removeAll(clusterProfiles);
preprocessedConfig.getElasticConfig().getClusterProfiles().addAll(migratedClusterProfiles);
preprocessedConfig.getElasticConfig().getProfiles().removeAll(elasticAgentProfiles);
preprocessedConfig.getElasticConfig().getProfiles().addAll(migratedElasticAgentProfiles);
return preprocessedConfig;
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class UpdateClusterProfileCommand method update.
@Override
public void update(CruiseConfig preprocessedConfig) throws Exception {
ClusterProfile existingClusterProfile = findExistingProfile(preprocessedConfig);
ClusterProfiles clusterProfiles = getPluginProfiles(preprocessedConfig);
clusterProfiles.set(clusterProfiles.indexOf(existingClusterProfile), profile);
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class InstanceFactoryTest method shouldAddElasticProfileAndClusterProfileOnJobPlan.
@Test
void shouldAddElasticProfileAndClusterProfileOnJobPlan() {
ElasticProfile elasticProfile = new ElasticProfile("id", "clusterId");
ClusterProfile clusterProfile = new ClusterProfile("clusterId", "pluginId");
DefaultSchedulingContext context = new DefaultSchedulingContext("foo", new Agents(), ImmutableMap.of("id", elasticProfile), ImmutableMap.of("clusterId", clusterProfile));
ArtifactTypeConfigs artifactTypeConfigs = new ArtifactTypeConfigs();
JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test"), null, artifactTypeConfigs);
jobConfig.setElasticProfileId("id");
JobPlan plan = instanceFactory.createJobPlan(jobConfig, context);
assertThat(plan.getElasticProfile(), is(elasticProfile));
assertThat(plan.getClusterProfile(), is(clusterProfile));
}
use of com.thoughtworks.go.config.elastic.ClusterProfile in project gocd by gocd.
the class ClusterProfilesChangedPluginNotifierTest method shouldSendResolveConfigValuesForBothClusterProfile.
@Test
void shouldSendResolveConfigValuesForBothClusterProfile() {
ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", "{{SECRET:[id][key1]}}");
ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", "{{SECRET:[id][key2]}}");
String newPluginId = "updated-plugin-id";
newClusterProfile = new ClusterProfile("profile1", newPluginId, properties);
oldClusterProfile.add(k1);
newClusterProfile.add(k2);
reset(goConfigService);
ElasticConfig elasticConfig = new ElasticConfig();
elasticConfig.getClusterProfiles().add(oldClusterProfile);
when(goConfigService.getElasticConfig()).thenReturn(elasticConfig);
doAnswer(invocation -> {
k2.getSecretParams().get(0).setValue("new-resolved-value");
return null;
}).when(secretParamResolver).resolve(newClusterProfile);
doAnswer(invocation -> {
k1.getSecretParams().get(0).setValue("old-resolved-value");
return null;
}).when(secretParamResolver).resolve(oldClusterProfile);
notifier = new ClusterProfilesChangedPluginNotifier(goConfigService, registry, secretParamResolver, serverHealthService);
notifier.onEntityConfigChange(newClusterProfile);
verify(secretParamResolver).resolve(newClusterProfile);
verify(secretParamResolver).resolve(oldClusterProfile);
verify(registry).notifyPluginAboutClusterProfileChanged(this.pluginId, ClusterProfilesChangedStatus.DELETED, oldClusterProfile.getConfigurationAsMap(true, true), null);
verify(registry).notifyPluginAboutClusterProfileChanged(newPluginId, ClusterProfilesChangedStatus.CREATED, null, newClusterProfile.getConfigurationAsMap(true, true));
verifyNoMoreInteractions(registry);
verify(goConfigService, times(3)).getElasticConfig();
verifyNoInteractions(serverHealthService);
}
Aggregations