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()));
}
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"))));
}
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);
}
Aggregations