controller

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const OwnerExecutable os.FileMode = 64

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Packages       []*Package       `validate:"dive"`
	InlineRegistry *RegistryContent `yaml:"inline_registry"`
	Registries     Registries       `validate:"dive"`
}

type ConfigFinder

type ConfigFinder interface {
	Find(wd string) string
	Finds(wd string) []string
	FindGlobal(rootDir string) string
}

type ConfigReader

type ConfigReader interface {
	Read(p string) (io.ReadCloser, error)
}

type Controller

type Controller struct {
	Stdin                   io.Reader
	Stdout                  io.Writer
	Stderr                  io.Writer
	ConfigFinder            ConfigFinder
	ConfigReader            ConfigReader
	GitHubRepositoryService GitHubRepositoryService
	PackageDownloader       PackageDownloader
	RootDir                 string
	Version                 string
}

func New

func New(ctx context.Context, param *Param) (*Controller, error)

func (*Controller) Exec

func (ctrl *Controller) Exec(ctx context.Context, param *Param, exeName string, args []string) error

func (*Controller) Generate

func (ctrl *Controller) Generate(ctx context.Context, param *Param) error

func (*Controller) Install

func (ctrl *Controller) Install(ctx context.Context, param *Param) error

func (*Controller) List

func (ctrl *Controller) List(ctx context.Context, param *Param, args []string) error

func (*Controller) Which

func (ctrl *Controller) Which(ctx context.Context, param *Param, exeName string) error

type Decompressor

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

func (*Decompressor) Unarchive

func (decomressor *Decompressor) Unarchive(body io.Reader) error

type File

type File struct {
	Name string `validate:"required"`
	Src  *Template
}

func (*File) RenderSrc

func (file *File) RenderSrc(pkg *Package, pkgInfo *MergedPackageInfo) (string, error)

type FindingPackage

type FindingPackage struct {
	PackageInfo  *MergedPackageInfo
	RegistryName string
}

type FormatOverride

type FormatOverride struct {
	GOOS   string
	Format string `yaml:"format"`
}

type Fsys

type Fsys interface {
	Stat(string) (os.FileInfo, error)
	Lstat(string) (os.FileInfo, error)
	Chmod(string, os.FileMode) error
	Symlink(string, string) error
	Readlink(string) (string, error)
	Remove(string) error
	Getwd(string) (string, error)
	Open(string) (io.ReadCloser, error)
	OpenFile(string, os.FileMode) (io.WriteCloser, error)
	WriteFile(string, []byte, os.FileMode) error
	CreateTemp(string, string) (io.WriteCloser, error)
}

type GitHubContentRegistry

type GitHubContentRegistry struct {
	Name      string `validate:"required"`
	RepoOwner string `yaml:"repo_owner"`
	RepoName  string `yaml:"repo_name"`
	Ref       string `validate:"required"`
	Path      string `validate:"required"`
}

func (*GitHubContentRegistry) GetFilePath

func (registry *GitHubContentRegistry) GetFilePath(rootDir, cfgFilePath string) string

func (*GitHubContentRegistry) GetName

func (registry *GitHubContentRegistry) GetName() string

func (*GitHubContentRegistry) GetType

func (registry *GitHubContentRegistry) GetType() string

type GitHubRepositoryService

type GitHubRepositoryService interface {
	GetLatestRelease(ctx context.Context, repoOwner, repoName string) (*github.RepositoryRelease, *github.Response, error)
	GetContents(ctx context.Context, repoOwner, repoName, path string, opt *github.RepositoryContentGetOptions) (*github.RepositoryContent, []*github.RepositoryContent, *github.Response, error)
	GetReleaseByTag(ctx context.Context, owner, repoName, version string) (*github.RepositoryRelease, *github.Response, error)
	DownloadReleaseAsset(ctx context.Context, owner, repoName string, assetID int64, httpClient *http.Client) (io.ReadCloser, string, error)
}

type LocalRegistry

type LocalRegistry struct {
	Name string `validate:"required"`
	Path string `validate:"required"`
}

func (*LocalRegistry) GetFilePath

func (registry *LocalRegistry) GetFilePath(rootDir, cfgFilePath string) string

func (*LocalRegistry) GetName

func (registry *LocalRegistry) GetName() string

func (*LocalRegistry) GetType

func (registry *LocalRegistry) GetType() string

type MergedPackageInfo

type MergedPackageInfo struct {
	Name               string
	Type               string `validate:"required"`
	RepoOwner          string `yaml:"repo_owner"`
	RepoName           string `yaml:"repo_name"`
	Asset              *Template
	Path               *Template
	Format             string
	Files              []*File
	URL                *Template
	Description        string
	Link               string
	Replacements       map[string]string
	FormatOverrides    []*FormatOverride    `yaml:"format_overrides"`
	VersionConstraints *VersionConstraints  `yaml:"version_constraint"`
	VersionOverrides   []*MergedPackageInfo `yaml:"version_overrides"`
}

func (*MergedPackageInfo) GetDescription

func (pkgInfo *MergedPackageInfo) GetDescription() string

func (*MergedPackageInfo) GetFileSrc

func (pkgInfo *MergedPackageInfo) GetFileSrc(pkg *Package, file *File) (string, error)

func (*MergedPackageInfo) GetFiles

func (pkgInfo *MergedPackageInfo) GetFiles() []*File

func (*MergedPackageInfo) GetFormat

func (pkgInfo *MergedPackageInfo) GetFormat() string
func (pkgInfo *MergedPackageInfo) GetLink() string

func (*MergedPackageInfo) GetName

func (pkgInfo *MergedPackageInfo) GetName() string

func (*MergedPackageInfo) GetPkgPath

func (pkgInfo *MergedPackageInfo) GetPkgPath(rootDir string, pkg *Package) (string, error)

func (*MergedPackageInfo) GetReplacements

func (pkgInfo *MergedPackageInfo) GetReplacements() map[string]string

func (*MergedPackageInfo) GetType

func (pkgInfo *MergedPackageInfo) GetType() string

func (*MergedPackageInfo) HasRepo

func (pkgInfo *MergedPackageInfo) HasRepo() bool

func (*MergedPackageInfo) RenderAsset

func (pkgInfo *MergedPackageInfo) RenderAsset(pkg *Package) (string, error)

func (*MergedPackageInfo) SetVersion

func (pkgInfo *MergedPackageInfo) SetVersion(v string) (*MergedPackageInfo, error)

type Package

type Package struct {
	Name     string `validate:"required"`
	Registry string `validate:"required" yaml:",omitempty"`
	Version  string `validate:"required" yaml:",omitempty"`
	Import   string `yaml:",omitempty"`
}

func (*Package) UnmarshalYAML

func (pkg *Package) UnmarshalYAML(unmarshal func(interface{}) error) error

type PackageDownloader

type PackageDownloader interface {
	GetReadCloser(ctx context.Context, pkg *Package, pkgInfo *MergedPackageInfo, assetName string) (io.ReadCloser, error)
}

type PackageInfos

type PackageInfos []*MergedPackageInfo

func (*PackageInfos) ToMap

func (pkgInfos *PackageInfos) ToMap() (map[string]*MergedPackageInfo, error)

type Param

type Param struct {
	ConfigFilePath string
	LogLevel       string
	OnlyLink       bool
	IsTest         bool
	All            bool
	File           string
	GlobalConfigs  []string
	AQUAVersion    string
}

type Registries

type Registries []Registry

func (*Registries) UnmarshalYAML

func (registries *Registries) UnmarshalYAML(unmarshal func(interface{}) error) error

type Registry

type Registry interface {
	GetName() string
	GetType() string
	GetFilePath(rootDir, cfgFilePath string) string
}

type RegistryContent

type RegistryContent struct {
	PackageInfos PackageInfos `yaml:"packages" validate:"dive"`
}

type Template

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

func NewTemplate

func NewTemplate(raw string) *Template

func (*Template) Execute

func (tpl *Template) Execute(param interface{}) (string, error)

func (*Template) Parse

func (tpl *Template) Parse() error

func (*Template) UnmarshalYAML

func (tpl *Template) UnmarshalYAML(unmarshal func(interface{}) error) error

type Unarchiver

type Unarchiver interface {
	Unarchive(body io.Reader) error
}

type VersionConstraints

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

func NewVersionConstraints

func NewVersionConstraints(s string) *VersionConstraints

func (*VersionConstraints) Check

func (constraints *VersionConstraints) Check(v string) (bool, error)

func (*VersionConstraints) Compile

func (constraints *VersionConstraints) Compile() error

func (*VersionConstraints) UnmarshalYAML

func (constraints *VersionConstraints) UnmarshalYAML(unmarshal func(interface{}) error) error

type Which

type Which struct {
	Package *Package
	PkgInfo *MergedPackageInfo
	File    *File
	ExePath string
}

Jump to

Keyboard shortcuts

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