Search in sources :

Example 11 with PluggableInstanceSettings

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

the class ElasticAgentPluginInfoBuilder method pluginInfoFor.

@Override
public ElasticPluginInfo pluginInfoFor(String pluginId) {
    PluginDescriptor descriptor = store.find(pluginId);
    if (descriptor == null) {
        return null;
    }
    Image icon = store.getIcon(descriptor);
    ArrayList<PluginConfiguration> pluginConfigurations = PluginConfiguration.getPluginConfigurations(store.getProfileMetadata(descriptor));
    PluginView pluginView = new PluginView(store.getProfileView(descriptor));
    PluggableInstanceSettings settings = new PluggableInstanceSettings(pluginConfigurations, pluginView);
    return new ElasticPluginInfo(descriptor, 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) ElasticPluginInfo(com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo) Image(com.thoughtworks.go.plugin.access.common.models.Image)

Example 12 with PluggableInstanceSettings

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

the class PluggableTaskViewModelBuilder method pluginInfoFor.

public PluginInfo pluginInfoFor(String pluginId) {
    if (!PluggableTaskConfigStore.store().hasPreferenceFor(pluginId)) {
        return null;
    }
    GoPluginDescriptor descriptor = pluginManager.getPluginDescriptorFor(pluginId);
    TaskPreference taskPreference = PluggableTaskConfigStore.store().preferenceFor(pluginId);
    List<PluginConfiguration> pluginConfigurations = configurations(taskPreference.getConfig());
    PluginView pluginView = new PluginView(taskPreference.getView().template());
    return new PluginInfo(descriptor, TaskExtension.TASK_EXTENSION, 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) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginInfo(com.thoughtworks.go.server.ui.plugins.PluginInfo) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)

Example 13 with PluggableInstanceSettings

use of com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings 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 14 with PluggableInstanceSettings

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

the class PluggableTaskPluginInfoBuilderTest method pluginInfoFor_ShouldProvidePluginInfoForAPlugin.

@Test
public void pluginInfoFor_ShouldProvidePluginInfoForAPlugin() 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);
    PluggableTaskPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
    PluggableTaskPluginInfo expectedPluginInfo = new PluggableTaskPluginInfo(plugin, taskView.displayValue(), new PluggableInstanceSettings(configurations(taskConfig), new PluginView(taskView.template())));
    assertEquals(expectedPluginInfo, pluginInfo);
}
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 15 with PluggableInstanceSettings

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

the class SCMPluginInfoBuilderTest method pluginInfoFor_ShouldProvidePluginInfoForAPlugin.

@Test
public void pluginInfoFor_ShouldProvidePluginInfoForAPlugin() 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);
    SCMPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
    SCMPluginInfo expectedPluginInfo = new SCMPluginInfo(plugin, view.displayValue(), new PluggableInstanceSettings(configurations(configurations), new PluginView(view.template())));
    assertEquals(expectedPluginInfo, pluginInfo);
}
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)

Aggregations

PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)18 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)15 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)14 Test (org.junit.Test)10 Image (com.thoughtworks.go.plugin.access.common.models.Image)8 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)8 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)6 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)5 PluginProfileMetadata (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata)4 PluginProfileMetadataKey (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey)4 PluginProfileMetadataKeys (com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys)4 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)4 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)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 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)2 PackageMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore)2