s3files

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 24 Imported by: 0

README

S3 Files

Parity grade: B · SDK aws-sdk-go-v2/service/s3files@v1.8.1 · last audited 2026-10-18 (d52fe4ac6)

Coverage

Metric Value
PARITY entries audited 21 (21 ok)
Known gaps 7
Structural gaps (can't be emulated) 1
Deferred items 0
Resource leaks clean
Known gaps
  • CreateMountTarget: IPv6 is never allocated; the EC2 emulator models no requester-managed flag on the mount target network interface.
  • CreateFileSystem: AcceptBucketWarning is accepted but no bucket warnings exist; the error code for a missing role or key (ValidationException) is inferred, the SDK does not pin it.
  • GetSynchronizationConfiguration returns ResourceNotFoundException until a configuration is put; the real service may seed a default configuration at creation, which the SDK docs do not state.
  • ServiceQuotaExceededException, ThrottlingException and InternalServerException are never returned: the S3 Files quotas are not published in the SDK, so no limit is enforced.
  • Error HTTP statuses (400/404/409) are inferred; the SDK dispatches on the X-Amzn-Errortype header and does not pin statuses. ConflictException carries resourceId and resourceType.
  • Access point and file system ARN resource paths (access-point/, file-system/) are assumed from sibling services; the SDK documents ARNs only as opaque strings.
  • The creating/deleting dwell is zero by default and is not exposed as a CLI lifecycle setting; tests drive it with SetLifecycleDelay.
Structural gaps

These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.

  • No NFS/file data plane: files are not served from or exported to the S3 bucket, and no import or expiration rule is ever evaluated.

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a file system, mount target, access point or policy does not exist.
	ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound)
	// ErrConflict is returned when the request conflicts with the resource's current state.
	ErrConflict = awserr.New("ConflictException", awserr.ErrConflict)
	// ErrValidation is returned for malformed or out-of-range input.
	ErrValidation = awserr.New("ValidationException", awserr.ErrInvalidParameter)
)
View Source
var ErrNilAppContext = errors.New("appContext must not be nil")

ErrNilAppContext is returned when Init is called with a nil application context.

Functions

This section is empty.

Types

type AccessPoint

type AccessPoint struct {
	Tags          map[string]string `json:"tags,omitempty"`
	PosixUser     *PosixUser        `json:"posixUser,omitempty"`
	RootDirectory *RootDirectory    `json:"rootDirectory,omitempty"`
	ID            string            `json:"id"`
	ARN           string            `json:"arn"`
	FileSystemID  string            `json:"fileSystemId"`
	ClientToken   string            `json:"clientToken,omitempty"`
	OwnerID       string            `json:"ownerId"`
	Region        string            `json:"region"`
	Lifecycle
}

AccessPoint is an application-specific entry point into a file system.

type BucketResolver

type BucketResolver interface {
	BucketExists(ctx context.Context, bucket string) bool
}

BucketResolver checks that an S3 bucket exists in the emulated S3 service.

type CreateAccessPointInput

type CreateAccessPointInput struct {
	Tags          map[string]string
	PosixUser     *PosixUser
	RootDirectory *RootDirectory
	FileSystemID  string
	ClientToken   string
}

CreateAccessPointInput is the backend form of CreateAccessPoint.

type CreateFileSystemInput

type CreateFileSystemInput struct {
	Tags        map[string]string
	Bucket      string
	RoleARN     string
	ClientToken string
	KMSKeyID    string
	Prefix      string
}

CreateFileSystemInput is the backend form of CreateFileSystem.

type CreateMountTargetInput

type CreateMountTargetInput struct {
	FileSystemID   string
	SubnetID       string
	IPAddressType  string
	IPv4Address    string
	IPv6Address    string
	SecurityGroups []string
}

CreateMountTargetInput is the backend form of CreateMountTarget.

type CreationPermissions

type CreationPermissions struct {
	OwnerUID    *int64  `json:"ownerUid"`
	OwnerGID    *int64  `json:"ownerGid"`
	Permissions *string `json:"permissions"`
}

CreationPermissions are applied to a newly created root directory.

type ENI

type ENI struct {
	ID             string
	PrivateIP      string
	SecurityGroups []string
}

ENI is a provisioned network interface.

type ENIRequest

type ENIRequest struct {
	SubnetID       string
	Description    string
	IPv4Address    string
	SecurityGroups []string
}

ENIRequest describes the network interface backing a mount target.

type ExpirationDataRule

type ExpirationDataRule struct {
	DaysAfterLastAccess *int32 `json:"daysAfterLastAccess"`
}

ExpirationDataRule controls when cached data expires from a file system.

type FileSystem

type FileSystem struct {
	Tags        map[string]string  `json:"tags,omitempty"`
	Sync        *SyncConfiguration `json:"sync,omitempty"`
	ID          string             `json:"id"`
	ARN         string             `json:"arn"`
	Bucket      string             `json:"bucket"`
	Prefix      string             `json:"prefix,omitempty"`
	RoleARN     string             `json:"roleArn"`
	KMSKeyID    string             `json:"kmsKeyId,omitempty"`
	ClientToken string             `json:"clientToken,omitempty"`
	OwnerID     string             `json:"ownerId"`
	Region      string             `json:"region"`
	Policy      string             `json:"policy,omitempty"`
	Lifecycle
}

FileSystem is an S3 file system scoped to a bucket or prefix.

type Handler

type Handler struct {
	Backend *InMemoryBackend
	// contains filtered or unexported fields
}

Handler is the Echo handler for the S3 Files REST-JSON API.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a handler over backend.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations lists the fault-injectable operations.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions lists the regions served.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase service name for fault rules.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name for the request.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the primary resource identifier for the request.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists the implemented operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all backend state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher matches requests signed for s3files. Its paths (/file-systems, /access-points, ...) carry no service prefix, so the SigV4 signing name or the s3files endpoint host is the discriminator.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable.

type ImportDataRule

type ImportDataRule struct {
	Prefix       *string `json:"prefix"`
	SizeLessThan *int64  `json:"sizeLessThan"`
	Trigger      string  `json:"trigger"`
}

ImportDataRule controls how S3 data is imported into a file system.

type InMemoryBackend

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

InMemoryBackend is the in-memory S3 Files backend. One coarse lock guards all tables.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) CreateAccessPoint

func (b *InMemoryBackend) CreateAccessPoint(
	ctx context.Context,
	in CreateAccessPointInput,
) (*AccessPoint, bool, error)

CreateAccessPoint creates an access point; created is false for an idempotent replay.

func (*InMemoryBackend) CreateFileSystem

func (b *InMemoryBackend) CreateFileSystem(
	ctx context.Context,
	in CreateFileSystemInput,
) (*FileSystem, bool, error)

CreateFileSystem creates a file system on an S3 bucket; created is false for an idempotent replay.

func (*InMemoryBackend) CreateMountTarget

func (b *InMemoryBackend) CreateMountTarget(ctx context.Context, in CreateMountTargetInput) (*MountTarget, error)

CreateMountTarget creates a mount target for an available file system.

func (*InMemoryBackend) DeleteAccessPoint

func (b *InMemoryBackend) DeleteAccessPoint(ctx context.Context, ref string) error

DeleteAccessPoint deletes an access point.

func (*InMemoryBackend) DeleteFileSystem

func (b *InMemoryBackend) DeleteFileSystem(ctx context.Context, ref string, force bool) error

DeleteFileSystem deletes a file system; with force it first deletes its mount targets and access points.

func (*InMemoryBackend) DeleteFileSystemPolicy

func (b *InMemoryBackend) DeleteFileSystemPolicy(ctx context.Context, ref string) error

DeleteFileSystemPolicy removes the resource policy of a file system.

func (*InMemoryBackend) DeleteMountTarget

func (b *InMemoryBackend) DeleteMountTarget(ctx context.Context, id string) error

DeleteMountTarget deletes a mount target.

func (*InMemoryBackend) GetAccessPoint

func (b *InMemoryBackend) GetAccessPoint(ctx context.Context, ref string) (*AccessPoint, error)

GetAccessPoint returns an access point by ID or ARN.

func (*InMemoryBackend) GetFileSystem

func (b *InMemoryBackend) GetFileSystem(ctx context.Context, ref string) (*FileSystem, error)

GetFileSystem returns a file system by ID or ARN.

func (*InMemoryBackend) GetFileSystemPolicy

func (b *InMemoryBackend) GetFileSystemPolicy(ctx context.Context, ref string) (string, string, error)

GetFileSystemPolicy returns the resource policy and the file system's ID.

func (*InMemoryBackend) GetMountTarget

func (b *InMemoryBackend) GetMountTarget(ctx context.Context, id string) (*MountTarget, error)

GetMountTarget returns a mount target by ID.

func (*InMemoryBackend) GetSynchronizationConfiguration

func (b *InMemoryBackend) GetSynchronizationConfiguration(ctx context.Context, ref string) (*SyncConfiguration, error)

GetSynchronizationConfiguration returns the sync configuration of a file system.

func (*InMemoryBackend) ListAccessPoints

func (b *InMemoryBackend) ListAccessPoints(
	ctx context.Context,
	fileSystemRef string,
	maxResults int,
	token string,
) (page.Page[*AccessPoint], error)

ListAccessPoints lists the access points of one file system.

func (*InMemoryBackend) ListFileSystems

func (b *InMemoryBackend) ListFileSystems(
	ctx context.Context,
	bucket string,
	maxResults int,
	token string,
) (page.Page[*FileSystem], error)

ListFileSystems lists file systems, optionally restricted to one bucket ARN.

func (*InMemoryBackend) ListMountTargets

func (b *InMemoryBackend) ListMountTargets(
	ctx context.Context,
	fileSystemRef, accessPointRef string,
	maxResults int,
	token string,
) (page.Page[*MountTarget], error)

ListMountTargets lists mount targets, optionally filtered by file system or access point.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(
	ctx context.Context,
	ref string,
	maxResults int,
	token string,
) (page.Page[KV], error)

ListTagsForResource lists a resource's tags sorted by key.

func (*InMemoryBackend) PutFileSystemPolicy

func (b *InMemoryBackend) PutFileSystemPolicy(ctx context.Context, ref, policy string) error

PutFileSystemPolicy sets the resource policy of a file system.

func (*InMemoryBackend) PutSynchronizationConfiguration

func (b *InMemoryBackend) PutSynchronizationConfiguration(ctx context.Context, ref string, in PutSyncInput) error

PutSynchronizationConfiguration creates or replaces the sync configuration, with optimistic versioning.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the default region.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads state produced by Snapshot.

func (*InMemoryBackend) SetBucketResolver

func (b *InMemoryBackend) SetBucketResolver(r BucketResolver)

SetBucketResolver wires S3 bucket validation; nil leaves buckets unvalidated.

func (*InMemoryBackend) SetClock

func (b *InMemoryBackend) SetClock(now func() time.Time)

SetClock replaces the time source (tests).

func (*InMemoryBackend) SetKeyResolver

func (b *InMemoryBackend) SetKeyResolver(r KeyResolver)

SetKeyResolver wires KMS key validation; nil leaves key IDs unchecked.

func (*InMemoryBackend) SetLifecycleDelay

func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)

SetLifecycleDelay sets how long resources stay creating/deleting; zero is instant.

func (*InMemoryBackend) SetNetworkResolver

func (b *InMemoryBackend) SetNetworkResolver(r NetworkResolver)

SetNetworkResolver wires EC2 network interface management; nil mints interface IDs locally.

func (*InMemoryBackend) SetRoleResolver

func (b *InMemoryBackend) SetRoleResolver(r RoleResolver)

SetRoleResolver wires IAM role validation; nil leaves role ARNs shape-checked only.

func (*InMemoryBackend) SetSubnetResolver

func (b *InMemoryBackend) SetSubnetResolver(r SubnetResolver)

SetSubnetResolver wires EC2 subnet validation; nil leaves subnets unvalidated.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(ctx context.Context, ref string, add map[string]string) error

TagResource adds or overwrites tags on a file system or access point.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(ctx context.Context, ref string, keys []string) error

UntagResource removes tags by key; absent keys are ignored.

func (*InMemoryBackend) UpdateMountTarget

func (b *InMemoryBackend) UpdateMountTarget(ctx context.Context, id string, sgs []string) (*MountTarget, error)

UpdateMountTarget replaces the mount target's security groups.

type KV

type KV struct{ Key, Value string }

KV is a tag key/value pair.

type KeyResolver

type KeyResolver interface {
	CheckKey(ctx context.Context, keyID string) error
}

KeyResolver checks that a KMS key exists and is usable.

type Lifecycle

type Lifecycle struct {
	CreatedAt         time.Time  `json:"createdAt"`
	DeleteRequestedAt *time.Time `json:"deleteRequestedAt,omitempty"`
	Status            string     `json:"status"`
	StatusMessage     string     `json:"statusMessage,omitempty"`
}

Lifecycle is the state shared by every S3 Files resource.

type MountTarget

type MountTarget struct {
	Lifecycle
	IPv6Address        string   `json:"ipv6Address,omitempty"`
	SubnetID           string   `json:"subnetId"`
	VPCID              string   `json:"vpcId,omitempty"`
	AvailabilityZoneID string   `json:"availabilityZoneId,omitempty"`
	IPv4Address        string   `json:"ipv4Address,omitempty"`
	ID                 string   `json:"id"`
	IPAddressType      string   `json:"ipAddressType"`
	NetworkInterfaceID string   `json:"networkInterfaceId"`
	OwnerID            string   `json:"ownerId"`
	Region             string   `json:"region"`
	FileSystemID       string   `json:"fileSystemId"`
	SecurityGroups     []string `json:"securityGroups,omitempty"`
}

MountTarget is a network endpoint for mounting a file system.

type NetworkResolver

type NetworkResolver interface {
	// CreateENI creates an interface; empty SecurityGroups selects the subnet VPC's default group.
	CreateENI(req ENIRequest) (ENI, error)
	// SetENISecurityGroups replaces the interface's security groups.
	SetENISecurityGroups(eniID string, sgs []string) error
	DeleteENI(eniID string)
}

NetworkResolver provisions mount-target network interfaces in EC2. Errors must wrap ErrNotFound, ErrConflict or ErrValidation so they reach the wire with the right code.

type PosixUser

type PosixUser struct {
	UID           *int64  `json:"uid"`
	GID           *int64  `json:"gid"`
	SecondaryGIDs []int64 `json:"secondaryGids,omitempty"`
}

PosixUser is the POSIX identity enforced through an access point.

type Provider

type Provider struct{}

Provider implements service.Provider for Amazon S3 Files.

func (*Provider) Init

Init creates the backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type PutSyncInput

type PutSyncInput struct {
	LatestVersion *int32
	ImportRules   []ImportDataRule
	ExpireRules   []ExpirationDataRule
}

PutSyncInput is the backend form of PutSynchronizationConfiguration.

type RoleResolver

type RoleResolver interface {
	RoleExists(roleARN string) bool
}

RoleResolver checks that an IAM role exists.

type RootDirectory

type RootDirectory struct {
	CreationPermissions *CreationPermissions `json:"creationPermissions,omitempty"`
	Path                *string              `json:"path,omitempty"`
}

RootDirectory is an access point's root directory.

type SubnetInfo

type SubnetInfo struct {
	VPCID              string
	AvailabilityZoneID string
	CIDR               string
}

SubnetInfo is the placement of an EC2 subnet.

type SubnetResolver

type SubnetResolver interface {
	Subnet(id string) (SubnetInfo, bool)
}

SubnetResolver looks up EC2 subnets.

type SyncConfiguration

type SyncConfiguration struct {
	ImportDataRules     []ImportDataRule     `json:"importDataRules"`
	ExpirationDataRules []ExpirationDataRule `json:"expirationDataRules"`
	Version             int32                `json:"version"`
}

SyncConfiguration is a file system's synchronization configuration.

Jump to

Keyboard shortcuts

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