pluginmanager

package
v0.0.0-...-4a61b4d Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGitLatestCommitId

func GetGitLatestCommitId(ctx context.Context, log logger.Logger, repo string) (string, error)

GetGitLatestCommitId is used to get the latest commit id

func GetGoPkgExecName

func GetGoPkgExecName(pkgPath string) string

GetGoPkgExecName is used to parse binary name from pkg uri `src\cmd\go\internal\load\pkg.go:1595`

func GetPluginPath

func GetPluginPath(path string, version string) (string, error)

GetPluginPath is used to get the plugin path

func InstallPluginUsingGo

func InstallPluginUsingGo(ctx context.Context,
	log logger.Logger,
	storageDir string,
	path string, version string) (string, error)

InstallPluginUsingGo is used to install plugin using golang

func IsPluginInstalled

func IsPluginInstalled(ctx context.Context,
	storageDir string,
	path string, version string) (bool, string, error)

IsPluginInstalled is used to check whether a plugin is installed

func IsProtocInstalled

func IsProtocInstalled(ctx context.Context, storageDir string, version string) (bool, string, error)

IsProtocInstalled is used to check whether the protoc version is installed

func ListGitTags

func ListGitTags(ctx context.Context, log logger.Logger, repo string) ([]string, error)

ListGitTags is used to list the git tags of specified repository

func ListGoPackageVersions

func ListGoPackageVersions(ctx context.Context, log logger.Logger, path string) ([]string, error)

ListGoPackageVersions is list go package versions

func ListsGoPackageVersionsAmbiguously

func ListsGoPackageVersionsAmbiguously(ctx context.Context, log logger.Logger, pkg string) ([]string, error)

ListsGoPackageVersionsAmbiguously is used to list go package versions ambiguously

func PathForGitRepos

func PathForGitRepos(storageDir string, commitId string) string

PathForGitRepos is used to get the git repo local path

func PathForGitReposCode

func PathForGitReposCode(storageDir string, uri string, commitId string) (string, error)

PathForGitReposCode returns the code path for git repos

func PathForInclude

func PathForInclude(storageDir string) string

PathForInclude is used to get the local directory of include files

func PathForPlugin

func PathForPlugin(storageDir string, path string, version string) (string, error)

PathForPlugin is used to get the binary path of plugin Path: e.g "google.golang.org/protobuf/cmd/protoc-gen-go"

func PathForPluginDir

func PathForPluginDir(storageDir string, path string, version string) (string, error)

PathForPluginDir is used to get the local directory where the specified version plug-in should be stored

func PathForProtoc

func PathForProtoc(storageDir string, version string) string

PathForProtoc is used to get the local binary location where the specified version protoc should be stored

Types

type BasicPluginManager

type BasicPluginManager struct {
	logger.Logger
	// contains filtered or unexported fields
}

BasicPluginManager is the basic implement of PluginManager

func NewBasicPluginManager

func NewBasicPluginManager(storageDir string, log logger.Logger) (*BasicPluginManager, error)

NewBasicPluginManager is used to create basic PluginManager

func (*BasicPluginManager) GetGitRepoLatestVersion

func (b *BasicPluginManager) GetGitRepoLatestVersion(ctx context.Context, url string) (string, error)

GetGitRepoLatestVersion is used to get the latest version of google apis

func (*BasicPluginManager) GetPathForPlugin

func (b *BasicPluginManager) GetPathForPlugin(ctx context.Context, path string, version string) (local string, err error)

GetPathForPlugin is used to get path for plugin executable file

func (*BasicPluginManager) GetPathForProtoc

func (b *BasicPluginManager) GetPathForProtoc(ctx context.Context, version string) (string, error)

GetPathForProtoc is used to get the path for protoc

func (*BasicPluginManager) GetPluginLatestVersion

func (b *BasicPluginManager) GetPluginLatestVersion(ctx context.Context, path string) (string, error)

GetPluginLatestVersion is used to get the latest version of plugin

func (*BasicPluginManager) GetProtocLatestVersion

func (b *BasicPluginManager) GetProtocLatestVersion(ctx context.Context) (string, error)

GetProtocLatestVersion is used to get the latest version of protoc

func (*BasicPluginManager) GitRepoPath

func (b *BasicPluginManager) GitRepoPath(ctx context.Context, commitId string) (string, error)

GitRepoPath returns the googleapis path

func (*BasicPluginManager) IncludePath

func (b *BasicPluginManager) IncludePath(ctx context.Context) (string, error)

IncludePath returns the default include path

func (*BasicPluginManager) InstallGitRepo

func (b *BasicPluginManager) InstallGitRepo(ctx context.Context, uri string, commitId string) (string, error)

InstallGitRepo is used to install google apis

func (*BasicPluginManager) InstallPlugin

func (b *BasicPluginManager) InstallPlugin(ctx context.Context, path string, version string) (local string, err error)

InstallPlugin is used to install plugin

func (*BasicPluginManager) InstallProtoc

func (b *BasicPluginManager) InstallProtoc(ctx context.Context, version string) (string, error)

InstallProtoc is used to install protoc of specified version

func (*BasicPluginManager) IsGitRepoInstalled

func (b *BasicPluginManager) IsGitRepoInstalled(ctx context.Context, uri string, commitId string) (bool, string, error)

IsGitRepoInstalled is used to check whether the protoc is installed

func (*BasicPluginManager) IsPluginInstalled

func (b *BasicPluginManager) IsPluginInstalled(ctx context.Context, path string, version string) (bool, string, error)

IsPluginInstalled is used to check whether the plugin is installed

func (*BasicPluginManager) IsProtocInstalled

func (b *BasicPluginManager) IsProtocInstalled(ctx context.Context, version string) (bool, string, error)

IsProtocInstalled is used to check whether the protoc is installed

func (*BasicPluginManager) ListPluginVersions

func (b *BasicPluginManager) ListPluginVersions(ctx context.Context, path string) ([]string, error)

ListPluginVersions is used to list the versions of plugin

func (*BasicPluginManager) ListProtocVersions

func (b *BasicPluginManager) ListProtocVersions(ctx context.Context) ([]string, error)

ListProtocVersions is used to list protoc version

type Config

type Config struct {
	StorageDir string `json:"storage"`
}

Config defines the config of PluginManager

func NewConfig

func NewConfig() *Config

NewConfig is used to create config

type ErrGitList

type ErrGitList struct {
	*command.ErrCommandExec
}

ErrGitList defines the git list error

type ErrGoInstall

type ErrGoInstall struct {
	*command.ErrCommandExec
}

ErrGoInstall defines the go install error

type ErrGoList

type ErrGoList struct {
	*command.ErrCommandExec
}

ErrGoList defines the go list error

type ErrHTTPDownload

type ErrHTTPDownload struct {
	Url  string
	Err  error
	Code int
}

ErrHTTPDownload defines the download error

func (*ErrHTTPDownload) Error

func (err *ErrHTTPDownload) Error() string

Error implements the error interface

type GitRepository

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

GitRepository describes a local git repository

func GetGitRepository

func GetGitRepository(ctx context.Context, uri string, commitId string, log logger.Logger) (*GitRepository, error)

func (*GitRepository) Clear

func (r *GitRepository) Clear() error

Clear is used to clear the workspace

func (*GitRepository) GetLocalDir

func (r *GitRepository) GetLocalDir() string

GetLocalDir is used to get local dir of repo

type Module

type Module struct {
	Path      string       // module path
	Version   string       // module version
	Versions  []string     // available module versions (with -versions)
	Replace   *Module      // replaced by this module
	Time      *time.Time   // time version was created
	Update    *Module      // available update, if any (with -u)
	Main      bool         // is this the main module?
	Indirect  bool         // is this module only an indirect dependency of main module?
	Dir       string       // directory holding files for this module, if any
	GoMod     string       // path to go.mod file used when loading this module, if any
	GoVersion string       // go version used in module
	Retracted string       // retraction information, if any (with -retracted or -u)
	Error     *ModuleError // error loading module
}

Module defines the model of go list data

type ModuleError

type ModuleError struct {
	Err string // the error itself
}

ModuleError defines the module error

type PluginManager

type PluginManager interface {
	// GetPluginLatestVersion is used to get the latest version of plugin
	GetPluginLatestVersion(ctx context.Context, path string) (string, error)
	// ListPluginVersions is used to list the versions of plugin
	ListPluginVersions(ctx context.Context, path string) ([]string, error)
	// IsPluginInstalled is used to check whether the plugin is installed
	IsPluginInstalled(ctx context.Context, path string, version string) (bool, string, error)
	// InstallPlugin is used to install plugin
	InstallPlugin(ctx context.Context, path string, version string) (local string, err error)
	// GetPathForPlugin is used to get path for plugin executable file
	GetPathForPlugin(ctx context.Context, path string, version string) (local string, err error)

	// GetGitRepoLatestVersion is used to get the latest version of google apis
	GetGitRepoLatestVersion(ctx context.Context, uri string) (string, error)
	// InstallGitRepo is used to install google apis
	InstallGitRepo(ctx context.Context, uri string, commitId string) (local string, err error)
	// IsGitRepoInstalled is used to check whether the protoc is installed
	IsGitRepoInstalled(ctx context.Context, uri string, commitId string) (bool, string, error)
	// GitRepoPath returns the git repo path
	GitRepoPath(ctx context.Context, commitId string) (string, error)

	// GetProtocLatestVersion is used to get the latest version of protoc
	GetProtocLatestVersion(ctx context.Context) (string, error)
	// ListProtocVersions is used to list protoc version
	ListProtocVersions(ctx context.Context) ([]string, error)
	// IsProtocInstalled is used to check whether the protoc is installed
	IsProtocInstalled(ctx context.Context, version string) (bool, string, error)
	// InstallProtoc is used to install protoc of specified version
	InstallProtoc(ctx context.Context, version string) (local string, err error)
	// IncludePath returns the default include path
	IncludePath(ctx context.Context) (string, error)
	// GetPathForProtoc is used to get the path of protoc
	GetPathForProtoc(ctx context.Context, version string) (string, error)
}

PluginManager is used to manage plugins

func NewPluginManager

func NewPluginManager(cfg *Config, log logger.Logger) (PluginManager, error)

NewPluginManager is used to create PluginManager

type ProtocRelease

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

ProtocRelease defines the release of protoc

func GetProtocRelease

func GetProtocRelease(ctx context.Context, version string) (*ProtocRelease, error)

GetProtocRelease is used to download protoc release

func (*ProtocRelease) Clear

func (p *ProtocRelease) Clear() error

Clear is used to clear the workspace

func (*ProtocRelease) GetIncludePath

func (p *ProtocRelease) GetIncludePath() string

GetIncludePath is used to get the include path

func (*ProtocRelease) GetProtocPath

func (p *ProtocRelease) GetProtocPath() string

GetProtocPath is used to get the protoc path

Jump to

Keyboard shortcuts

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