metadata

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	BucketMetadataVersion = "1.0.0"
	ObjectMetadataVersion = "1.0.0"
)

Metadata format versions

Variables

View Source
var (
	ErrUserNotFound           = errors.New("user not found")
	ErrPolicyNotFound         = errors.New("policy not found")
	ErrGroupNotFound          = errors.New("group not found")
	ErrGroupAlreadyExists     = errors.New("group already exists")
	ErrServiceAccountNotFound = errors.New("service account not found")
	ErrUsernameAlreadyTaken   = errors.New("username already taken")
	ErrAccessKeyAlreadyTaken  = errors.New("access key already taken")
)

Domain errors

Functions

This section is empty.

Types

type BucketMetadata

type BucketMetadata struct {
	Version      string          `json:"version"`                // DirIO metadata version
	Name         string          `json:"name"`                   // Bucket name
	Owner        *uuid.UUID      `json:"owner,omitempty"`        // User UUID; nil = admin-only (no specific owner)
	Created      time.Time       `json:"created"`                // Creation timestamp
	BucketPolicy *PolicyDocument `json:"bucketPolicy,omitempty"` // S3 bucket policy (resource-based)

	// Extended MinIO metadata (imported but may not be actively used yet)
	NotificationConfigXML       string    `json:"notificationConfig,omitempty"`
	LifecycleConfigXML          string    `json:"lifecycleConfig,omitempty"`
	ObjectLockConfigXML         string    `json:"objectLockConfig,omitempty"`
	VersioningConfigXML         string    `json:"versioningConfig,omitempty"`
	EncryptionConfigXML         string    `json:"encryptionConfig,omitempty"`
	TaggingConfigXML            string    `json:"taggingConfig,omitempty"`
	QuotaConfigJSON             string    `json:"quotaConfig,omitempty"`
	ReplicationConfigXML        string    `json:"replicationConfig,omitempty"`
	BucketTargetsConfigJSON     string    `json:"bucketTargetsConfig,omitempty"`
	BucketTargetsConfigMetaJSON string    `json:"bucketTargetsConfigMeta,omitempty"`
	PolicyConfigUpdatedAt       time.Time `json:"policyConfigUpdatedAt"`
	ObjectLockConfigUpdatedAt   time.Time `json:"objectLockConfigUpdatedAt"`
	EncryptionConfigUpdatedAt   time.Time `json:"encryptionConfigUpdatedAt"`
	TaggingConfigUpdatedAt      time.Time `json:"taggingConfigUpdatedAt"`
	QuotaConfigUpdatedAt        time.Time `json:"quotaConfigUpdatedAt"`
	ReplicationConfigUpdatedAt  time.Time `json:"replicationConfigUpdatedAt"`
	VersioningConfigUpdatedAt   time.Time `json:"versioningConfigUpdatedAt"`
}

BucketMetadata represents bucket configuration

type Group

type Group = iam.Group

type ImportState

type ImportState struct {
	Imported         bool      `json:"imported"`
	ImportedAt       time.Time `json:"importedAt"`
	AsyncComplete    bool      `json:"asyncComplete"`
	AsyncCompletedAt time.Time `json:"asyncCompletedAt"`
	MinIOModTime     time.Time `json:"minioModTime"`
	SourceVersion    string    `json:"sourceVersion"`
}

ImportState tracks MinIO import status. Phase 1 (blocking): policies, users, buckets, object metadata → Imported=true. Phase 2 (async): groups, service accounts → AsyncComplete=true.

type Manager

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

Manager handles metadata storage and retrieval

func New

func New(rootFS billy.Filesystem) (*Manager, error)

New creates a new metadata manager

func (*Manager) AddUserToGroup

func (m *Manager) AddUserToGroup(ctx context.Context, groupName string, userUid uuid.UUID) error

AddUserToGroup adds an access key to a group's member list (idempotent).

func (*Manager) AttachPolicyToGroup

func (m *Manager) AttachPolicyToGroup(ctx context.Context, groupName, policyName string) error

AttachPolicyToGroup adds a policy name to a group's attached policies (idempotent).

func (*Manager) CheckAndImportMinIO

func (m *Manager) CheckAndImportMinIO(ctx context.Context) (phase1Ran bool, asyncPhase func(context.Context), err error)

CheckAndImportMinIO checks for MinIO data and imports if needed.

It returns three values:

  • phase1Ran: true when Phase 1 (blocking) ran this call — callers use this to know whether to reload DataConfig.
  • asyncPhase: non-nil function containing Phase 2 work (groups, service accounts) that should be run in a background goroutine after the server starts. Nil when there is nothing left to import.
  • err: any fatal error from Phase 1.

Phase 1 (blocking): config, policies, users, buckets, object metadata. Phase 2 (async): groups, service accounts.

Restart recovery: if a previous run completed Phase 1 but was interrupted before Phase 2 finished, this call skips Phase 1 and returns only the async Phase 2 function (phase1Ran=false so DataConfig is not reloaded unnecessarily).

func (*Manager) Close

func (m *Manager) Close() error

Close closes the underlying bbolt database.

func (*Manager) CreateBucket

func (m *Manager) CreateBucket(ctx context.Context, bucket string) error

CreateBucket creates metadata for a new bucket

func (*Manager) CreateGroup

func (m *Manager) CreateGroup(ctx context.Context, groupName string) error

CreateGroup creates a new empty group. Returns ErrGroupAlreadyExists if it already exists.

func (*Manager) CreateOrUpdateUser

func (m *Manager) CreateOrUpdateUser(ctx context.Context, user *User) error

CreateOrUpdateUser creates a new user or updates an existing one. Returns ErrUsernameAlreadyTaken or ErrAccessKeyAlreadyTaken if a different user already holds the requested username or access key.

func (*Manager) CreateServiceAccount

func (m *Manager) CreateServiceAccount(ctx context.Context, sa *ServiceAccount) error

CreateServiceAccount saves a new service account. Returns error if key already exists.

func (*Manager) DeleteBucket

func (m *Manager) DeleteBucket(ctx context.Context, bucket string) error

DeleteBucket removes bucket metadata

func (*Manager) DeleteBucketPolicy

func (m *Manager) DeleteBucketPolicy(ctx context.Context, bucket string) error

DeleteBucketPolicy removes the bucket policy

func (*Manager) DeleteGroup

func (m *Manager) DeleteGroup(ctx context.Context, groupName string) error

DeleteGroup removes a group.

func (*Manager) DeleteObjectMetadata

func (m *Manager) DeleteObjectMetadata(ctx context.Context, bucket, key string) error

DeleteObjectMetadata removes object metadata

func (*Manager) DeletePolicy

func (m *Manager) DeletePolicy(ctx context.Context, name string) error

DeletePolicy removes a policy by name

func (*Manager) DeleteServiceAccount

func (m *Manager) DeleteServiceAccount(ctx context.Context, accessKey string) error

DeleteServiceAccount removes a service account.

func (*Manager) DeleteUser

func (m *Manager) DeleteUser(ctx context.Context, userUID uuid.UUID) error

DeleteUser removes a user and cleans up all indexes.

func (*Manager) DetachPolicyFromGroup

func (m *Manager) DetachPolicyFromGroup(ctx context.Context, groupName, policyName string) error

DetachPolicyFromGroup removes a policy name from a group's attached policies.

func (*Manager) GetAllBucketPolicies

func (m *Manager) GetAllBucketPolicies(ctx context.Context) (map[string]*PolicyDocument, error)

GetAllBucketPolicies retrieves all bucket policies for loading into the policy engine. Returns a map from bucket name to policy document (nil policies are excluded).

func (*Manager) GetBucketMetadata

func (m *Manager) GetBucketMetadata(ctx context.Context, bucket string) (*BucketMetadata, error)

GetBucketMetadata retrieves bucket metadata

func (*Manager) GetBucketPolicy

func (m *Manager) GetBucketPolicy(ctx context.Context, bucket string) (*PolicyDocument, error)

GetBucketPolicy retrieves the bucket policy

func (*Manager) GetGroup

func (m *Manager) GetGroup(ctx context.Context, groupName string) (*Group, error)

GetGroup retrieves a group by name.

func (*Manager) GetGroupNamesForUser

func (m *Manager) GetGroupNamesForUser(ctx context.Context, userUUID uuid.UUID) ([]string, error)

GetGroupNamesForUser returns the names of all groups the user with userUUID belongs to, using the bolt index (O(1) on disk for the lookup).

func (*Manager) GetGroups

func (m *Manager) GetGroups(ctx context.Context) (map[string]*Group, error)

GetGroups loads all groups.

func (*Manager) GetObjectMetadata

func (m *Manager) GetObjectMetadata(ctx context.Context, bucket, key string) (*ObjectMetadata, error)

GetObjectMetadata retrieves object metadata

func (*Manager) GetPolicies

func (m *Manager) GetPolicies(ctx context.Context) (map[string]*Policy, error)

GetPolicies retrieves all policies

func (*Manager) GetPolicy

func (m *Manager) GetPolicy(ctx context.Context, name string) (*Policy, error)

GetPolicy retrieves a policy by name

func (*Manager) GetServiceAccount

func (m *Manager) GetServiceAccount(ctx context.Context, accessKey string) (*ServiceAccount, error)

GetServiceAccount retrieves a service account by access key.

func (*Manager) GetServiceAccountByUUID

func (m *Manager) GetServiceAccountByUUID(ctx context.Context, saUUID uuid.UUID) (*ServiceAccount, error)

GetServiceAccountByUUID retrieves a service account by their UUID.

func (*Manager) GetServiceAccounts

func (m *Manager) GetServiceAccounts(ctx context.Context) (map[string]*ServiceAccount, error)

GetServiceAccounts loads all service accounts.

func (*Manager) GetUser

func (m *Manager) GetUser(ctx context.Context, userUID uuid.UUID) (*User, error)

GetUser retrieves a single user by username

func (*Manager) GetUserByAccessKey

func (m *Manager) GetUserByAccessKey(ctx context.Context, accessKey string) (*User, error)

GetUserByAccessKey retrieves a user by their access key using the bolt index (O(1) on disk).

func (*Manager) GetUserByUUID

func (m *Manager) GetUserByUUID(ctx context.Context, userUID uuid.UUID) (*User, error)

GetUserByUUID retrieves a user by their UUID.

func (*Manager) GetUserByUsername

func (m *Manager) GetUserByUsername(ctx context.Context, username string) (*User, error)

GetUserByUsername retrieves a user by their username using the bolt index (O(1) on disk).

func (*Manager) GetUsers

func (m *Manager) GetUsers(ctx context.Context) (map[uuid.UUID]*User, error)

GetUsers retrieves all users (convenience method, loads all user files)

func (*Manager) ListBucketMetadatas

func (m *Manager) ListBucketMetadatas(ctx context.Context) ([]*BucketMetadata, error)

ListBucketMetadatas returns the full metadata for every bucket.

func (*Manager) ListGroupNames

func (m *Manager) ListGroupNames(ctx context.Context) ([]string, error)

ListGroupNames returns all group names.

func (*Manager) ListPolicyNames

func (m *Manager) ListPolicyNames(ctx context.Context) ([]string, error)

ListPolicyNames returns all policy names

func (*Manager) ListServiceAccountKeys

func (m *Manager) ListServiceAccountKeys(ctx context.Context) ([]string, error)

ListServiceAccountKeys returns all service account access keys.

func (*Manager) ListUsers

func (m *Manager) ListUsers(ctx context.Context) ([]uuid.UUID, error)

ListUsers returns a list of all user UIDs

func (*Manager) MetricsSnapshot

func (m *Manager) MetricsSnapshot() (gets, misses, entries uint64, dbBytes int64)

MetricsSnapshot returns a point-in-time snapshot of metadata subsystem statistics for telemetry instrumentation.

func (*Manager) Ping

func (m *Manager) Ping() error

Ping performs a lightweight read-only transaction to verify the bbolt database is open and responsive. Returns non-nil if the DB is closed or otherwise unavailable.

func (*Manager) PutObjectMetadata

func (m *Manager) PutObjectMetadata(ctx context.Context, bucket, key string, meta *ObjectMetadata) error

PutObjectMetadata stores object metadata

func (*Manager) RemoveUserFromGroup

func (m *Manager) RemoveUserFromGroup(ctx context.Context, groupName string, userUid uuid.UUID) error

RemoveUserFromGroup removes an access key from a group's member list.

func (*Manager) SaveGroup

func (m *Manager) SaveGroup(ctx context.Context, g *Group) error

SaveGroup atomically saves a group.

func (*Manager) SavePolicy

func (m *Manager) SavePolicy(ctx context.Context, policy *Policy) error

SavePolicy saves a single policy

func (*Manager) SaveServiceAccount

func (m *Manager) SaveServiceAccount(ctx context.Context, sa *ServiceAccount) error

SaveServiceAccount atomically saves a service account (encrypts secret key).

func (*Manager) SaveUser

func (m *Manager) SaveUser(ctx context.Context, userUID uuid.UUID, user *User) error

SaveUser saves a single user (atomic operation). The SecretKey is encrypted before writing; the in-memory user is unchanged.

func (*Manager) SetBucketOwner

func (m *Manager) SetBucketOwner(ctx context.Context, bucket string, ownerUUID *uuid.UUID) error

SetBucketOwner updates the owner UUID of an existing bucket. Pass nil to clear ownership (admin-only bucket).

func (*Manager) SetBucketPolicy

func (m *Manager) SetBucketPolicy(ctx context.Context, bucket string, policy *PolicyDocument) error

SetBucketPolicy sets or updates the bucket policy

func (*Manager) SetGroupStatus

func (m *Manager) SetGroupStatus(ctx context.Context, groupName string, status iam.GroupStatus) error

SetGroupStatus updates a group's status.

func (*Manager) UpdateUser

func (m *Manager) UpdateUser(ctx context.Context, userUID uuid.UUID, updates *User) error

UpdateUser updates an existing user's mutable fields and keeps the bolt indexes in sync.

type ObjectMetadata

type ObjectMetadata struct {
	Version        string            `json:"version"`                  // DirIO metadata version
	Owner          *uuid.UUID        `json:"owner,omitempty"`          // User UUID; nil = admin-only (no specific owner)
	ContentType    string            `json:"contentType"`              // MIME type
	Size           int64             `json:"size"`                     // Object size in bytes
	ETag           string            `json:"etag"`                     // Entity tag (MD5 hash)
	LastModified   time.Time         `json:"lastModified"`             // Last modification timestamp
	CustomMetadata map[string]string `json:"customMetadata,omitempty"` // Custom headers like Cache-Control, Content-Disposition, x-amz-meta-*, etc.
	Tags           map[string]string `json:"tags,omitempty"`           // Object tags (key-value pairs)
}

ObjectMetadata represents object metadata

type Policy

type Policy = iam.Policy

type PolicyDocument

type PolicyDocument = iam.PolicyDocument

type PolicyStatement

type PolicyStatement = iam.Statement

type ServiceAccount

type ServiceAccount = iam.ServiceAccount

type User

type User = iam.User

Type aliases for backward compatibility

Jump to

Keyboard shortcuts

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