artifact

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const ArtifactFallbackMimeType = "binary/octet-stream"

Variables

This section is empty.

Functions

func DefaultUploadConcurrency

func DefaultUploadConcurrency() int

func IsAzureBlobPath

func IsAzureBlobPath(loc string) bool

IsAzureBlobPath reports if the location is an Azure Blob Storage path.

func NewAzureBlobClient

func NewAzureBlobClient(l logger.Logger, storageAccountName string) (*service.Client, error)

NewAzureBlobClient creates a new Azure Blob Storage client.

func NewS3Client

func NewS3Client(ctx context.Context, l logger.Logger, bucket string) (*s3.Client, error)

func ParseArtifactoryDestination

func ParseArtifactoryDestination(destination string) (repo, path string)

func ParseGSDestination

func ParseGSDestination(destination string) (name, path string)

func ParseS3Destination

func ParseS3Destination(destination string) (string, string)

Types

type APIClient

type APIClient interface {
	CreateArtifacts(context.Context, string, *api.ArtifactBatch) (*api.ArtifactBatchCreateResponse, *api.Response, error)
	SearchArtifacts(context.Context, string, *api.ArtifactSearchOptions) ([]*api.Artifact, *api.Response, error)
	UpdateArtifacts(context.Context, string, []api.ArtifactState) (*api.Response, error)
}

APIClient describes the Agent REST API methods used by the artifact package.

type ArtifactoryDownloader

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

func (ArtifactoryDownloader) RepositoryFileLocation

func (d ArtifactoryDownloader) RepositoryFileLocation() string

func (ArtifactoryDownloader) RepositoryName

func (d ArtifactoryDownloader) RepositoryName() string

func (ArtifactoryDownloader) RepositoryPath

func (d ArtifactoryDownloader) RepositoryPath() string

func (ArtifactoryDownloader) Start

type ArtifactoryDownloaderConfig

type ArtifactoryDownloaderConfig struct {
	// The Artifactory repository name and the path, for example, rt://my-repo-name/foo/bar
	Repository string

	// The root directory of the download
	Destination string

	// The relative path that should be preserved in the download folder,
	// also its location in the repo
	Path string

	// How many times should it retry the download before giving up
	Retries int

	// If failed responses should be dumped to the log
	DebugHTTP    bool
	TraceHTTP    bool
	DisableHTTP2 bool
}

type ArtifactoryUploader

type ArtifactoryUploader struct {
	// The artifactory bucket path set from the destination
	Path string

	// The artifactory bucket name set from the destination
	Repository string
	// contains filtered or unexported fields
}

func (*ArtifactoryUploader) CreateWork

func (u *ArtifactoryUploader) CreateWork(artifact *api.Artifact) ([]workUnit, error)

func (*ArtifactoryUploader) URL

func (u *ArtifactoryUploader) URL(artifact *api.Artifact) string

type ArtifactoryUploaderConfig

type ArtifactoryUploaderConfig struct {
	// The destination which includes the Artifactory bucket name and the path.
	// e.g artifactory://my-repo-name/foo/bar
	Destination string

	// Standard HTTP options
	DebugHTTP    bool
	TraceHTTP    bool
	DisableHTTP2 bool
}

type AzureBlobDownloader

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

AzureBlobDownloader downloads files from Azure Blob storage.

func NewAzureBlobDownloader

func NewAzureBlobDownloader(l logger.Logger, c AzureBlobDownloaderConfig) *AzureBlobDownloader

NewAzureBlobDownloader creates a new AzureBlobDownloader.

func (*AzureBlobDownloader) Start

func (d *AzureBlobDownloader) Start(ctx context.Context) error

Start starts the download.

type AzureBlobDownloaderConfig

type AzureBlobDownloaderConfig struct {
	Path        string
	Repository  string
	Destination string
	Retries     int
	DebugHTTP   bool
	TraceHTTP   bool
}

AzureBlobUploaderConfig configures AzureBlobDownloader.

type AzureBlobLocation

type AzureBlobLocation struct {
	StorageAccountName string
	ContainerName      string
	BlobPath           string
}

AzureBlobLocation specifies the location of a blob in Azure Blob Storage.

func ParseAzureBlobLocation

func ParseAzureBlobLocation(loc string) (*AzureBlobLocation, error)

ParseAzureBlobLocation parses a URL into an Azure Blob Storage location.

func (*AzureBlobLocation) String

func (l *AzureBlobLocation) String() string

String returns the location as a URL string.

func (*AzureBlobLocation) URL

func (l *AzureBlobLocation) URL(blob string) string

URL returns an Azure Blob Storage URL for the blob.

type AzureBlobUploader

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

AzureBlobUploader uploads artifacts to Azure Blob Storage.

func NewAzureBlobUploader

func NewAzureBlobUploader(l logger.Logger, c AzureBlobUploaderConfig) (*AzureBlobUploader, error)

NewAzureBlobUploader creates a new AzureBlobUploader.

func (*AzureBlobUploader) CreateWork

func (u *AzureBlobUploader) CreateWork(artifact *api.Artifact) ([]workUnit, error)

func (*AzureBlobUploader) URL

func (u *AzureBlobUploader) URL(artifact *api.Artifact) string

URL returns the full destination URL of an artifact.

type AzureBlobUploaderConfig

type AzureBlobUploaderConfig struct {
	// The destination which includes the storage account name and the path.
	// For example, "https://my-storage-account.blob.core.windows.net/my-container/my-virtual-directory/artifacts-go-here/"
	Destination string
}

AzureBlobUploaderConfig configures AzureBlobUploader.

type BKUploader

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

BKUploader uploads artifacts to Buildkite itself.

func NewBKUploader

func NewBKUploader(l logger.Logger, c BKUploaderConfig) *BKUploader

NewBKUploader creates a new Buildkite uploader.

func (*BKUploader) CreateWork

func (u *BKUploader) CreateWork(artifact *api.Artifact) ([]workUnit, error)

CreateWork creates workers for the artifact's upload instructions.

func (*BKUploader) URL

func (u *BKUploader) URL(*api.Artifact) string

URL returns the empty string. BKUploader doesn't know the URL in advance, it is provided by Buildkite after uploading.

type BKUploaderConfig

type BKUploaderConfig struct {
	// Standard HTTP options
	DebugHTTP    bool
	TraceHTTP    bool
	DisableHTTP2 bool
}

type BatchCreator

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

func NewArtifactBatchCreator

func NewArtifactBatchCreator(l logger.Logger, ac APIClient, c BatchCreatorConfig) *BatchCreator

func (*BatchCreator) Batches

func (a *BatchCreator) Batches(ctx context.Context) iter.Seq2[[]*api.Artifact, error]

Batches yields successive chunks of artifacts after batch-creating them on Buildkite (which assigns IDs and upload instructions). Each chunk is created immediately before it is yielded, keeping presigned upload URLs fresh.

type BatchCreatorConfig

type BatchCreatorConfig struct {
	// The ID of the Job that these artifacts belong to
	JobID string

	// All the artifacts that need to be created
	Artifacts []*api.Artifact

	// Where the artifacts are being uploaded to on the command line
	UploadDestination string

	// CreateArtifactsTimeout, sets a context.WithTimeout around the CreateArtifacts API.
	// If it's zero, there's no context timeout and the default HTTP timeout will prevail.
	CreateArtifactsTimeout time.Duration

	// Whether to allow multipart uploads to the BK-hosted bucket.
	AllowMultipart bool

	// OnBatchCreated observes successful CreateArtifacts calls.
	OnBatchCreated func(artifactCount int, duration time.Duration)
}

type Download

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

func NewDownload

func NewDownload(l logger.Logger, client *http.Client, c DownloadConfig) *Download

func (Download) Start

func (d Download) Start(ctx context.Context) error

type DownloadConfig

type DownloadConfig struct {
	// The actual URL to get the file from
	URL string

	// The root directory of the download
	Destination string

	// Optional Headers to append to the request
	Headers http.Header

	// HTTP method to use (default is GET)
	Method string

	// The relative path that should be preserved in the download folder
	Path string

	// How many times should it retry the download before giving up
	Retries int

	// Hexadecimal(SHA256(content)) used to verify the downloaded contents, if not empty
	WantSHA256 string

	// If failed responses should be dumped to the log
	// Standard HTTP options.
	DebugHTTP bool
	TraceHTTP bool
}

type Downloader

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

func NewDownloader

func NewDownloader(l logger.Logger, ac APIClient, c DownloaderConfig) Downloader

func (*Downloader) Download

func (a *Downloader) Download(ctx context.Context) error

type DownloaderConfig

type DownloaderConfig struct {
	// The ID of the Build
	BuildID string

	// The query used to find the artifacts
	Query string

	// Which step should we look at for the jobs
	Step string

	// Whether to include artifacts from retried jobs in the search
	IncludeRetriedJobs bool

	// Where we'll be downloading artifacts to
	Destination string

	// Standard HTTP options
	DebugHTTP    bool
	TraceHTTP    bool
	DisableHTTP2 bool

	// Whether to allow multipart downloads to the custom s3 bucket
	AllowS3Multipart bool
}

type Error

type Error struct {
	Status  int    `json:"status"`  // Error code
	Message string `json:"message"` // Message describing the error.
}

An Error reports more details on an individual error in an ErrorResponse.

type GSDownloader

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

func NewGSDownloader

func NewGSDownloader(l logger.Logger, c GSDownloaderConfig) *GSDownloader

func (GSDownloader) BucketFileLocation

func (d GSDownloader) BucketFileLocation() string

func (GSDownloader) BucketName

func (d GSDownloader) BucketName() string

func (GSDownloader) BucketPath

func (d GSDownloader) BucketPath() string

func (GSDownloader) Start

func (d GSDownloader) Start(ctx context.Context) error

type GSDownloaderConfig

type GSDownloaderConfig struct {
	// The name of the bucket
	Bucket string

	// The root directory of the download
	Destination string

	// The relative path that should be preserved in the download folder,
	// also its location in the bucket
	Path string

	// How many times should it retry the download before giving up
	Retries int

	// If failed responses should be dumped to the log
	DebugHTTP bool
	TraceHTTP bool
}

type GSUploader

type GSUploader struct {
	// The gs bucket path set from the destination
	BucketPath string

	// The gs bucket name set from the destination
	BucketName string
	// contains filtered or unexported fields
}

func NewGSUploader

func NewGSUploader(ctx context.Context, l logger.Logger, c GSUploaderConfig) (*GSUploader, error)

func (*GSUploader) CreateWork

func (u *GSUploader) CreateWork(artifact *api.Artifact) ([]workUnit, error)

func (*GSUploader) URL

func (u *GSUploader) URL(artifact *api.Artifact) string

type GSUploaderConfig

type GSUploaderConfig struct {
	// The destination which includes the GS bucket name and the path.
	// gs://my-bucket-name/foo/bar
	Destination string
}

type S3Downloader

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

func NewS3Downloader

func NewS3Downloader(l logger.Logger, c S3DownloaderConfig) *S3Downloader

func (S3Downloader) BucketFileLocation

func (d S3Downloader) BucketFileLocation() string

func (S3Downloader) BucketName

func (d S3Downloader) BucketName() string

func (S3Downloader) BucketPath

func (d S3Downloader) BucketPath() string

func (S3Downloader) Start

func (d S3Downloader) Start(ctx context.Context) error

type S3DownloaderConfig

type S3DownloaderConfig struct {
	// The client for interacting with S3
	S3Client *s3.Client

	// The S3 bucket name and the path, for example, s3://my-bucket-name/foo/bar
	S3Path string

	// The root directory of the download
	Destination string

	// The relative path that should be preserved in the download folder,
	// also its location in the bucket
	Path string

	// How many times should it retry the download before giving up
	Retries int

	// If failed responses should be dumped to the log
	DebugHTTP    bool
	TraceHTTP    bool
	DisableHTTP2 bool

	// Expected SHA-256 hex digest from the artifact API record. If non-empty,
	// the multipart path verifies the downloaded bytes against it before
	// atomic rename. Empty for legacy artifacts without a digest.
	ExpectedSHA256 string

	// Whether to allow multipart downloads to the custom s3 bucket
	AllowS3Multipart bool
}

type S3Uploader

type S3Uploader struct {
	// The s3 bucket path set from the destination
	BucketPath string

	// The s3 bucket name set from the destination
	BucketName string
	// contains filtered or unexported fields
}

func NewS3Uploader

func NewS3Uploader(ctx context.Context, l logger.Logger, c S3UploaderConfig) (*S3Uploader, error)

func (*S3Uploader) CreateWork

func (u *S3Uploader) CreateWork(artifact *api.Artifact) ([]workUnit, error)

func (*S3Uploader) URL

func (u *S3Uploader) URL(artifact *api.Artifact) string

type S3UploaderConfig

type S3UploaderConfig struct {
	// The destination which includes the S3 bucket name and the path.
	// For example, s3://my-bucket-name/foo/bar
	Destination string
}

type Searcher

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

func NewSearcher

func NewSearcher(l logger.Logger, ac APIClient, buildID string) *Searcher

func (*Searcher) Search

func (a *Searcher) Search(ctx context.Context, query, scope string, includeRetriedJobs, includeDuplicates bool) ([]*api.Artifact, error)

type Uploader

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

func NewUploader

func NewUploader(l logger.Logger, ac APIClient, c UploaderConfig) *Uploader

func (*Uploader) Upload

func (a *Uploader) Upload(ctx context.Context) error

type UploaderConfig

type UploaderConfig struct {
	// The ID of the Job
	JobID string

	// The path of the uploads
	Paths string

	// Where we'll be uploading artifacts
	Destination string

	// A specific Content-Type to use for all artifacts
	ContentType string

	// Standard HTTP options.
	DebugHTTP    bool
	TraceHTTP    bool
	DisableHTTP2 bool

	// When true, disables parsing Paths as globs; treat each path literally.
	Literal bool

	// The delimiter used to split Paths into multiple paths/globs.
	Delimiter string

	// Whether to follow symbolic links when resolving globs
	GlobResolveFollowSymlinks bool

	// Whether to not upload symlinks
	UploadSkipSymlinks bool

	// Whether to allow multipart uploads to the BK-hosted bucket
	AllowMultipart bool

	// How many upload operations to run concurrently. When zero, defaults to
	// DefaultUploadConcurrency.
	UploadConcurrency int
}

Jump to

Keyboard shortcuts

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