s3

package
v0.40.21 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package s3 is a minimal S3 client for the telemetry archive: put, get, delete and list objects in one bucket, path-style, signed with AWS Signature Version 4 over the real payload hash (never UNSIGNED-PAYLOAD). It talks to the in-cluster MinIO; nothing here is MinIO-specific.

A handful of verbs didn't justify a client library and its dependency tree (DA, N19 A2): the signer is checked against AWS's published examples (s3_test.go) and every verb against a real MinIO (integration test).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("s3: no such key")

ErrNotFound is a GET of a key that doesn't exist.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Endpoint is the service URL, e.g. http://minio.minio.svc:9000.
	Endpoint  string
	Region    string // e.g. us-east-1
	Bucket    string
	AccessKey string
	SecretKey string
	// HTTP defaults to a client with a 2-minute timeout.
	HTTP *http.Client
	// Now is the signing clock (tests pin it).
	Now func() time.Time
	// ListPageSize is ListObjectsV2's max-keys (0: the server's 1000). Tests
	// set it small to exercise continuation.
	ListPageSize int
}

Client is one bucket on one endpoint.

func (*Client) CreateBucket

func (c *Client) CreateBucket(ctx context.Context) error

CreateBucket creates the client's bucket. For tests and local development: in a cluster the buckets are created by the MinIO bootstrap Job, and the app's credentials can't create them.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string) error

Delete removes key; deleting a missing key is not an error (S3 semantics).

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (io.ReadCloser, error)

Get returns the object's body; the caller closes it. A missing key is ErrNotFound.

func (*Client) List

func (c *Client) List(ctx context.Context, prefix string, fn func(Object) error) error

List calls fn for every object under prefix, following ListObjectsV2 continuation tokens until the listing is complete or fn returns an error.

func (*Client) Put

func (c *Client) Put(ctx context.Context, key string, body []byte, contentType string) error

Put stores body under key.

type Object

type Object struct {
	Key          string
	Size         int64
	ETag         string
	LastModified time.Time
}

Object is one ListObjectsV2 entry.

Jump to

Keyboard shortcuts

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