artifact

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 3 Imported by: 0

README

artifact

This package provides a simple way to manage downloadable artifacts in a project. It supports downloading and extracting artifacts of different types.

Supported types:

  • http(s) archive file (zip, tar, tar.gz)
  • git repository
  • Github release
  • helm chart
  • json-bundler

First create an Artifact instance describing the artifact to download.

Then use the puller.New() function to create a new puller instance.

Example:

a := &artifact.Artifact{
	Name:       "my-artifact",
	Repository: "https://my-repos.com/my-repo",
	Branch:     "main",
	Tag:        "v1.0.0",
	CommitHash: "e7d1f4c...",
	Version:    "1.0.0",
	URL:        "https://my-repos.com/my-repo/archive/v1.0.0.zip",
	AssetName:  "my-artifact-1.0.0.zip",
	SubDir:     "my-subdir",
}


p := puller.NewPuller(puller.WithLogger(logger))
res, err := p.Pull(ctx, puller.MethodHelmChart, a, puller.WithHelmOptions(...))

The concrete puller method determines the options.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstVersionOrLatest

func FirstVersionOrLatest(versions ...string) string

FirstVersionOrLatest returns the first non-empty version from the list or "latest" if none are found

Types

type Artifact

type Artifact struct {
	// Name is the name of the artifact
	Name string

	// Repository is the repository of the source
	// e.g. the helm repository or the github repository
	Repository string

	// Branch is the branch of the source
	Branch string

	// Tag is the tag of the source
	Tag string

	// CommitHash is the commit hash of the source
	CommitHash string

	// Version is the version of the source
	// e.g. the version of the helm chart or github release
	Version string

	// URL is the URL of the source
	URL string

	// AssetName is the file name of the asset to be downloaded
	// typically used for archives
	AssetName string

	// RelativePath is a subdirectory relative to the souce root directory that is
	// used for the basis in the component. Leading slashes are removed.
	// e.g. 'my/path' in the checkout of git URL
	// 'https://github.com/my/repo.git' would use 'my/path' as the directory
	// where the source is found
	RelativePath string

	// BaseDir is the directory where the artifact is stored
	// It does not include the directory for the artifact itself
	BaseDir string
}

Artifact is a source artifact that can be pulled or pushed

func (*Artifact) DestDir

func (a *Artifact) DestDir() string

DestDir returns the destination directory of the artifact

func (*Artifact) DestDirExists

func (a *Artifact) DestDirExists() error

DestDirExists checks if the destination directory exists

type Downloader

type Downloader interface {
	// Download downloads a file from the given URL to the given destination
	Download(url, dest string) (int64, error)
}

Downloader is an interface for downloading files

type PullResult

type PullResult struct {
	// Dir is the directory where the artifact was pulled to
	Dir string

	// If the puller discovers a version, it will be stored here
	Version string
}

PullResult is a struct that represents the result of a pull operation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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