storage

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveArtifactStream

func ResolveArtifactStream(ctx context.Context, cli Client, namespace, path string) (io.ReadCloser, error)

func UploadArtifact

func UploadArtifact(ctx context.Context, c Client, namespace, path string, in io.Reader) error

Types

type ArtifactInfo

type ArtifactInfo struct {
	// Timestamp of the artifact commit.
	CreatedAt time.Time

	// Digest of the uploaded content.
	DigestSHA256 string
}

func ResolveArtifactWithOpts

func ResolveArtifactWithOpts(ctx context.Context, cli Client, namespace, path string, opts ResolveArtifactOpts) (io.ReadCloser, ArtifactInfo, error)

func UploadArtifactWithOpts

func UploadArtifactWithOpts(ctx context.Context, c Client, namespace, path string, in io.Reader, o UploadOpts) (ArtifactInfo, error)

type CacheInfo

type CacheInfo struct {
	CachedAt time.Time
}

func CacheURL

func CacheURL(ctx context.Context, cli Client, sourceURL string, opts CacheURLOpts) (io.ReadCloser, CacheInfo, error)

Download the content from an arbitrary URL and cache it for fast access.

The content at the URL is assumed to be immutable. If content is already present in the artifact cache for the given URL it will be used instead.

Returns CacheSourceError if it fails downloading from sourceURL.

type CacheSourceError

type CacheSourceError struct {
	Err            error
	HTTPStatusCode int
}

func (CacheSourceError) Error

func (err CacheSourceError) Error() string

func (CacheSourceError) Unwrap

func (err CacheSourceError) Unwrap() error

type CacheURLOpts

type CacheURLOpts struct {
	// Re-download from source if cached data is older than that.
	NewerThan time.Time

	// Verify digest of the cached or downloaded data.
	ExpectedSHA256 string

	// Receives human-readable debug messages.
	Logf func(string, ...interface{})
}

type Client

type Client struct {
	Artifacts storagev1betagrpc.ArtifactsServiceClient

	Conn *grpc.ClientConn
}

func NewClient

func NewClient(ctx context.Context, token api.TokenSource, opts ...grpc.DialOption) (Client, error)

func NewClientWithEndpoint

func NewClientWithEndpoint(ctx context.Context, endpoint string, token api.TokenSource, opts ...grpc.DialOption) (Client, error)

func (Client) Close

func (c Client) Close() error

type ResolveArtifactOpts

type ResolveArtifactOpts struct {
}

type UploadOpts

type UploadOpts struct {
	// Artifact labels to save.
	Labels map[string]string

	// Expected length of the uploaded content.
	// If not set and the Reader is a Seeker, the length will be determined automatically.
	// Otherwise the content will be buffered in memory.
	Length int64

	// Expected MD5 of the uploaded content; optional.
	MD5 string
}

Jump to

Keyboard shortcuts

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