Introduces code.nochebuena.dev/einherjar/storage-minio — the object storage starter for the Einherjar framework. Absorbs the minio package from micro-lib, replacing fmt.Errorf wrapping with core/xerrors. Interfaces (CT-6: one TypeSpec per file): - Provider — PutObject, RemoveObject, GetObject, PresignedGetObject, HandleError - Component — lifecycle.Component + observability.Checkable + Provider + Native() Implementation: - New(logger, cfg) Component — client not created until OnInit - OnInit: minio.New with credentials and transport; bucket existence check - OnStart: BucketExists PING; logs "minio: connected" - OnStop: logs "minio: closing client" (minio-go is stateless; no explicit close) - HealthCheck: BucketExists check; Priority LevelCritical - Native() *miniogo.Client — escape hatch for operations not in Provider - HandleError: maps minio-go errors to xerrors (NotFound, AlreadyExists, Internal) Config (EINHERJAR_MINIO_* env vars): Endpoint(required), AccessKey(required), SecretKey(required), Bucket(required), UseSSL(false), Region(us-east-1) - Component interface embeds observability.Identifiable; identifiable.go implements ModulePath and ModuleVersion via runtime/debug.ReadBuildInfo() — prints in launcher banner
28 lines
1.1 KiB
Go
28 lines
1.1 KiB
Go
package minio
|
|
|
|
import "net/http"
|
|
|
|
// Config holds MinIO connection settings. Required fields must be supplied
|
|
// by the caller; optional fields have production-safe defaults via DefaultConfig.
|
|
type Config struct {
|
|
Endpoint string `env:"EINHERJAR_MINIO_ENDPOINT,required"`
|
|
AccessKey string `env:"EINHERJAR_MINIO_ACCESS_KEY,required"`
|
|
SecretKey string `env:"EINHERJAR_MINIO_SECRET_KEY,required"`
|
|
UseSSL bool `env:"EINHERJAR_MINIO_USE_SSL" envDefault:"false"`
|
|
Bucket string `env:"EINHERJAR_MINIO_BUCKET,required"`
|
|
// Region defaults to "us-east-1" — the region MinIO uses by default on self-hosted
|
|
// deployments. Setting a non-empty region bypasses per-request region detection.
|
|
Region string `env:"EINHERJAR_MINIO_REGION" envDefault:"us-east-1"`
|
|
// Transport is used for testing only. Nil uses the minio-go default transport.
|
|
Transport http.RoundTripper `env:"-"`
|
|
}
|
|
|
|
// DefaultConfig returns a Config with all optional fields set to production-safe
|
|
// defaults. Callers must supply Endpoint, AccessKey, SecretKey, and Bucket.
|
|
func DefaultConfig() Config {
|
|
return Config{
|
|
UseSSL: false,
|
|
Region: "us-east-1",
|
|
}
|
|
}
|