grafana/pkg/plugins/repo/ifaces.go
Will Browne 26dfdd5af3
Plugins: Refactor plugin download/installation (#43046)
* installer -> repo

* add semver format checking

* add plugin callbacks in test

* remove newline

* post install only scans new directories

* remove unused stuff

* everything in own package

* add missing cli params

* make grafana version part of the API

* resolve conflicts

* tidy up logger

* fix cli and tidy log statements

* rename log package

* update struct name

* fix linter issue

* fs -> filestore

* reorder imports

* alias import

* fix test

* fix test

* inline var

* revert jsonc file

* make repo dep of manager

* actually inject the thing

* accept all args for compatability checks

* accept compat from store

* pass os + arch vals

* don't inject fs

* tidy up

* tidy up

* merge with main and tidy fs storage

* fix test

* fix packages

* fix comment + field name

* update fs naming

* fixed wire

* remove unused func

* fix mocks

* fix storage test

* renaming

* fix log line

* fix test

* re-order field

* tidying

* add test for update with same version

* fix wire for CLI

* remove use of ioutil

* don't pass field

* small tidy

* ignore code scanning warn

* fix testdata link

* update lgtm code
2022-08-23 11:50:50 +02:00

40 lines
1.2 KiB
Go

package repo
import (
"context"
"fmt"
"strings"
)
// Service is responsible for retrieving plugin information from a repository.
type Service interface {
// GetPluginArchive fetches the requested plugin archive.
GetPluginArchive(ctx context.Context, pluginID, version string, opts CompatOpts) (*PluginArchive, error)
// GetPluginArchiveByURL fetches the requested plugin from the specified URL.
GetPluginArchiveByURL(ctx context.Context, archiveURL string, opts CompatOpts) (*PluginArchive, error)
// GetPluginDownloadOptions fetches information for downloading the requested plugin.
GetPluginDownloadOptions(ctx context.Context, pluginID, version string, opts CompatOpts) (*PluginDownloadOptions, error)
}
type CompatOpts struct {
GrafanaVersion string
OS string
Arch string
}
func NewCompatOpts(grafanaVersion, os, arch string) CompatOpts {
return CompatOpts{
GrafanaVersion: grafanaVersion,
OS: os,
Arch: arch,
}
}
func (co CompatOpts) OSAndArch() string {
return fmt.Sprintf("%s-%s", strings.ToLower(co.OS), co.Arch)
}
func (co CompatOpts) String() string {
return fmt.Sprintf("Grafana v%s %s", co.GrafanaVersion, co.OSAndArch())
}