Search in sources :

Example 21 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class ElasticAgentPluginService method heartbeat.

public void heartbeat() {
    LinkedMultiValueMap<String, ElasticAgentMetadata> elasticAgentsOfMissingPlugins = agentService.allElasticAgents();
    // pingMessage TTL is set lesser than elasticPluginHeartBeatInterval to ensure there aren't multiple ping request for the same plugin
    long pingMessageTimeToLive = elasticPluginHeartBeatInterval - 10000L;
    for (PluginDescriptor descriptor : elasticAgentPluginRegistry.getPlugins()) {
        elasticAgentsOfMissingPlugins.remove(descriptor.id());
        List<ClusterProfile> clusterProfiles = clusterProfilesService.getPluginProfiles().findByPluginId(descriptor.id());
        boolean secretsResolved = resolveSecrets(descriptor.id(), clusterProfiles);
        if (!secretsResolved)
            continue;
        serverPingQueue.post(new ServerPingMessage(descriptor.id(), clusterProfiles), pingMessageTimeToLive);
        serverHealthService.removeByScope(scope(descriptor.id()));
    }
    if (!elasticAgentsOfMissingPlugins.isEmpty()) {
        for (String pluginId : elasticAgentsOfMissingPlugins.keySet()) {
            Collection<String> uuids = elasticAgentsOfMissingPlugins.get(pluginId).stream().map(ElasticAgentMetadata::uuid).collect(toList());
            String description = format("Elastic agent plugin with identifier %s has gone missing, but left behind %s agent(s) with UUIDs %s.", pluginId, elasticAgentsOfMissingPlugins.get(pluginId).size(), uuids);
            serverHealthService.update(ServerHealthState.warning("Elastic agents with no matching plugins", description, general(scope(pluginId))));
            LOGGER.warn(description);
        }
    }
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) ServerPingMessage(com.thoughtworks.go.server.messaging.elasticagents.ServerPingMessage) ElasticAgentMetadata(com.thoughtworks.go.server.domain.ElasticAgentMetadata) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile)

Example 22 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class RoleConfigCommandTest method setAuthorizationPluginInfo.

private void setAuthorizationPluginInfo() {
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    PluginConfiguration k1 = new PluginConfiguration("k1", new Metadata(false, true));
    PluginConfiguration k2 = new PluginConfiguration("k2", new Metadata(false, false));
    PluginConfiguration k3 = new PluginConfiguration("k3", new Metadata(false, true));
    PluggableInstanceSettings authConfigSettins = new PluggableInstanceSettings(asList(k1, k2, k3));
    PluggableInstanceSettings roleConfigSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
    com.thoughtworks.go.plugin.domain.authorization.Capabilities capabilities = new com.thoughtworks.go.plugin.domain.authorization.Capabilities(SupportedAuthType.Web, true, true, true);
    AuthorizationPluginInfo artifactPluginInfo = new AuthorizationPluginInfo(pluginDescriptor, authConfigSettins, roleConfigSettings, null, capabilities);
    when(pluginDescriptor.id()).thenReturn("cd.go.github");
    AuthorizationMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
Also used : Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration)

Example 23 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class BasicCruiseConfigTest method setArtifactPluginInfo.

private void setArtifactPluginInfo() {
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    PluggableInstanceSettings storeConfigSettings = new PluggableInstanceSettings(asList());
    PluginConfiguration k1 = new PluginConfiguration("k1", new Metadata(false, true));
    PluginConfiguration k2 = new PluginConfiguration("k2", new Metadata(false, false));
    PluginConfiguration k3 = new PluginConfiguration("k3", new Metadata(false, true));
    PluggableInstanceSettings publishArtifactSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
    PluggableInstanceSettings fetchArtifactSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
    ArtifactPluginInfo artifactPluginInfo = new ArtifactPluginInfo(pluginDescriptor, storeConfigSettings, publishArtifactSettings, fetchArtifactSettings, null, new Capabilities());
    when(pluginDescriptor.id()).thenReturn("cd.go.s3");
    ArtifactMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.artifact.Capabilities) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo)

Example 24 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class AuthorizationMetadataStoreTest method pluginInfo.

private AuthorizationPluginInfo pluginInfo(String pluginId, SupportedAuthType supportedAuthType) {
    AuthorizationPluginInfo pluginInfo = mock(AuthorizationPluginInfo.class);
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    when(pluginDescriptor.id()).thenReturn(pluginId);
    when(pluginInfo.getDescriptor()).thenReturn(pluginDescriptor);
    Capabilities capabilities = mock(Capabilities.class);
    when(capabilities.getSupportedAuthType()).thenReturn(supportedAuthType);
    when(pluginInfo.getCapabilities()).thenReturn(capabilities);
    return pluginInfo;
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)

Example 25 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class AnalyticsMetadataStoreTest method shouldHandleUpdateAssetsPath.

@Test
public void shouldHandleUpdateAssetsPath() throws Exception {
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    AnalyticsPluginInfo pluginInfo = new AnalyticsPluginInfo(pluginDescriptor, null, null, null);
    when(pluginDescriptor.id()).thenReturn("plugin_id");
    store.setPluginInfo(pluginInfo);
    store.updateAssetsPath("plugin_id", "static_assets_path");
    assertThat(pluginInfo.getStaticAssetsPath(), is("static_assets_path"));
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) Test(org.junit.jupiter.api.Test)

Aggregations

PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)28 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)11 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)11 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)11 ArtifactPluginInfo (com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo)10 Capabilities (com.thoughtworks.go.plugin.domain.artifact.Capabilities)8 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)7 Image (com.thoughtworks.go.plugin.access.common.models.Image)6 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)5 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)4 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)4 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)4 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)4 ArrayList (java.util.ArrayList)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Test (org.junit.jupiter.api.Test)4 Capabilities (com.thoughtworks.go.plugin.domain.authorization.Capabilities)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1