blob

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package blob is a minimal S3/MinIO object client for the few places Miabi must touch an object store directly from Go: a bundle's control objects and bucket listings, and `miabi restore`, which reads a sealed envelope on a bare host before any platform exists.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("object not found")

ErrNotFound is returned when an object (or the bucket) does not exist.

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoint       string // empty for AWS S3; host or URL for MinIO and friends
	Bucket         string
	Region         string
	AccessKey      string
	SecretKey      string
	UseSSL         bool
	ForcePathStyle bool
}

Config describes an S3-compatible target. It mirrors the fields of the backup S3 settings so callers can hand the same values to either path.

type Object

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

Object is one listed object.

type Probe

type Probe struct {
	// Key is the object the probe used, for the message shown to the operator.
	Key string
	// Wrote, ReadBack and Removed record how far it got.
	Wrote    bool
	ReadBack bool
	Removed  bool
}

Probe verifies a target end to end by using it: writes a small object, reads it back, compares the bytes, removes it. Deliberately not a HeadBucket — a bucket that exists says nothing about whether these credentials may write to it under the attached policy.

func RunProbe

func RunProbe(ctx context.Context, cfg Config, prefix string) (Probe, error)

RunProbe performs the round trip under prefix, naming the operation that failed so the operator learns which permission is missing. Delete is attempted but never fatal: a missing delete permission costs retention, not data, and the caller sees it in Removed.

type Store

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

Store is a bucket-scoped object client.

func New

func New(cfg Config) (*Store, error)

New builds a client for cfg. It does not contact the network; the first Get/Put/List reports connectivity or credential problems.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string) error

Delete removes an object. Deleting an absent object is not an error, so retention pruning is idempotent.

func (*Store) Exists

func (s *Store) Exists(ctx context.Context, key string) (bool, error)

Exists reports whether an object is present.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) (io.ReadCloser, int64, error)

Get opens an object for reading. The caller closes the returned reader.

func (*Store) GetBytes

func (s *Store) GetBytes(ctx context.Context, key string) ([]byte, error)

GetBytes reads a whole object. Intended for small control objects (the identity envelope, manifests) — not for artifacts.

func (*Store) List

func (s *Store) List(ctx context.Context, prefix string) ([]Object, error)

List returns every object under prefix, following pagination.

func (*Store) Put

func (s *Store) Put(ctx context.Context, key string, body []byte) error

Put writes an object.

Jump to

Keyboard shortcuts

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