internal

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const GRABIT_ARTIFACTORY_TOKEN_ENV_VAR = "GRABIT_ARTIFACTORY_TOKEN"
View Source
const NoFileMode = os.FileMode(0)

Variables

View Source
var (
	Version = "dev"
	Commit  = "none"
	Date    = "unknown"
)
View Source
var COMMENT_PREFIX = "//"
View Source
var RecommendedAlgo = "sha256"

Functions

func GetUrlToDir added in v0.1.2

func GetUrlToDir(u string, targetDir string, bearer string, ctx context.Context) (string, error)

GetUrlToDir downloads the given resource to the given directory and returns the path to it.

func GetUrltoTempFile added in v0.1.2

func GetUrltoTempFile(u string, bearer string, ctx context.Context) (string, error)

GetUrlWithDir downloads the given resource to a temporary file and returns the path to it.

Types

type Hash

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

func NewHash

func NewHash(algo string) (*Hash, error)

type Hasher

type Hasher func() hash.Hash

type Lock

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

Lock represents a grabit lockfile.

func NewLock

func NewLock(path string, newOk bool) (*Lock, error)

func (*Lock) AddResource

func (l *Lock) AddResource(paths []string, algo string, tags []string, filename string, cacheURL string) error

func (*Lock) Contains

func (l *Lock) Contains(url string) bool

Contains returns true if this lock file contains the given resource url.

func (*Lock) DeleteResource

func (l *Lock) DeleteResource(path string) error

func (*Lock) Download

func (l *Lock) Download(dir string, tags []string, notags []string, perm string, status bool) error

Download gets all the resources in this lock file and moves them to the destination directory.

func (*Lock) Save

func (l *Lock) Save() error

Save this lock file to disk.

type Resource

type Resource struct {
	Urls                []string
	Integrity           string
	Tags                []string `toml:",omitempty"`
	Filename            string   `toml:",omitempty"`
	ArtifactoryCacheURL string   `toml:",omitempty"`
}

Resource represents an external resource to be downloaded.

func NewResourceFromUrl

func NewResourceFromUrl(urls []string, algo string, tags []string, filename string, ArtifactoryCacheURL string) (*Resource, error)

func (*Resource) AddToCache added in v1.1.0

func (l *Resource) AddToCache(filePath string) error

func (*Resource) Contains

func (l *Resource) Contains(url string) bool

func (*Resource) Delete added in v1.1.0

func (l *Resource) Delete() error

func (*Resource) Download

func (l *Resource) Download(dir string, mode os.FileMode, ctx context.Context) error

type StatusLine added in v1.1.0

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

func NewStatusLine added in v1.1.0

func NewStatusLine(ctx context.Context, resources *[]Resource) *StatusLine

NewStatusLine creates and initializes a new StatusLine.

func (*StatusLine) GetStatusString added in v1.1.0

func (st *StatusLine) GetStatusString() string

GetStatusString composes and returns the status line string for printing.

func (*StatusLine) Increment added in v1.1.0

func (st *StatusLine) Increment(i int)

Increment informs the StatusLine that a resource (at index i in resource list) has finished downloading. The SL is printed and Stopped if all resources are downloaded.

func (*StatusLine) InitResourcesSizes added in v1.1.0

func (st *StatusLine) InitResourcesSizes() error

initResourceSizes fetches the size, in bytes, of each resource.

func (*StatusLine) Start added in v1.1.0

func (st *StatusLine) Start(doTick bool)

Start begins the goroutine and loop that will update/print the status line. Pass true to force SL to update (spinner and second counter) every 50ms.

func (*StatusLine) Stop added in v1.1.0

func (st *StatusLine) Stop()

Jump to

Keyboard shortcuts

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