@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);
    }
@Test
    public void shouldBuildPluginInfo() {
        GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();

        PackageMaterialPluginInfo pluginInfo = new PackageMaterialPluginInfoBuilder(extension).pluginInfoFor(descriptor);

        List<PluginConfiguration> packageSettings = List.of(
                new PluginConfiguration("username", new PackageMaterialMetadata(true, false, false, "foo", 1)),
                new PluginConfiguration("password", new PackageMaterialMetadata(true, true, true, "", 2))
        );

        List<PluginConfiguration> repoSettings = List.of(
                new PluginConfiguration("foo", new PackageMaterialMetadata(true, false, true, "", 1)),
                new PluginConfiguration("bar", new PackageMaterialMetadata(true, true, true, "", 2))
        );

        List<PluginConfiguration> pluginSettings = List.of(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"))));
    }