Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

pluginv1 "github.com/Silo-Server/silo-plugin-sdk/pkg/pluginproto/silo/plugin/v1"
pluginmanifest "github.com/Silo-Server/silo-plugin-sdk/pkg/pluginsdk/manifest"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
Expand Down Expand Up @@ -59,6 +60,10 @@ func BuildPackageFromRelease(repo string, source *SourceManifest, release Releas
if len(source.GetCapabilities()) == 0 {
return CatalogPackage{}, fmt.Errorf("source manifest capabilities are required")
}
repositoryURL := "https://github.com/" + repo
if err := pluginmanifest.ValidateCatalogPresentation(source, repositoryURL); err != nil {
return CatalogPackage{}, fmt.Errorf("source manifest presentation: %w", err)
}

version := strings.TrimPrefix(strings.TrimSpace(release.TagName), "v")
if version == "" {
Expand Down Expand Up @@ -101,7 +106,7 @@ func BuildPackageFromRelease(repo string, source *SourceManifest, release Releas

return CatalogPackage{
Manifest: manifest,
RepoURL: "https://github.com/" + repo,
RepoURL: repositoryURL,
ChecksumsURL: checksumsURL,
Binaries: binaries,
}, nil
Expand Down
53 changes: 53 additions & 0 deletions catalog/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func TestBuildPackageFromRelease_MinimalManifestAndAssets(t *testing.T) {
PluginId: "silo.tmdb",
Version: "1.2.3",
SiloApiVersion: "v1",
Presentation: catalogTestPresentation("https://github.com/Silo-Server/silo-plugin-tmdb"),
Capabilities: []*pluginv1.CapabilityDescriptor{
{
Type: "metadata_provider.v1",
Expand Down Expand Up @@ -62,6 +63,7 @@ func TestBuildPackageFromRelease_TagWinsOverManifestVersion(t *testing.T) {
PluginId: "silo.tmdb",
Version: "1.2.2",
SiloApiVersion: "v1",
Presentation: catalogTestPresentation("https://github.com/Silo-Server/silo-plugin-tmdb"),
Capabilities: []*pluginv1.CapabilityDescriptor{
{Type: "metadata_provider.v1", Id: "tmdb"},
},
Expand All @@ -83,12 +85,47 @@ func TestBuildPackageFromRelease_TagWinsOverManifestVersion(t *testing.T) {
}
}

func TestBuildPackageFromRelease_RequiresCompletePresentation(t *testing.T) {
source := &SourceManifest{
PluginId: "silo.requests.arr",
Version: "0.1.1",
SiloApiVersion: "v1",
Capabilities: []*pluginv1.CapabilityDescriptor{
{Type: "request_router.v1", Id: "arr"},
},
}
release := Release{
TagName: "v0.1.1",
Assets: []Asset{
{Name: "plugin-linux-amd64", BrowserDownloadURL: "https://example.invalid/arr/plugin-linux-amd64"},
{Name: "checksums.txt", BrowserDownloadURL: "https://example.invalid/arr/checksums.txt"},
},
}

if _, err := BuildPackageFromRelease("Silo-Community/silo-plugins-requests-arr", source, release); err == nil {
t.Fatal("BuildPackageFromRelease() accepted a manifest without presentation metadata")
}
}

func TestBuildPackageFromRelease_PreservesManifestMetadataAndConfigSchema(t *testing.T) {
source, err := DecodeSourceManifest([]byte(`{
"plugin_id": "silo.requests.arr",
"version": "0.1.0",
"checksum": "__CHECKSUM__",
"silo_api_version": "v1",
"presentation": {
"display_name": "Sonarr & Radarr Requests",
"summary": "Routes requests to Sonarr and Radarr.",
"description_markdown": "Routes approved requests.",
"setup_markdown": "Add a connection.",
"homepage_url": "https://github.com/Silo-Server/silo-plugins-requests-arr",
"source_url": "https://github.com/Silo-Server/silo-plugins-requests-arr",
"support_url": "https://github.com/Silo-Server/silo-plugins-requests-arr/issues",
"changelog_url": "https://github.com/Silo-Server/silo-plugins-requests-arr/releases",
"publisher_name": "Silo",
"publisher_url": "https://github.com/Silo-Server",
"license_spdx": "AGPL-3.0-only"
},
"supported_platforms": [{"os": "linux", "arch": "amd64"}],
"capabilities": [{
"type": "request_router.v1",
Expand Down Expand Up @@ -177,6 +214,22 @@ func TestBuildPackageFromRelease_PreservesManifestMetadataAndConfigSchema(t *tes
}
}

func catalogTestPresentation(sourceURL string) *pluginv1.PluginPresentation {
return &pluginv1.PluginPresentation{
DisplayName: "Test Plugin",
Summary: "Test summary.",
DescriptionMarkdown: "Test description.",
SetupMarkdown: "Test setup.",
HomepageUrl: sourceURL,
SourceUrl: sourceURL,
SupportUrl: sourceURL + "/issues",
ChangelogUrl: sourceURL + "/releases",
PublisherName: "Silo",
PublisherUrl: "https://github.com/Silo-Server",
LicenseSpdx: "AGPL-3.0-only",
}
}

func TestUpsertPackage_ReplacesExistingPluginAndSorts(t *testing.T) {
index := RepositoryIndex{
Plugins: []CatalogPackage{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Silo-Community/silo-plugins
go 1.26.0

require (
github.com/Silo-Server/silo-plugin-sdk v0.6.0
github.com/Silo-Server/silo-plugin-sdk v0.10.0
google.golang.org/protobuf v1.36.11
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/Silo-Server/silo-plugin-sdk v0.6.0 h1:Gi9TdH9kt7b8X4xRXH493/nSYb9n0GO4VCWmlll0hKI=
github.com/Silo-Server/silo-plugin-sdk v0.6.0/go.mod h1:etqmxLTwjxpFH9goAjBDfNDoqHMv2/sqUXu8yx3hNfA=
github.com/Silo-Server/silo-plugin-sdk v0.10.0 h1:OU2PfQwnUQAnf8FEZSTfWI+3x0OBiVfjKHHaVWhD/E0=
github.com/Silo-Server/silo-plugin-sdk v0.10.0/go.mod h1:etqmxLTwjxpFH9goAjBDfNDoqHMv2/sqUXu8yx3hNfA=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
Expand Down