common

package
v4.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeleteNotSupported = errors.New("delete not supported for this artifact storage, please check" +
	" the following issue for details: https://github.com/argoproj/argo-workflows/issues/3102")

ErrDeleteNotSupported Sentinel error definition for artifact deletion

Functions

func BufferReaderToTempFile

func BufferReaderToTempFile(reader io.Reader, pattern string) (path string, cleanup func(), err error)

BufferReaderToTempFile buffers reader into a new temp file (named per the os.CreateTemp pattern, e.g. "s3-upload-*") so its content can be re-read multiple times, which most storage SDKs require for retry/backoff. It returns the temp file's path and a cleanup function that removes it; cleanup is safe to call more than once. On error, any partially written temp file is removed before returning, so callers only need to defer cleanup after a nil error.

func LoadToStream

func LoadToStream(ctx context.Context, a *wfv1.Artifact, g ArtifactDriver) (io.ReadCloser, error)

LoadToStream uses ArtifactDriver.Load() to get a stream, which can be used for all implementations of ArtifactDriver.OpenStream() that aren't yet implemented the "right way" and/or for those that don't have a natural way of streaming.

func SaveStreamViaTempFile

func SaveStreamViaTempFile(reader io.Reader, pattern string, save func(path string) error) error

SaveStreamViaTempFile buffers reader to a temp file and hands the path to save, so drivers whose storage SDK needs a seekable input reuse their existing Save logic (bucket creation, key normalization, retries) unchanged instead of reimplementing it per driver.

Types

type ArtifactDriver

type ArtifactDriver interface {
	// Load accepts an artifact source URL and places it at specified path
	Load(ctx context.Context, inputArtifact *v1alpha1.Artifact, path string) error

	// OpenStream opens an artifact for reading. If the artifact is a file,
	// then the file should be opened. If the artifact is a directory, the
	// driver may return that as a tarball. OpenStream is intended to be efficient,
	// so implementations should minimise usage of disk, CPU and memory.
	// Implementations must not implement retry mechanisms. This will be handled by
	// the client, so would result in O(nm) cost.
	OpenStream(ctx context.Context, a *v1alpha1.Artifact) (io.ReadCloser, error)

	// Save uploads the path to artifact destination
	Save(ctx context.Context, path string, outputArtifact *v1alpha1.Artifact) error

	// SaveStream saves an artifact from an io.Reader.
	// Whether the reader is streamed directly or buffered to a temp file first is
	// implementation-specific, so the reader may be partially consumed on failure;
	// callers must not retry with the same reader.
	SaveStream(ctx context.Context, reader io.Reader, outputArtifact *v1alpha1.Artifact) error

	Delete(ctx context.Context, artifact *v1alpha1.Artifact) error

	ListObjects(ctx context.Context, artifact *v1alpha1.Artifact) ([]string, error)

	IsDirectory(ctx context.Context, artifact *v1alpha1.Artifact) (bool, error)
}

ArtifactDriver is the interface for loading and saving of artifacts

Jump to

Keyboard shortcuts

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