storage

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package storage provides storage management for den sandboxes, including tmpfs mounts, Docker named volumes, and S3 synchronization.

Index

Constants

View Source
const (
	// MaxTmpfsSizeBytes is the maximum allowed tmpfs size (4GB).
	MaxTmpfsSizeBytes = 4 * 1024 * 1024 * 1024
)
View Source
const (
	// VolumePrefix is prepended to all volume names for namespace isolation.
	VolumePrefix = "den-"
)

Variables

This section is empty.

Functions

func BuildTmpfsMap

func BuildTmpfsMap(storage *runtime.StorageConfig, defaults []config.TmpfsDefault) (map[string]string, error)

BuildTmpfsMap merges per-sandbox tmpfs overrides with server defaults and returns a map suitable for Docker's HostConfig.Tmpfs field.

func FUSEContainerRequirements

func FUSEContainerRequirements() (capAdd []string, devices []string)

FUSEContainerRequirements returns the additional capabilities and devices needed for FUSE mount support.

func NamespacedVolumeName

func NamespacedVolumeName(name string) string

NamespacedVolumeName returns the Docker volume name with den- prefix.

func ParseSize

func ParseSize(s string) (int64, error)

ParseSize parses a size string like "256m", "1g", "512k" into bytes.

func SetupFUSEInContainer

func SetupFUSEInContainer(ctx context.Context, rt runtime.Runtime, sandboxID string, fuseCfg *FUSEConfig, logger *slog.Logger) error

SetupFUSEInContainer executes s3fs/goofys mount inside a running container. This requires SYS_ADMIN capability and /dev/fuse device access on the container.

func ValidateTmpfsOptions

func ValidateTmpfsOptions(opts string) error

ValidateTmpfsOptions checks that all tmpfs options are in the allowed set.

func ValidateVolumeMountPath

func ValidateVolumeMountPath(path string) error

ValidateVolumeMountPath checks that a mount path is safe.

func ValidateVolumeName

func ValidateVolumeName(name string) error

ValidateVolumeName checks that a volume name is safe for Docker.

Types

type FUSEConfig

type FUSEConfig struct {
	Endpoint  string
	Bucket    string
	Region    string
	AccessKey string
	SecretKey string
	MountPath string
}

FUSEConfig holds configuration for setting up an S3 FUSE mount inside a container.

func PrepareFUSEMount

func PrepareFUSEMount(s3Cfg *runtime.S3SyncConfig) (*FUSEConfig, error)

PrepareFUSEMount returns the container modifications needed for FUSE mount support. The caller is responsible for applying these to the container config.

type S3Client

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

S3Client wraps the AWS S3 client with den-specific operations.

func NewS3Client

func NewS3Client(ctx context.Context, creds *S3Credentials, logger *slog.Logger) (*S3Client, error)

NewS3Client creates a new S3Client from resolved credentials.

func (*S3Client) Download

func (c *S3Client) Download(ctx context.Context, bucket, key string) (io.ReadCloser, int64, error)

Download downloads an object from S3 and returns its body.

func (*S3Client) ListObjects

func (c *S3Client) ListObjects(ctx context.Context, bucket, prefix string, maxKeys int) ([]string, error)

ListObjects lists objects in a bucket with the given prefix. If maxKeys > 0, at most maxKeys objects are returned.

func (*S3Client) Upload

func (c *S3Client) Upload(ctx context.Context, bucket, key string, body io.Reader, size int64) error

Upload uploads data to S3.

type S3Credentials

type S3Credentials struct {
	Endpoint  string
	Bucket    string
	Prefix    string
	Region    string
	AccessKey string
	SecretKey string
}

S3Credentials holds the resolved credentials for an S3 operation.

func ResolveS3Credentials

func ResolveS3Credentials(sandbox *runtime.S3SyncConfig, server serverconfig.S3Config) (*S3Credentials, error)

ResolveS3Credentials resolves credentials from per-sandbox config falling back to server-wide defaults.

Jump to

Keyboard shortcuts

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