asset

package
v1.0.0-alpha.16 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Name        string
	DisplayName string
	Type        Type

	OS      string
	Arch    string
	Version string

	Extension    string
	DownloadPath string
	Hash         string
	TempDir      string
	Files        []*File
	// contains filtered or unexported fields
}

func New

func New(name, displayName, osName, osArch, version string) *Asset

New creates a new asset

func (*Asset) Classify

func (a *Asset) Classify()

Classify determines the type of asset based on the file extension

func (*Asset) Cleanup

func (a *Asset) Cleanup() error

func (*Asset) Download

func (a *Asset) Download(_ context.Context) error

func (*Asset) Extract

func (a *Asset) Extract() error

func (*Asset) GetAsset

func (a *Asset) GetAsset() *Asset

func (*Asset) GetDisplayName

func (a *Asset) GetDisplayName() string

func (*Asset) GetFilePath

func (a *Asset) GetFilePath() string

func (*Asset) GetFiles

func (a *Asset) GetFiles() []*File

func (*Asset) GetName

func (a *Asset) GetName() string

func (*Asset) GetScore

func (a *Asset) GetScore() int

func (*Asset) GetTempPath

func (a *Asset) GetTempPath() string

func (*Asset) GetType

func (a *Asset) GetType() Type

func (*Asset) ID

func (a *Asset) ID() string

func (*Asset) Install

func (a *Asset) Install(id, binDir string) error

func (*Asset) IsSupportedExtension

func (a *Asset) IsSupportedExtension() bool

func (*Asset) Score

func (a *Asset) Score(opts *ScoreOptions) int

Score returns the score of the asset based on the options provided

type File

type File struct {
	Name        string
	Alias       string
	Installable bool
}

type IAsset

type IAsset interface {
	GetName() string
	GetDisplayName() string
	GetScore() int
	GetType() Type
	GetAsset() *Asset
	GetFiles() []*File
	GetTempPath() string
	GetFilePath() string
	Score(options *ScoreOptions) int
	Download(context.Context) error
	Extract() error
	Install(string, string) error
	Cleanup() error
	ID() string
}

type ScoreOptions

type ScoreOptions struct {
	OS         []string
	Arch       []string
	Extensions []string
}

type Type

type Type int

Type is the type of asset

const (
	Unknown Type = iota
	Archive
	Binary
	Installer
	Checksum
	Signature
	Key
	SBOM
)

Jump to

Keyboard shortcuts

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