Search in sources :

Example 1 with PluginView

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

the class ElasticAgentViewViewModelBuilder method pluginInfoFor.

@Override
public PluginInfo pluginInfoFor(String pluginId) {
    PluginDescriptor descriptor = metadataStore.find(pluginId);
    if (descriptor == null) {
        return null;
    }
    Image icon = metadataStore.getIcon(descriptor);
    ArrayList<PluginConfiguration> pluginConfigurations = PluginConfiguration.getPluginConfigurations(metadataStore.getProfileMetadata(descriptor));
    PluginView pluginView = new PluginView(metadataStore.getProfileView(descriptor));
    PluggableInstanceSettings settings = new PluggableInstanceSettings(pluginConfigurations, pluginView);
    return new PluginInfo(descriptor, ElasticAgentPluginConstants.EXTENSION_NAME, null, settings, icon);
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) Image(com.thoughtworks.go.plugin.access.common.models.Image)

Example 2 with PluginView

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

the class PluggableTaskPluginInfoBuilder method pluginInfoFor.

@Override
public PluggableTaskPluginInfo pluginInfoFor(String pluginId) {
    if (!store.pluginIds().contains(pluginId)) {
        return null;
    }
    GoPluginDescriptor plugin = pluginManager.getPluginDescriptorFor(pluginId);
    TaskPreference taskPreference = store.preferenceFor(pluginId);
    List<PluginConfiguration> pluginConfigurations = configurations(taskPreference.getConfig());
    PluginView pluginView = new PluginView(taskPreference.getView().template());
    return new PluggableTaskPluginInfo(plugin, taskPreference.getView().displayValue(), new PluggableInstanceSettings(pluginConfigurations, pluginView));
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) PluggableTaskPluginInfo(com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)

Example 3 with PluginView

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

the class PluggableTaskPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() throws Exception {
    GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
    GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
    PluginManager pluginManager = mock(PluginManager.class);
    PluggableTaskConfigStore packageMetadataStore = mock(PluggableTaskConfigStore.class);
    when(packageMetadataStore.pluginIds()).thenReturn(Collections.singleton(plugin.id()));
    when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
    JsonBasedPluggableTask jsonBasedPluggableTask = mock(JsonBasedPluggableTask.class);
    TaskView taskView = new TaskView() {

        @Override
        public String displayValue() {
            return "task display value";
        }

        @Override
        public String template() {
            return "pluggable task view template";
        }
    };
    TaskConfig taskConfig = new TaskConfig();
    taskConfig.add(new TaskConfigProperty("key1", null));
    taskConfig.add(new TaskConfigProperty("key2", null));
    when(jsonBasedPluggableTask.config()).thenReturn(taskConfig);
    when(jsonBasedPluggableTask.view()).thenReturn(taskView);
    TaskPreference taskPreference = new TaskPreference(jsonBasedPluggableTask);
    when(packageMetadataStore.preferenceFor(plugin.id())).thenReturn(taskPreference);
    PluggableTaskPluginInfoBuilder builder = new PluggableTaskPluginInfoBuilder(pluginManager, packageMetadataStore);
    Collection<PluggableTaskPluginInfo> pluginInfos = builder.allPluginInfos();
    PluggableTaskPluginInfo expectedPluginInfo = new PluggableTaskPluginInfo(plugin, taskView.displayValue(), new PluggableInstanceSettings(configurations(taskConfig), new PluginView(taskView.template())));
    assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
}
Also used : TaskView(com.thoughtworks.go.plugin.api.task.TaskView) JsonBasedPluggableTask(com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask) PluggableTaskPluginInfo(com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluggableTaskConfigStore(com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskConfigStore) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 4 with PluginView

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

the class SCMPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() throws Exception {
    GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
    GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
    PluginManager pluginManager = mock(PluginManager.class);
    SCMMetadataStore scmMetadataStore = mock(SCMMetadataStore.class);
    when(scmMetadataStore.getPlugins()).thenReturn(Collections.singletonList(plugin.id()));
    when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
    SCMConfigurations configurations = new SCMConfigurations();
    configurations.add(new SCMConfiguration("key1"));
    configurations.add(new SCMConfiguration("key2"));
    SCMView view = new SCMView() {

        @Override
        public String displayValue() {
            return "SCM Display Value";
        }

        @Override
        public String template() {
            return "scm view template";
        }
    };
    SCMPreference scmPreference = new SCMPreference(configurations, view);
    when(scmMetadataStore.preferenceFor(plugin.id())).thenReturn(scmPreference);
    SCMPluginInfoBuilder builder = new SCMPluginInfoBuilder(pluginManager, scmMetadataStore);
    Collection<SCMPluginInfo> pluginInfos = builder.allPluginInfos();
    SCMPluginInfo expectedPluginInfo = new SCMPluginInfo(plugin, view.displayValue(), new PluggableInstanceSettings(configurations(configurations), new PluginView(view.template())));
    assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
    assertEquals(Arrays.asList(expectedPluginInfo), pluginInfos);
}
Also used : SCMPluginInfo(com.thoughtworks.go.server.ui.plugins.SCMPluginInfo) PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 5 with PluginView

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

the class AuthorizationPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() throws Exception {
    GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
    GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
    PluginProfileMetadataKeys securityAuthConfigMetadata = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("password", new PluginProfileMetadata(true, true))));
    PluginProfileMetadataKeys roleConfigMetadata = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("memberOf", new PluginProfileMetadata(true, false))));
    Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
    String securityAuthConfigView = "some html view";
    String roleConfigView = "another html view";
    AuthorizationPluginConfigMetadataStore store = mock(AuthorizationPluginConfigMetadataStore.class);
    when(store.getPlugins()).thenReturn(Arrays.asList(plugin));
    when(store.find("docker-plugin")).thenReturn(plugin);
    when(store.getProfileMetadata(plugin)).thenReturn(securityAuthConfigMetadata);
    when(store.getRoleMetadata(plugin)).thenReturn(roleConfigMetadata);
    when(store.getIcon(plugin)).thenReturn(image);
    when(store.getProfileView(plugin)).thenReturn(securityAuthConfigView);
    when(store.getRoleView(plugin)).thenReturn(roleConfigView);
    AuthorizationPluginInfoBuilder builder = new AuthorizationPluginInfoBuilder(store);
    Collection<AuthorizationPluginInfo> pluginInfos = builder.allPluginInfos();
    PluggableInstanceSettings authConfigSettings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(securityAuthConfigMetadata), new PluginView(securityAuthConfigView));
    PluggableInstanceSettings roleConfigSettings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(roleConfigMetadata), new PluginView(roleConfigView));
    assertEquals(Arrays.asList(new AuthorizationPluginInfo(plugin, authConfigSettings, roleConfigSettings, image)), pluginInfos);
}
Also used : PluginProfileMetadataKeys(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys) AuthorizationPluginInfo(com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo) Image(com.thoughtworks.go.plugin.access.common.models.Image) AuthorizationPluginConfigMetadataStore(com.thoughtworks.go.plugin.access.authorization.AuthorizationPluginConfigMetadataStore) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginProfileMetadataKey(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey) PluginProfileMetadata(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata) Test(org.junit.Test)

Aggregations

PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)18 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)15 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)11 Test (org.junit.Test)11 Image (com.thoughtworks.go.plugin.access.common.models.Image)9 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)8 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)7 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)5 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)5 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)5 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)4 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)4 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)4 AuthorizationPluginInfo (com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo)3 ElasticPluginInfo (com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo)3 PluggableTaskPluginInfo (com.thoughtworks.go.server.ui.plugins.PluggableTaskPluginInfo)3 AuthorizationPluginConfigMetadataStore (com.thoughtworks.go.plugin.access.authorization.AuthorizationPluginConfigMetadataStore)2 ElasticPluginConfigMetadataStore (com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore)2 JsonBasedPluggableTask (com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask)2 PluggableTaskConfigStore (com.thoughtworks.go.plugin.access.pluggabletask.PluggableTaskConfigStore)2