Search in sources :

Example 16 with PluginConfiguration

use of com.thoughtworks.go.server.ui.plugins.PluginConfiguration in project gocd by gocd.

the class SCMViewModelBuilder method pluginInfoFor.

public PluginInfo pluginInfoFor(String pluginId) {
    if (!SCMMetadataStore.getInstance().hasPreferenceFor(pluginId)) {
        return null;
    }
    GoPluginDescriptor descriptor = pluginManager.getPluginDescriptorFor(pluginId);
    SCMPreference scmPreference = SCMMetadataStore.getInstance().preferenceFor(pluginId);
    List<PluginConfiguration> pluginConfigurations = configurations(scmPreference.getScmConfigurations());
    PluginView pluginView = new PluginView(scmPreference.getScmView().template());
    return new PluginInfo(descriptor, SCMExtension.EXTENSION_NAME, scmPreference.getScmView().displayValue(), new PluggableInstanceSettings(pluginConfigurations, pluginView));
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo)

Example 17 with PluginConfiguration

use of com.thoughtworks.go.server.ui.plugins.PluginConfiguration in project gocd by gocd.

the class ElasticAgentViewViewModelBuilderTest method shouldBeAbleToFetchPluginInfoForSinglePlugin.

@Test
public void shouldBeAbleToFetchPluginInfoForSinglePlugin() throws Exception {
    when(elasticPluginConfigMetadataStore.find(dockerPlugin.id())).thenReturn(dockerPlugin);
    Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
    ;
    when(elasticPluginConfigMetadataStore.getIcon(dockerPlugin)).thenReturn(image);
    when(elasticPluginConfigMetadataStore.getProfileView(dockerPlugin)).thenReturn("html");
    PluginProfileMetadataKey pluginProfileMetadataKey = new PluginProfileMetadataKey("foo", new PluginProfileMetadata(true, true));
    PluginProfileMetadataKeys pluginProfileMetadataKeys = new PluginProfileMetadataKeys(Collections.singletonList(pluginProfileMetadataKey));
    when(elasticPluginConfigMetadataStore.getProfileMetadata(dockerPlugin)).thenReturn(pluginProfileMetadataKeys);
    PluginInfo pluginInfo = builder.pluginInfoFor(dockerPlugin.id());
    assertThat(pluginInfo.getImage(), is(image));
    assertThat(pluginInfo.getPluggableInstanceSettings().getView(), is(new PluginView("html")));
    Map<String, Object> metadata = new HashMap<>();
    metadata.put(REQUIRED_OPTION, true);
    metadata.put(SECURE_OPTION, true);
    assertEquals(pluginInfo.getPluggableInstanceSettings().getConfigurations(), Arrays.asList(new PluginConfiguration("foo", metadata, null)));
}
Also used : PluginProfileMetadataKeys(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) PluginProfileMetadataKey(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey) Image(com.thoughtworks.go.plugin.access.common.models.Image) PluginProfileMetadata(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata) Test(org.junit.Test)

Aggregations

PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)17 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)9 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)8 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)8 HashMap (java.util.HashMap)6 Image (com.thoughtworks.go.plugin.access.common.models.Image)5 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)2 Property (com.thoughtworks.go.plugin.api.config.Property)2 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)1 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)1 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)1 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)1 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)1 SCMPreference (com.thoughtworks.go.plugin.access.scm.SCMPreference)1 AuthorizationPluginInfo (com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo)1 ElasticPluginInfo (com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo)1