artifact

package
v0.0.0-...-302dbc3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package artifact provides the core artifact storage for goreleaser.

Index

Constants

View Source
const (
	ExtraID        = "ID"
	ExtraBinary    = "Binary"
	ExtraExt       = "Ext"
	ExtraBuilds    = "Builds"
	ExtraFormat    = "Format"
	ExtraWrappedIn = "WrappedIn"
	ExtraBinaries  = "Binaries"
	ExtraRefresh   = "Refresh"
	ExtraReplaces  = "Replaces"
)

Variables

This section is empty.

Functions

func Extra

func Extra[T any](a Artifact, key string) (T, error)

Extra tries to get the extra field with the given name, returning either its value, the default value for its type, or an error.

If the extra value cannot be cast into the given type, it'll try to convert it to JSON and unmarshal it into the correct type after.

If that fails as well, it'll error.

func ExtraOr

func ExtraOr[T any](a Artifact, key string, or T) T

ExtraOr returns the Extra field with the given key or the or value specified if it is nil.

func OnlyReplacingUnibins

func OnlyReplacingUnibins(a *Artifact) bool

OnlyReplacingUnibins removes universal binaries that did not replace the single-arch ones.

This is useful specially on homebrew et al, where you'll want to use only either the single-arch or the universal binaries.

Types

type Artifact

type Artifact struct {
	Name    string `json:"name,omitempty"`
	Path    string `json:"path,omitempty"`
	Goos    string `json:"goos,omitempty"`
	Goarch  string `json:"goarch,omitempty"`
	Goarm   string `json:"goarm,omitempty"`
	Gomips  string `json:"gomips,omitempty"`
	Goamd64 string `json:"goamd64,omitempty"`
	Type    Type   `json:"internal_type,omitempty"`
	TypeS   string `json:"type,omitempty"`
	Extra   Extras `json:"extra,omitempty"`
}

Artifact represents an artifact and its relevant info.

func (Artifact) Checksum

func (a Artifact) Checksum(algorithm string) (string, error)

Checksum calculates the checksum of the artifact. nolint: gosec

func (Artifact) Format

func (a Artifact) Format() string

Format returns the artifact Format if it exists, empty otherwise.

func (Artifact) ID

func (a Artifact) ID() string

ID returns the artifact ID if it exists, empty otherwise.

func (Artifact) Refresh

func (a Artifact) Refresh() error

Refresh executes a Refresh extra function on artifacts, if it exists.

func (Artifact) String

func (a Artifact) String() string

type Artifacts

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

Artifacts is a list of artifacts.

func New

func New() Artifacts

New return a new list of artifacts.

func (*Artifacts) Add

func (artifacts *Artifacts) Add(a *Artifact)

Add safely adds a new artifact to an artifact list.

func (*Artifacts) Filter

func (artifacts *Artifacts) Filter(filter Filter) Artifacts

Filter filters the artifact list, returning a new instance. There are some pre-defined filters but anything of the Type Filter is accepted. You can compose filters by using the And and Or filters.

func (Artifacts) GroupByID

func (artifacts Artifacts) GroupByID() map[string][]*Artifact

GroupByID groups the artifacts by their ID.

func (Artifacts) GroupByPlatform

func (artifacts Artifacts) GroupByPlatform() map[string][]*Artifact

GroupByPlatform groups the artifacts by their platform.

func (Artifacts) List

func (artifacts Artifacts) List() []*Artifact

List return the actual list of artifacts.

func (Artifacts) Paths

func (artifacts Artifacts) Paths() []string

Paths returns the artifact.Path of the current artifact list.

func (*Artifacts) Remove

func (artifacts *Artifacts) Remove(filter Filter) error

Remove removes artifacts that match the given filter from the original artifact list.

func (Artifacts) Visit

func (artifacts Artifacts) Visit(fn VisitFn) error

Visit executes the given function for each artifact in the list.

type Extras

type Extras map[string]any

Extras represents the extra fields in an artifact.

func (Extras) MarshalJSON

func (e Extras) MarshalJSON() ([]byte, error)

type Filter

type Filter func(a *Artifact) bool

Filter defines an artifact filter which can be used within the Filter function.

func And

func And(filters ...Filter) Filter

And performs an AND between all given filters.

func ByBinaryLikeArtifacts

func ByBinaryLikeArtifacts(arts Artifacts) Filter

ByBinaryLikeArtifacts filter artifacts down to artifacts that are Binary, UploadableBinary, or UniversalBinary, deduplicating artifacts by path (preferring UploadableBinary over all others). Note: this filter is unique in the sense that it cannot act in isolation of the state of other artifacts; the filter requires the whole list of artifacts in advance to perform deduplication.

func ByExt

func ByExt(exts ...string) Filter

ByExt filter artifact by their 'Ext' extra field.

func ByFormats

func ByFormats(formats ...string) Filter

ByFormats filters artifacts by a `Format` extra field.

func ByGoamd64

func ByGoamd64(s string) Filter

ByGoamd64 is a predefined filter that filters by the given goamd64.

func ByGoarch

func ByGoarch(s string) Filter

ByGoarch is a predefined filter that filters by the given goarch.

func ByGoarm

func ByGoarm(s string) Filter

ByGoarm is a predefined filter that filters by the given goarm.

func ByGoos

func ByGoos(s string) Filter

ByGoos is a predefined filter that filters by the given goos.

func ByIDs

func ByIDs(ids ...string) Filter

ByIDs filter artifacts by an `ID` extra field.

func ByType

func ByType(t Type) Filter

ByType is a predefined filter that filters by the given type.

func Or

func Or(filters ...Filter) Filter

Or performs an OR between all given filters.

type Type

type Type int

Type defines the type of an artifact.

const (
	// UploadableArchive a tar.gz/zip archive to be uploaded.
	UploadableArchive Type = iota + 1
	// UploadableBinary is a binary file to be uploaded.
	UploadableBinary
	// UploadableFile is any file that can be uploaded.
	UploadableFile
	// Binary is a binary (output of a gobuild).
	Binary
	// UniversalBinary is a binary that contains multiple binaries within.
	UniversalBinary
	// LinuxPackage is a linux package generated by nfpm.
	LinuxPackage
	// PublishableSnapcraft is a snap package yet to be published.
	PublishableSnapcraft
	// Snapcraft is a published snap package.
	Snapcraft
	// PublishableDockerImage is a Docker image yet to be published.
	PublishableDockerImage
	// DockerImage is a published Docker image.
	DockerImage
	// DockerManifest is a published Docker manifest.
	DockerManifest
	// Checksum is a checksums file.
	Checksum
	// Signature is a signature file.
	Signature
	// Certificate is a signing certificate file
	Certificate
	// UploadableSourceArchive is the archive with the current commit source code.
	UploadableSourceArchive
	// BrewTap is an uploadable homebrew tap recipe file.
	BrewTap
	// PkgBuild is an Arch Linux AUR PKGBUILD file.
	PkgBuild
	// SrcInfo is an Arch Linux AUR .SRCINFO file.
	SrcInfo
	// KrewPluginManifest is a krew plugin manifest file.
	KrewPluginManifest
	// ScoopManifest is an uploadable scoop manifest file.
	ScoopManifest
	// SBOM is a Software Bill of Materials file.
	SBOM
)

func (Type) String

func (t Type) String() string

type VisitFn

type VisitFn func(a *Artifact) error

VisitFn is a function that can be executed against each artifact in a list.

Jump to

Keyboard shortcuts

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