Search in sources :

Example 1 with PackageMaterialPluginInfo

use of com.thoughtworks.go.plugin.domain.packagematerial.PackageMaterialPluginInfo in project gocd by gocd.

the class PackageMaterialExtensionRepresenter method toJSON.

@Override
public void toJSON(OutputWriter extensionWriter, PluginInfo extension) {
    super.toJSON(extensionWriter, extension);
    PackageMaterialPluginInfo packageMaterialPluginInfo = (PackageMaterialPluginInfo) extension;
    extensionWriter.addChild("package_settings", taskSettingsWriter -> PluggableInstanceSettingsRepresenter.toJSON(taskSettingsWriter, packageMaterialPluginInfo.getPackageSettings())).addChild("repository_settings", taskSettingsWriter -> PluggableInstanceSettingsRepresenter.toJSON(taskSettingsWriter, packageMaterialPluginInfo.getRepositorySettings()));
}
Also used : PluginInfo(com.thoughtworks.go.plugin.domain.common.PluginInfo) OutputWriter(com.thoughtworks.go.api.base.OutputWriter) PackageMaterialPluginInfo(com.thoughtworks.go.plugin.domain.packagematerial.PackageMaterialPluginInfo) PluggableInstanceSettingsRepresenter(com.thoughtworks.go.apiv7.plugininfos.representers.PluggableInstanceSettingsRepresenter) PackageMaterialPluginInfo(com.thoughtworks.go.plugin.domain.packagematerial.PackageMaterialPluginInfo)

Example 2 with PackageMaterialPluginInfo

use of com.thoughtworks.go.plugin.domain.packagematerial.PackageMaterialPluginInfo in project gocd by gocd.

the class PackageMaterialPluginInfoBuilderTest method shouldBuildPluginInfo.

@Test
public void shouldBuildPluginInfo() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    PackageMaterialPluginInfo pluginInfo = new PackageMaterialPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    List<PluginConfiguration> packageSettings = Arrays.asList(new PluginConfiguration("username", new PackageMaterialMetadata(true, false, false, "foo", 1)), new PluginConfiguration("password", new PackageMaterialMetadata(true, true, true, "", 2)));
    List<PluginConfiguration> repoSettings = Arrays.asList(new PluginConfiguration("foo", new PackageMaterialMetadata(true, false, true, "", 1)), new PluginConfiguration("bar", new PackageMaterialMetadata(true, true, true, "", 2)));
    List<PluginConfiguration> pluginSettings = Arrays.asList(new PluginConfiguration("k1", new Metadata(true, false)));
    assertThat(pluginInfo.getDescriptor(), is(descriptor));
    assertThat(pluginInfo.getExtensionName(), is("package-repository"));
    assertThat(pluginInfo.getPackageSettings(), is(new PluggableInstanceSettings(packageSettings, null)));
    assertThat(pluginInfo.getRepositorySettings(), is(new PluggableInstanceSettings(repoSettings, null)));
    assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(pluginSettings, new PluginView("some-html"))));
}
Also used : PackageMaterialPluginInfo(com.thoughtworks.go.plugin.domain.packagematerial.PackageMaterialPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.jupiter.api.Test)

Example 3 with PackageMaterialPluginInfo

use of com.thoughtworks.go.plugin.domain.packagematerial.PackageMaterialPluginInfo in project gocd by gocd.

the class PackageMaterialPluginInfoBuilder method pluginInfoFor.

@Override
public PackageMaterialPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) {
    RepositoryConfiguration repositoryConfiguration = extension.getRepositoryConfiguration(descriptor.id());
    com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration packageConfiguration = extension.getPackageConfiguration(descriptor.id());
    if (repositoryConfiguration == null) {
        throw new RuntimeException(format("Plugin[%s] returned null repository configuration", descriptor.id()));
    }
    if (packageConfiguration == null) {
        throw new RuntimeException(format("Plugin[%s] returned null package configuration", descriptor.id()));
    }
    PluggableInstanceSettings pluginSettingsAndView = getPluginSettingsAndView(descriptor, extension);
    return new PackageMaterialPluginInfo(descriptor, new PluggableInstanceSettings(packageRepoConfigurations(repositoryConfiguration)), new PluggableInstanceSettings(packageRepoConfigurations(packageConfiguration)), pluginSettingsAndView);
}
Also used : PackageMaterialPluginInfo(com.thoughtworks.go.plugin.domain.packagematerial.PackageMaterialPluginInfo) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)

Aggregations

PackageMaterialPluginInfo (com.thoughtworks.go.plugin.domain.packagematerial.PackageMaterialPluginInfo)3 OutputWriter (com.thoughtworks.go.api.base.OutputWriter)1 PluggableInstanceSettingsRepresenter (com.thoughtworks.go.apiv7.plugininfos.representers.PluggableInstanceSettingsRepresenter)1 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)1 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)1 PluginInfo (com.thoughtworks.go.plugin.domain.common.PluginInfo)1 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)1 Test (org.junit.jupiter.api.Test)1