mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
* support grafana wildcard version * undo go.mod changes * tidy * flesh out tests * refactor * add tests * tidy naming * undo some changes * split interfaces * separation * update new signature * simplify * update var namings * unexport types * introduce opts pattern * reorder test * fix compat checks * middle ground * unexport client * move back * fix tests * inline logger * make client usable * use fake logger * tidy errors * remove unused types * fix test * review fixes * rework compatibility * adjust installer * fix tests * opts => cfg * remove unused var * fix var name
82 lines
1.9 KiB
Go
82 lines
1.9 KiB
Go
package repo
|
|
|
|
import "fmt"
|
|
|
|
type ErrResponse4xx struct {
|
|
message string
|
|
statusCode int
|
|
compatibilityInfo CompatOpts
|
|
}
|
|
|
|
func newErrResponse4xx(statusCode int) ErrResponse4xx {
|
|
return ErrResponse4xx{
|
|
statusCode: statusCode,
|
|
}
|
|
}
|
|
|
|
func (e ErrResponse4xx) Message() string {
|
|
return e.message
|
|
}
|
|
|
|
func (e ErrResponse4xx) StatusCode() int {
|
|
return e.statusCode
|
|
}
|
|
|
|
func (e ErrResponse4xx) withMessage(message string) ErrResponse4xx {
|
|
e.message = message
|
|
return e
|
|
}
|
|
|
|
func (e ErrResponse4xx) withCompatibilityInfo(compatibilityInfo CompatOpts) ErrResponse4xx {
|
|
e.compatibilityInfo = compatibilityInfo
|
|
return e
|
|
}
|
|
|
|
func (e ErrResponse4xx) Error() string {
|
|
if len(e.message) > 0 {
|
|
compatInfo := e.compatibilityInfo.String()
|
|
if len(compatInfo) > 0 {
|
|
return fmt.Sprintf("%d: %s (%s)", e.statusCode, e.message, compatInfo)
|
|
}
|
|
return fmt.Sprintf("%d: %s", e.statusCode, e.message)
|
|
}
|
|
return fmt.Sprintf("%d", e.statusCode)
|
|
}
|
|
|
|
type ErrVersionUnsupported struct {
|
|
pluginID string
|
|
requestedVersion string
|
|
systemInfo string
|
|
}
|
|
|
|
func (e ErrVersionUnsupported) Error() string {
|
|
return fmt.Sprintf("%s v%s is not supported on your system (%s)", e.pluginID, e.requestedVersion, e.systemInfo)
|
|
}
|
|
|
|
type ErrVersionNotFound struct {
|
|
pluginID string
|
|
requestedVersion string
|
|
systemInfo string
|
|
}
|
|
|
|
func (e ErrVersionNotFound) Error() string {
|
|
return fmt.Sprintf("%s v%s either does not exist or is not supported on your system (%s)", e.pluginID, e.requestedVersion, e.systemInfo)
|
|
}
|
|
|
|
type ErrArcNotFound struct {
|
|
pluginID string
|
|
systemInfo string
|
|
}
|
|
|
|
func (e ErrArcNotFound) Error() string {
|
|
return fmt.Sprintf("%s is not compatible with your system architecture: %s", e.pluginID, e.systemInfo)
|
|
}
|
|
|
|
type ErrChecksumMismatch struct {
|
|
archiveURL string
|
|
}
|
|
|
|
func (e ErrChecksumMismatch) Error() string {
|
|
return fmt.Sprintf("expected SHA256 checksum does not match the downloaded archive (%s) - please contact security@grafana.com", e.archiveURL)
|
|
}
|