repo

package
v0.0.0-testrgm3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchMeta

type ArchMeta struct {
	SHA256 string `json:"sha256"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(skipTLSVerify bool, logger log.PrettyLogger) *Client

func (*Client) Download

func (c *Client) Download(_ context.Context, pluginZipURL, checksum string, compatOpts CompatOpts) (*PluginArchive, error)

func (*Client) SendReq

func (c *Client) SendReq(url *url.URL, compatOpts CompatOpts) ([]byte, error)

type CompatOpts

type CompatOpts struct {
	// contains filtered or unexported fields
}

func NewCompatOpts

func NewCompatOpts(grafanaVersion, os, arch string) CompatOpts

func NewSystemCompatOpts

func NewSystemCompatOpts(os, arch string) CompatOpts

func (CompatOpts) GrafanaVersion

func (co CompatOpts) GrafanaVersion() (string, bool)

func (CompatOpts) String

func (co CompatOpts) String() string

func (CompatOpts) System

func (co CompatOpts) System() (SystemCompatOpts, bool)

type ErrArcNotFound

type ErrArcNotFound struct {
	// contains filtered or unexported fields
}

func (ErrArcNotFound) Error

func (e ErrArcNotFound) Error() string

type ErrChecksumMismatch

type ErrChecksumMismatch struct {
	// contains filtered or unexported fields
}

func (ErrChecksumMismatch) Error

func (e ErrChecksumMismatch) Error() string

type ErrResponse4xx

type ErrResponse4xx struct {
	// contains filtered or unexported fields
}

func (ErrResponse4xx) Error

func (e ErrResponse4xx) Error() string

func (ErrResponse4xx) Message

func (e ErrResponse4xx) Message() string

func (ErrResponse4xx) StatusCode

func (e ErrResponse4xx) StatusCode() int

type ErrVersionNotFound

type ErrVersionNotFound struct {
	// contains filtered or unexported fields
}

func (ErrVersionNotFound) Error

func (e ErrVersionNotFound) Error() string

type ErrVersionUnsupported

type ErrVersionUnsupported struct {
	// contains filtered or unexported fields
}

func (ErrVersionUnsupported) Error

func (e ErrVersionUnsupported) Error() string

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(cfg ManagerCfg) *Manager

func ProvideService

func ProvideService(cfg *config.Cfg) (*Manager, error)

func (*Manager) GetPluginArchive

func (m *Manager) GetPluginArchive(ctx context.Context, pluginID, version string, compatOpts CompatOpts) (*PluginArchive, error)

GetPluginArchive fetches the requested plugin archive

func (*Manager) GetPluginArchiveByURL

func (m *Manager) GetPluginArchiveByURL(ctx context.Context, pluginZipURL string, compatOpts CompatOpts) (*PluginArchive, error)

GetPluginArchiveByURL fetches the requested plugin archive from the provided `pluginZipURL`

func (*Manager) GetPluginArchiveInfo

func (m *Manager) GetPluginArchiveInfo(_ context.Context, pluginID, version string, compatOpts CompatOpts) (*PluginArchiveInfo, error)

GetPluginArchiveInfo returns the options for downloading the requested plugin (with optional `version`)

type ManagerCfg

type ManagerCfg struct {
	SkipTLSVerify bool
	BaseURL       string
	Logger        log.PrettyLogger
}

type PluginArchive

type PluginArchive struct {
	File *zip.ReadCloser
}

type PluginArchiveInfo

type PluginArchiveInfo struct {
	URL      string
	Version  string
	Checksum string
}

type PluginRepo

type PluginRepo struct {
	Versions []Version `json:"versions"`
}

PluginRepo is (a subset of) the JSON response from /api/plugins/repo/$pluginID

type Service

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)
	// GetPluginArchiveInfo fetches information needed for downloading the requested plugin.
	GetPluginArchiveInfo(ctx context.Context, pluginID, version string, opts CompatOpts) (*PluginArchiveInfo, error)
}

Service is responsible for retrieving plugin archive information from a repository.

type SystemCompatOpts

type SystemCompatOpts struct {
	// contains filtered or unexported fields
}

func (SystemCompatOpts) Arch

func (co SystemCompatOpts) Arch() (string, bool)

func (SystemCompatOpts) OS

func (co SystemCompatOpts) OS() (string, bool)

func (SystemCompatOpts) OSAndArch

func (co SystemCompatOpts) OSAndArch() string

type Version

type Version struct {
	Version string              `json:"version"`
	Arch    map[string]ArchMeta `json:"arch"`
}

type VersionData

type VersionData struct {
	Version  string
	Checksum string
}

func SelectSystemCompatibleVersion

func SelectSystemCompatibleVersion(log log.PrettyLogger, versions []Version, pluginID, version string, compatOpts SystemCompatOpts) (VersionData, error)

SelectSystemCompatibleVersion selects the most appropriate plugin version based on os + architecture returns the specified version if supported. returns the latest version if no specific version is specified. returns error if the supplied version does not exist. returns error if supplied version exists but is not supported. NOTE: It expects plugin.Versions to be sorted so the newest version is first.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL