utils

package
v3.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: EPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ChePluginType = "che plugin"
View Source
const EditorPluginType = "che editor"
View Source
const RegistryURLFormat = "%s/%s/meta.yaml"

RegistryURLFormat specifies the format string for registry urls when downloading metas

View Source
const TheiaPluginType = "theia plugin"
View Source
const VscodePluginType = "vs code extension"

Variables

This section is empty.

Functions

func Close

func Close(c io.Closer)

func ConvertCollisionsToLog

func ConvertCollisionsToLog(collisions map[string][]string) []string

ConvertCollisionsToLog converts the output of GetExtensionCollisions to a human-readable string. Output is a slice of strings, to be joined by newlines

func ConvertIDToUniqueName

func ConvertIDToUniqueName(id string) string

ConvertIDToUniqueName converts a plugin ID to a unique plugin name

func GetExtensionCollisions

func GetExtensionCollisions(metas []model.PluginMeta) map[string][]string

GetExtensionCollisions checks a list of plugin metas for extensions shared by more than one plugin. Return value is a list of

func GetPluginMeta

func GetPluginMeta(plugin model.PluginFQN, defaultRegistry string, ioUtil IoUtil) (*model.PluginMeta, error)

GetPluginMeta downloads the metadata for a plugin. If specified, defaultRegistry is used as the registry when plugin does not specify its registry. If defaultRegistry is empty, and plugin does not specify a registry, an error is returned.

func GetPluginMetas

func GetPluginMetas(plugins []model.PluginFQN, defaultRegistry string, ioUtil IoUtil) ([]model.PluginMeta, error)

GetPluginMetas retrieves plugin metas for a list of plugin FQNs. This method is a thin wrapper over GetPluginMeta.

func GetPluginUniqueName

func GetPluginUniqueName(meta model.PluginMeta) string

GetPluginUniqueName generates a unique plugin name from plugin publisher, version, and name

func IsTheiaOrVscodePlugin

func IsTheiaOrVscodePlugin(meta model.PluginMeta) bool

func ResolveRelativeExtensionPaths

func ResolveRelativeExtensionPaths(metas []model.PluginMeta, defaultRegistry string) error

ResolveRelativeExtensionPaths takes a slice of plugin metas and updates relative extension references (e.g. relative:extension/[...]) to point to relative paths in the default registry.

func SanitizeImage

func SanitizeImage(image string) string

func ValidateMetas

func ValidateMetas(metas ...model.PluginMeta) error

ValidateMetas ensures that a plugin meta conforms to expectations at a basic level, e.g. that required fields are present.

Types

type HTTPError

type HTTPError struct {
	StatusCode int
	Body       string
	// contains filtered or unexported fields
}

func NewHTTPError

func NewHTTPError(resp *http.Response, errMsg string) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

type IoUtil

type IoUtil interface {
	Download(URL string, destPath string, useContentDisposition bool) (string, error)
	CopyResource(src string, dest string) error
	CopyFile(src string, dest string) error
	ResolveDestPath(filePath string, destDir string) string
	ResolveDestPathFromURL(url string, destDir string) string
	TempDir(string, string) (string, error)
	MkDir(string) error
	Unzip(arch string, dest string) error
	Untar(tarPath string, dest string) error
	CreateFile(file string, tr io.Reader) error
	Fetch(url string) ([]byte, error)
	GetFilesByGlob(glob string) ([]string, error)
	RemoveAll(path string) error
	ReadFile(path string) ([]byte, error)
	WriteFile(path string, data []byte) error
	RemoveFile(path string) error
	FileExists(path string) bool
}

func New

func New() IoUtil

New creates an instance of IoUtil using the default http client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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