controller

package
v1.2.0-0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 38 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"`
	Registries Registries `validate:"dive"`
}

type ConfigFinder

type ConfigFinder interface {
	Find(wd string) string
	Finds(wd 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
	GlobalConfingDir        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, args ...string) error

Generate searches packages in registries and outputs the configuration to standard output. If no package is specified, the interactive fuzzy finder is launched. If the package supports, the latest version is gotten by GitHub API.

func (*Controller) Init added in v0.8.7

func (ctrl *Controller) Init(ctx context.Context, cfgFilePath string) 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 *PackageInfo) (string, error)

type FindingPackage

type FindingPackage struct {
	PackageInfo  *PackageInfo
	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 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)
	ListReleases(ctx context.Context, owner, repo string, opts *github.ListOptions) ([]*github.RepositoryRelease, *github.Response, 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 PackageCondition added in v0.8.1

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

func NewPackageCondition added in v0.8.1

func NewPackageCondition(s string) *PackageCondition

func (*PackageCondition) Check added in v0.8.1

func (pkgCondition *PackageCondition) Check() (bool, error)

func (*PackageCondition) Compile added in v0.8.1

func (pkgCondition *PackageCondition) Compile() error

func (*PackageCondition) Raw added in v0.8.1

func (pkgCondition *PackageCondition) Raw() string

func (*PackageCondition) UnmarshalYAML added in v0.8.1

func (pkgCondition *PackageCondition) UnmarshalYAML(unmarshal func(interface{}) error) error

type PackageDownloader

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

type PackageInfo added in v0.9.0

type PackageInfo 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   []*PackageInfo      `yaml:"version_overrides"`
	SupportedIf        *PackageCondition   `yaml:"supported_if"`
	VersionFilter      *VersionFilter      `yaml:"version_filter"`
	Rosetta2           *bool
}

func (*PackageInfo) GetDescription added in v0.9.0

func (pkgInfo *PackageInfo) GetDescription() string

func (*PackageInfo) GetFileSrc added in v0.9.0

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

func (*PackageInfo) GetFiles added in v0.9.0

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

func (*PackageInfo) GetFormat added in v0.9.0

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

func (*PackageInfo) GetName added in v0.9.0

func (pkgInfo *PackageInfo) GetName() string

func (*PackageInfo) GetPkgPath added in v0.9.0

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

func (*PackageInfo) GetReplacements added in v0.9.0

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

func (*PackageInfo) GetRosetta2 added in v0.9.0

func (pkgInfo *PackageInfo) GetRosetta2() bool

func (*PackageInfo) GetType added in v0.9.0

func (pkgInfo *PackageInfo) GetType() string

func (*PackageInfo) HasRepo added in v0.9.0

func (pkgInfo *PackageInfo) HasRepo() bool

func (*PackageInfo) RenderAsset added in v0.9.0

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

func (*PackageInfo) SetVersion added in v0.9.0

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

type PackageInfos

type PackageInfos []*PackageInfo

func (*PackageInfos) ToMap

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

type Param

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

type Registries

type Registries map[string]*Registry

func (*Registries) UnmarshalYAML

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

type Registry

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

func (*Registry) GetFilePath

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

func (*Registry) UnmarshalYAML added in v0.9.0

func (registry *Registry) UnmarshalYAML(unmarshal func(interface{}) error) error

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 VersionFilter added in v0.8.13

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

func NewVersionFilter added in v0.8.13

func NewVersionFilter(s string) *VersionFilter

func (*VersionFilter) Check added in v0.8.13

func (vf *VersionFilter) Check(v string) (bool, error)

func (*VersionFilter) Compile added in v0.8.13

func (vf *VersionFilter) Compile() error

func (*VersionFilter) Raw added in v0.8.13

func (vf *VersionFilter) Raw() string

func (*VersionFilter) UnmarshalYAML added in v0.8.13

func (vf *VersionFilter) UnmarshalYAML(unmarshal func(interface{}) error) error

type Which

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

Jump to

Keyboard shortcuts

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