asset

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadHTTP added in v1.10.0

func DownloadHTTP(ctx context.Context, a *Asset, url, downloadsDir, filename string,
	logger *zerolog.Logger, beforeRequest func(*http.Request)) error

DownloadHTTP downloads a file from a URL, caching by sha256 hash file. It sets DownloadPath, Extension, and Hash on the provided Asset. beforeRequest allows callers to add custom headers (auth tokens, etc).

Types

type Asset

type Asset struct {
	Name         string
	DisplayName  string
	Type         Type
	ParentType   Type
	ChecksumType string
	MatchedAsset IAsset

	OS      string
	Arch    string
	Version string

	Extension    string
	DownloadPath string
	Hash         string
	TempDir      string
	Files        []*File
}

func New

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

New creates a new asset

func (*Asset) Classify

func (a *Asset) Classify(name string) Type

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) GetBaseName added in v1.3.0

func (a *Asset) GetBaseName() string

func (*Asset) GetChecksumType

func (a *Asset) GetChecksumType() string

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) GetGPGKeyID

func (a *Asset) GetGPGKeyID() (uint64, error)

func (*Asset) GetMatchedAsset

func (a *Asset) GetMatchedAsset() IAsset

func (*Asset) GetName

func (a *Asset) GetName() string

func (*Asset) GetParentType

func (a *Asset) GetParentType() Type

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, optDir string) error

Install installs the asset

func (*Asset) Path

func (a *Asset) Path() string

func (*Asset) SetMatchedAsset

func (a *Asset) SetMatchedAsset(asset IAsset)

type File

type File struct {
	Name        string
	Alias       string
	Installable bool
}

type IAsset

type IAsset interface {
	GetName() string
	GetDisplayName() string
	GetType() Type
	GetParentType() Type
	GetAsset() *Asset
	GetFiles() []*File
	GetTempPath() string
	GetFilePath() string
	Download(context.Context) error
	Extract() error
	Install(string, string, string) error
	Cleanup() error
	ID() string
	Path() string
	GetChecksumType() string
	GetMatchedAsset() IAsset
	SetMatchedAsset(IAsset)
	GetGPGKeyID() (uint64, error)
	GetBaseName() string
}

type Type

type Type int

Type is the type of asset

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

	ChecksumTypeNone  = "none"
	ChecksumTypeFile  = "single"
	ChecksumTypeMulti = "multi"
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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