Search in sources :

Example 11 with PluginDescriptor

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

the class ConfigInfoProviderTest method pluginInfo.

private AuthorizationPluginInfo pluginInfo(String pluginId, String pluginName) {
    final AuthorizationPluginInfo pluginInfo = mock(AuthorizationPluginInfo.class);
    final PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    final PluginDescriptor.About about = mock(PluginDescriptor.About.class);
    when(pluginDescriptor.id()).thenReturn(pluginId);
    when(pluginDescriptor.about()).thenReturn(about);
    when(about.name()).thenReturn(pluginName);
    when(pluginInfo.getDescriptor()).thenReturn(pluginDescriptor);
    Capabilities capabilities = mock(Capabilities.class);
    when(capabilities.getSupportedAuthType()).thenReturn(SupportedAuthType.Password);
    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 12 with PluginDescriptor

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

the class MagicalGoConfigXmlLoaderTest method shouldEncryptPluggablePublishArtifactProperties.

@Test
void shouldEncryptPluggablePublishArtifactProperties() throws Exception {
    PluginDescriptor pluginDescriptor = GoPluginDescriptor.builder().id("cd.go.artifact.docker.registry").version("1.0").build();
    PluginConfiguration buildFile = new PluginConfiguration("BuildFile", new Metadata(false, false));
    PluginConfiguration image = new PluginConfiguration("Image", new Metadata(false, true));
    PluginConfiguration tag = new PluginConfiguration("Tag", new Metadata(false, false));
    PluginConfiguration fetchProperty = new PluginConfiguration("FetchProperty", new Metadata(false, true));
    PluginConfiguration fetchTag = new PluginConfiguration("Tag", new Metadata(false, false));
    PluginConfiguration registryUrl = new PluginConfiguration("RegistryURL", new Metadata(true, false));
    PluginConfiguration username = new PluginConfiguration("Username", new Metadata(false, false));
    PluginConfiguration password = new PluginConfiguration("Password", new Metadata(false, true));
    PluggableInstanceSettings storeConfigSettings = new PluggableInstanceSettings(asList(registryUrl, username, password));
    PluggableInstanceSettings publishArtifactSettings = new PluggableInstanceSettings(asList(buildFile, image, tag));
    PluggableInstanceSettings fetchArtifactSettings = new PluggableInstanceSettings(asList(fetchProperty, fetchTag));
    ArtifactPluginInfo artifactPluginInfo = new ArtifactPluginInfo(pluginDescriptor, storeConfigSettings, publishArtifactSettings, fetchArtifactSettings, null, new Capabilities());
    ArtifactMetadataStore.instance().setPluginInfo(artifactPluginInfo);
    String content = goConfigMigration.upgradeIfNecessary(IOUtils.toString(getClass().getResource("/data/pluggable_artifacts_with_params.xml"), UTF_8));
    CruiseConfig config = xmlLoader.loadConfigHolder(content).configForEdit;
    PipelineConfig ancestor = config.pipelineConfigByName(new CaseInsensitiveString("ancestor"));
    PipelineConfig parent = config.pipelineConfigByName(new CaseInsensitiveString("parent"));
    PipelineConfig child = config.pipelineConfigByName(new CaseInsensitiveString("child"));
    Configuration ancestorPublishArtifactConfig = ancestor.get(0).getJobs().first().artifactTypeConfigs().getPluggableArtifactConfigs().get(0).getConfiguration();
    Configuration parentPublishArtifactConfig = parent.get(0).getJobs().first().artifactTypeConfigs().getPluggableArtifactConfigs().get(0).getConfiguration();
    Configuration childFetchArtifactFromAncestorConfig = ((FetchPluggableArtifactTask) child.get(0).getJobs().first().tasks().get(0)).getConfiguration();
    Configuration childFetchArtifactFromParentConfig = ((FetchPluggableArtifactTask) child.get(0).getJobs().first().tasks().get(1)).getConfiguration();
    ArtifactStore dockerhubStore = config.getArtifactStores().first();
    assertConfigProperty(ancestorPublishArtifactConfig, "Image", "IMAGE_SECRET", true);
    assertConfigProperty(ancestorPublishArtifactConfig, "Tag", "ancestor_tag_${GO_PIPELINE_COUNTER}", false);
    assertConfigProperty(parentPublishArtifactConfig, "Image", "IMAGE_SECRET", true);
    assertConfigProperty(parentPublishArtifactConfig, "Tag", "parent_tag_${GO_PIPELINE_COUNTER}", false);
    assertConfigProperty(childFetchArtifactFromAncestorConfig, "FetchProperty", "SECRET", true);
    assertConfigProperty(childFetchArtifactFromAncestorConfig, "Tag", "ancestor_tag", false);
    assertConfigProperty(childFetchArtifactFromParentConfig, "FetchProperty", "SECRET", true);
    assertConfigProperty(childFetchArtifactFromParentConfig, "Tag", "parent_tag", false);
    assertConfigProperty(dockerhubStore, "RegistryURL", "https://index.docker.io/v1/", false);
    assertConfigProperty(dockerhubStore, "Username", "docker-user", false);
    assertConfigProperty(dockerhubStore, "Password", "SECRET", true);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.artifact.Capabilities) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 13 with PluginDescriptor

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

the class CachedGoConfigIntegrationTest method setupMetadataForPlugin.

private void setupMetadataForPlugin() {
    PluginDescriptor pluginDescriptor = GoPluginDescriptor.builder().id("cd.go.artifact.docker.registry").build();
    PluginConfiguration buildFile = new PluginConfiguration("BuildFile", new Metadata(false, false));
    PluginConfiguration image = new PluginConfiguration("Image", new Metadata(false, true));
    PluginConfiguration tag = new PluginConfiguration("Tag", new Metadata(false, false));
    PluginConfiguration fetchProperty = new PluginConfiguration("FetchProperty", new Metadata(false, true));
    PluginConfiguration fetchTag = new PluginConfiguration("Tag", new Metadata(false, false));
    PluginConfiguration registryUrl = new PluginConfiguration("RegistryURL", new Metadata(true, false));
    PluginConfiguration username = new PluginConfiguration("Username", new Metadata(false, false));
    PluginConfiguration password = new PluginConfiguration("Password", new Metadata(false, true));
    PluggableInstanceSettings storeConfigSettings = new PluggableInstanceSettings(asList(registryUrl, username, password));
    PluggableInstanceSettings publishArtifactSettings = new PluggableInstanceSettings(asList(buildFile, image, tag));
    PluggableInstanceSettings fetchArtifactSettings = new PluggableInstanceSettings(asList(fetchProperty, fetchTag));
    ArtifactPluginInfo artifactPluginInfo = new ArtifactPluginInfo(pluginDescriptor, storeConfigSettings, publishArtifactSettings, fetchArtifactSettings, null, new Capabilities());
    ArtifactMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) 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 14 with PluginDescriptor

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

the class PipelineConfigsServiceIntegrationTest method setupMetadataForPlugin.

private void setupMetadataForPlugin() {
    PluginDescriptor pluginDescriptor = GoPluginDescriptor.builder().id("cd.go.artifact.docker.registry").build();
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration buildFile = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("BuildFile", new Metadata(false, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration image = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("Image", new Metadata(false, true));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration tag = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("Tag", new Metadata(false, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration fetchProperty = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("FetchProperty", new Metadata(false, true));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration fetchTag = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("Tag", new Metadata(false, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration registryUrl = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("RegistryURL", new Metadata(true, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration username = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("Username", new Metadata(false, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration password = new PluginConfiguration("Password", new Metadata(false, true));
    PluggableInstanceSettings storeConfigSettings = new PluggableInstanceSettings(asList(registryUrl, username, password));
    PluggableInstanceSettings publishArtifactSettings = new PluggableInstanceSettings(asList(buildFile, image, tag));
    PluggableInstanceSettings fetchArtifactSettings = new PluggableInstanceSettings(asList(fetchProperty, fetchTag));
    ArtifactPluginInfo artifactPluginInfo = new ArtifactPluginInfo(pluginDescriptor, storeConfigSettings, publishArtifactSettings, fetchArtifactSettings, null, new Capabilities());
    ArtifactMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
Also used : PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.artifact.Capabilities) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration)

Example 15 with PluginDescriptor

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

the class ElasticAgentPluginRegistry method createAgent.

public void createAgent(final String pluginId, String autoRegisterKey, String environment, Map<String, String> configuration) {
    PluginDescriptor plugin = findPlugin(pluginId);
    if (plugin != null) {
        LOGGER.debug("Processing create agent for plugin: {} with environment: {} with configuration: {}", pluginId, environment, configuration);
        extension.createAgent(pluginId, autoRegisterKey, environment, configuration);
        LOGGER.debug("Done processing create agent for plugin: {} with environment: {} with configuration: {}", pluginId, environment, configuration);
    } else {
        LOGGER.warn("Could not find plugin with id: {}", pluginId);
    }
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor)

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