Documentation
¶
Index ¶
- Constants
- Variables
- func FromBytesToUUID(b []byte) (uuid.UUID, error)
- type BucketMetadata
- type Group
- type ImportState
- type Manager
- func (m *Manager) AddUserToGroup(ctx context.Context, groupName string, userUid uuid.UUID) error
- func (m *Manager) AttachPolicyToGroup(ctx context.Context, groupName, policyName string) error
- func (m *Manager) CheckAndImportMinIO(ctx context.Context) (phase1Ran bool, asyncPhase func(context.Context), err error)
- func (m *Manager) Close() error
- func (m *Manager) CreateBucket(ctx context.Context, bucket string) error
- func (m *Manager) CreateGroup(ctx context.Context, groupName string) error
- func (m *Manager) CreateOrUpdateUser(ctx context.Context, user *User) error
- func (m *Manager) CreateServiceAccount(ctx context.Context, sa *ServiceAccount) error
- func (m *Manager) DeleteBucket(ctx context.Context, bucket string) error
- func (m *Manager) DeleteBucketPolicy(ctx context.Context, bucket string) error
- func (m *Manager) DeleteGroup(ctx context.Context, groupName string) error
- func (m *Manager) DeleteObjectMetadata(ctx context.Context, bucket, key string) error
- func (m *Manager) DeletePolicy(ctx context.Context, name string) error
- func (m *Manager) DeleteServiceAccount(ctx context.Context, accessKey string) error
- func (m *Manager) DeleteUser(ctx context.Context, userUID uuid.UUID) error
- func (m *Manager) DetachPolicyFromGroup(ctx context.Context, groupName, policyName string) error
- func (m *Manager) GetAllBucketPolicies(ctx context.Context) (map[string]*PolicyDocument, error)
- func (m *Manager) GetBucketMetadata(ctx context.Context, bucket string) (*BucketMetadata, error)
- func (m *Manager) GetBucketPolicy(ctx context.Context, bucket string) (*PolicyDocument, error)
- func (m *Manager) GetGroup(ctx context.Context, groupName string) (*Group, error)
- func (m *Manager) GetGroupNamesForUser(ctx context.Context, userUUID uuid.UUID) ([]string, error)
- func (m *Manager) GetGroups(ctx context.Context) (map[string]*Group, error)
- func (m *Manager) GetObjectMetadata(ctx context.Context, bucket, key string) (*ObjectMetadata, error)
- func (m *Manager) GetPolicies(ctx context.Context) (map[string]*Policy, error)
- func (m *Manager) GetPolicy(ctx context.Context, name string) (*Policy, error)
- func (m *Manager) GetServiceAccount(ctx context.Context, accessKey string) (*ServiceAccount, error)
- func (m *Manager) GetServiceAccountByUUID(ctx context.Context, saUUID uuid.UUID) (*ServiceAccount, error)
- func (m *Manager) GetServiceAccounts(ctx context.Context) (map[string]*ServiceAccount, error)
- func (m *Manager) GetUser(ctx context.Context, userUID uuid.UUID) (*User, error)
- func (m *Manager) GetUserByAccessKey(ctx context.Context, accessKey string) (*User, error)
- func (m *Manager) GetUserByUUID(ctx context.Context, userUID uuid.UUID) (*User, error)
- func (m *Manager) GetUserByUsername(ctx context.Context, username string) (*User, error)
- func (m *Manager) GetUsers(ctx context.Context) (map[uuid.UUID]*User, error)
- func (m *Manager) ListBucketMetadatas(ctx context.Context) ([]*BucketMetadata, error)
- func (m *Manager) ListGroupNames(ctx context.Context) ([]string, error)
- func (m *Manager) ListPolicyNames(ctx context.Context) ([]string, error)
- func (m *Manager) ListServiceAccountKeys(ctx context.Context) ([]string, error)
- func (m *Manager) ListUsers(ctx context.Context) ([]uuid.UUID, error)
- func (m *Manager) MetricsSnapshot() (gets, misses, entries uint64, dbBytes int64)
- func (m *Manager) Ping() error
- func (m *Manager) PutObjectMetadata(ctx context.Context, bucket, key string, meta *ObjectMetadata) error
- func (m *Manager) RemoveUserFromGroup(ctx context.Context, groupName string, userUid uuid.UUID) error
- func (m *Manager) SaveGroup(ctx context.Context, g *Group) error
- func (m *Manager) SavePolicy(ctx context.Context, policy *Policy) error
- func (m *Manager) SaveServiceAccount(ctx context.Context, sa *ServiceAccount) error
- func (m *Manager) SaveUser(ctx context.Context, userUID uuid.UUID, user *User) error
- func (m *Manager) SetBucketOwner(ctx context.Context, bucket string, ownerUUID *uuid.UUID) error
- func (m *Manager) SetBucketPolicy(ctx context.Context, bucket string, policy *PolicyDocument) error
- func (m *Manager) SetGroupStatus(ctx context.Context, groupName string, status iam.GroupStatus) error
- func (m *Manager) UpdateUser(ctx context.Context, userUID uuid.UUID, updates *User) error
- type ObjectMetadata
- type Policy
- type PolicyDocument
- type PolicyStatement
- type ServiceAccount
- type User
Constants ¶
const ( BucketMetadataVersion = "1.0.0" ObjectMetadataVersion = "1.0.0" )
Metadata format versions
Variables ¶
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 ¶
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 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 (*Manager) AddUserToGroup ¶
AddUserToGroup adds an access key to a group's member list (idempotent).
func (*Manager) AttachPolicyToGroup ¶
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) CreateBucket ¶
CreateBucket creates metadata for a new bucket
func (*Manager) CreateGroup ¶
CreateGroup creates a new empty group. Returns ErrGroupAlreadyExists if it already exists.
func (*Manager) CreateOrUpdateUser ¶
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 ¶
DeleteBucket removes bucket metadata
func (*Manager) DeleteBucketPolicy ¶
DeleteBucketPolicy removes the bucket policy
func (*Manager) DeleteGroup ¶
DeleteGroup removes a group.
func (*Manager) DeleteObjectMetadata ¶
DeleteObjectMetadata removes object metadata
func (*Manager) DeletePolicy ¶
DeletePolicy removes a policy by name
func (*Manager) DeleteServiceAccount ¶
DeleteServiceAccount removes a service account.
func (*Manager) DeleteUser ¶
DeleteUser removes a user and cleans up all indexes.
func (*Manager) DetachPolicyFromGroup ¶
DetachPolicyFromGroup removes a policy name from a group's attached policies.
func (*Manager) GetAllBucketPolicies ¶
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 ¶
GetBucketMetadata retrieves bucket metadata
func (*Manager) GetBucketPolicy ¶
GetBucketPolicy retrieves the bucket policy
func (*Manager) GetGroupNamesForUser ¶
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) GetObjectMetadata ¶
func (m *Manager) GetObjectMetadata(ctx context.Context, bucket, key string) (*ObjectMetadata, error)
GetObjectMetadata retrieves object metadata
func (*Manager) GetPolicies ¶
GetPolicies retrieves all policies
func (*Manager) GetServiceAccount ¶
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 ¶
GetServiceAccounts loads all service accounts.
func (*Manager) GetUserByAccessKey ¶
GetUserByAccessKey retrieves a user by their access key using the bolt index (O(1) on disk).
func (*Manager) GetUserByUUID ¶
GetUserByUUID retrieves a user by their UUID.
func (*Manager) GetUserByUsername ¶
GetUserByUsername retrieves a user by their username using the bolt index (O(1) on disk).
func (*Manager) ListBucketMetadatas ¶
func (m *Manager) ListBucketMetadatas(ctx context.Context) ([]*BucketMetadata, error)
ListBucketMetadatas returns the full metadata for every bucket.
func (*Manager) ListGroupNames ¶
ListGroupNames returns all group names.
func (*Manager) ListPolicyNames ¶
ListPolicyNames returns all policy names
func (*Manager) ListServiceAccountKeys ¶
ListServiceAccountKeys returns all service account access keys.
func (*Manager) MetricsSnapshot ¶
MetricsSnapshot returns a point-in-time snapshot of metadata subsystem statistics for telemetry instrumentation.
func (*Manager) Ping ¶
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) SavePolicy ¶
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 ¶
SaveUser saves a single user (atomic operation). The SecretKey is encrypted before writing; the in-memory user is unchanged.
func (*Manager) SetBucketOwner ¶
SetBucketOwner updates the owner UUID of an existing bucket. Pass nil to clear ownership (admin-only bucket).
func (*Manager) SetBucketPolicy ¶
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.
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 PolicyDocument ¶
type PolicyDocument = iam.PolicyDocument
type PolicyStatement ¶
type ServiceAccount ¶
type ServiceAccount = iam.ServiceAccount