storage

package
v0.0.0-...-02fb3ca Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 43 Imported by: 6

Documentation

Index

Constants

View Source
const (
	GuestEnvdPath = "/usr/bin/envd"

	MemfileName  = "memfile"
	RootfsName   = "rootfs.ext4"
	SnapfileName = "snapfile"
	MetadataName = "metadata.json"

	HeaderSuffix = ".header"
)

Variables

View Source
var (
	ErrOffsetUnaligned = errors.New("offset must be a multiple of chunk size")
	ErrBufferTooSmall  = errors.New("buffer is too small")
	ErrMultipleChunks  = errors.New("cannot read multiple chunks")
	ErrBufferTooLarge  = errors.New("buffer is too large")
)
View Source
var ErrObjectNotExist = errors.New("object does not exist")

Functions

func HostEnvdPath

func HostEnvdPath() string

Types

type AWSBucketStorageObjectProvider

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

func (*AWSBucketStorageObjectProvider) Delete

func (*AWSBucketStorageObjectProvider) ReadAt

func (a *AWSBucketStorageObjectProvider) ReadAt(ctx context.Context, buff []byte, off int64) (n int, err error)

func (*AWSBucketStorageObjectProvider) Size

func (*AWSBucketStorageObjectProvider) Write

func (a *AWSBucketStorageObjectProvider) Write(ctx context.Context, data []byte) (int, error)

func (*AWSBucketStorageObjectProvider) WriteFromFileSystem

func (a *AWSBucketStorageObjectProvider) WriteFromFileSystem(ctx context.Context, path string) error

func (*AWSBucketStorageObjectProvider) WriteTo

type AWSBucketStorageProvider

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

func NewAWSBucketStorageProvider

func NewAWSBucketStorageProvider(ctx context.Context, bucketName string) (*AWSBucketStorageProvider, error)

func (*AWSBucketStorageProvider) DeleteObjectsWithPrefix

func (a *AWSBucketStorageProvider) DeleteObjectsWithPrefix(ctx context.Context, prefix string) error

func (*AWSBucketStorageProvider) GetDetails

func (a *AWSBucketStorageProvider) GetDetails() string

func (*AWSBucketStorageProvider) OpenObject

func (*AWSBucketStorageProvider) UploadSignedURL

func (a *AWSBucketStorageProvider) UploadSignedURL(ctx context.Context, path string, ttl time.Duration) (string, error)

type CachedFileObjectProvider

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

func (*CachedFileObjectProvider) Delete

func (*CachedFileObjectProvider) ReadAt

func (c *CachedFileObjectProvider) ReadAt(ctx context.Context, buff []byte, offset int64) (int, error)

func (*CachedFileObjectProvider) Size

func (*CachedFileObjectProvider) Write

func (c *CachedFileObjectProvider) Write(ctx context.Context, src []byte) (int, error)

func (*CachedFileObjectProvider) WriteFromFileSystem

func (c *CachedFileObjectProvider) WriteFromFileSystem(ctx context.Context, path string) error

func (*CachedFileObjectProvider) WriteTo

func (c *CachedFileObjectProvider) WriteTo(ctx context.Context, dst io.Writer) (int64, error)

WriteTo is used for very small files and we can check against their size to ensure the content is valid.

type CachedProvider

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

func NewCachedProvider

func NewCachedProvider(rootPath string, inner StorageProvider) *CachedProvider

func (CachedProvider) DeleteObjectsWithPrefix

func (c CachedProvider) DeleteObjectsWithPrefix(ctx context.Context, prefix string) error

func (CachedProvider) GetDetails

func (c CachedProvider) GetDetails() string

func (CachedProvider) OpenObject

func (c CachedProvider) OpenObject(ctx context.Context, path string) (StorageObjectProvider, error)

func (CachedProvider) UploadSignedURL

func (c CachedProvider) UploadSignedURL(ctx context.Context, path string, ttl time.Duration) (string, error)

type CompleteMultipartUpload

type CompleteMultipartUpload struct {
	XMLName string `xml:"CompleteMultipartUpload"`
	Parts   []Part `xml:"Part"`
}

type FileSystemStorageObjectProvider

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

func (*FileSystemStorageObjectProvider) Delete

func (*FileSystemStorageObjectProvider) ReadAt

func (f *FileSystemStorageObjectProvider) ReadAt(ctx context.Context, buff []byte, off int64) (n int, err error)

func (*FileSystemStorageObjectProvider) Size

func (*FileSystemStorageObjectProvider) Write

func (f *FileSystemStorageObjectProvider) Write(ctx context.Context, data []byte) (int, error)

func (*FileSystemStorageObjectProvider) WriteFromFileSystem

func (f *FileSystemStorageObjectProvider) WriteFromFileSystem(ctx context.Context, path string) error

func (*FileSystemStorageObjectProvider) WriteTo

type FileSystemStorageProvider

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

func NewFileSystemStorageProvider

func NewFileSystemStorageProvider(basePath string) (*FileSystemStorageProvider, error)

func (*FileSystemStorageProvider) DeleteObjectsWithPrefix

func (fs *FileSystemStorageProvider) DeleteObjectsWithPrefix(_ context.Context, prefix string) error

func (*FileSystemStorageProvider) GetDetails

func (fs *FileSystemStorageProvider) GetDetails() string

func (*FileSystemStorageProvider) OpenObject

func (*FileSystemStorageProvider) UploadSignedURL

func (fs *FileSystemStorageProvider) UploadSignedURL(_ context.Context, _ string, _ time.Duration) (string, error)

type GCPBucketStorageObjectProvider

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

func (*GCPBucketStorageObjectProvider) Delete

func (*GCPBucketStorageObjectProvider) ReadAt

func (g *GCPBucketStorageObjectProvider) ReadAt(ctx context.Context, buff []byte, off int64) (n int, err error)

func (*GCPBucketStorageObjectProvider) Size

func (*GCPBucketStorageObjectProvider) Write

func (g *GCPBucketStorageObjectProvider) Write(ctx context.Context, data []byte) (int, error)

func (*GCPBucketStorageObjectProvider) WriteFromFileSystem

func (g *GCPBucketStorageObjectProvider) WriteFromFileSystem(ctx context.Context, path string) error

func (*GCPBucketStorageObjectProvider) WriteTo

type GCPBucketStorageProvider

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

func NewGCPBucketStorageProvider

func NewGCPBucketStorageProvider(ctx context.Context, bucketName string, limiter *limit.Limiter) (*GCPBucketStorageProvider, error)

func (*GCPBucketStorageProvider) DeleteObjectsWithPrefix

func (g *GCPBucketStorageProvider) DeleteObjectsWithPrefix(ctx context.Context, prefix string) error

func (*GCPBucketStorageProvider) GetDetails

func (g *GCPBucketStorageProvider) GetDetails() string

func (*GCPBucketStorageProvider) OpenObject

func (*GCPBucketStorageProvider) UploadSignedURL

func (g *GCPBucketStorageProvider) UploadSignedURL(_ context.Context, path string, ttl time.Duration) (string, error)

type InitiateMultipartUploadResult

type InitiateMultipartUploadResult struct {
	Bucket   string `xml:"Bucket"`
	Key      string `xml:"Key"`
	UploadID string `xml:"UploadId"`
}

type MultipartUploader

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

func NewMultipartUploaderWithRetryConfig

func NewMultipartUploaderWithRetryConfig(ctx context.Context, bucketName, objectName string, retryConfig RetryConfig) (*MultipartUploader, error)

func (*MultipartUploader) CompleteUpload

func (m *MultipartUploader) CompleteUpload(uploadID string, parts []Part) error

func (*MultipartUploader) InitiateUpload

func (m *MultipartUploader) InitiateUpload() (string, error)

func (*MultipartUploader) UploadFileInParallel

func (m *MultipartUploader) UploadFileInParallel(ctx context.Context, filePath string, maxConcurrency int) error

func (*MultipartUploader) UploadPart

func (m *MultipartUploader) UploadPart(uploadID string, partNumber int, data []byte) (string, error)

type Part

type Part struct {
	PartNumber int    `xml:"PartNumber"`
	ETag       string `xml:"ETag"`
}

type Provider

type Provider string
const (
	GCPStorageProvider   Provider = "GCPBucket"
	AWSStorageProvider   Provider = "AWSBucket"
	LocalStorageProvider Provider = "Local"

	DefaultStorageProvider Provider = GCPStorageProvider

	// MemoryChunkSize must always be bigger or equal to the block size.
	MemoryChunkSize = 4 * 1024 * 1024 // 4 MB
)

type ReaderAtCtx

type ReaderAtCtx interface {
	ReadAt(ctx context.Context, p []byte, off int64) (n int, err error)
}

type RetryConfig

type RetryConfig struct {
	MaxAttempts       int
	InitialBackoff    time.Duration
	MaxBackoff        time.Duration
	BackoffMultiplier float64
}

RetryConfig holds the configuration for retry logic

func DefaultRetryConfig

func DefaultRetryConfig() RetryConfig

DefaultRetryConfig returns the default retry configuration matching storage_google.go

type SandboxFiles

type SandboxFiles struct {
	TemplateCacheFiles

	SandboxID string
	// contains filtered or unexported fields
}

func (*SandboxFiles) SandboxCacheRootfsLinkPath

func (s *SandboxFiles) SandboxCacheRootfsLinkPath() string

func (*SandboxFiles) SandboxCacheRootfsPath

func (s *SandboxFiles) SandboxCacheRootfsPath() string

func (*SandboxFiles) SandboxFirecrackerSocketPath

func (s *SandboxFiles) SandboxFirecrackerSocketPath() string

func (*SandboxFiles) SandboxUffdSocketPath

func (s *SandboxFiles) SandboxUffdSocketPath() string

type StorageObjectProvider

type StorageObjectProvider interface {
	WriterCtx
	WriterToCtx
	ReaderAtCtx

	WriteFromFileSystem(ctx context.Context, path string) error

	Size(ctx context.Context) (int64, error)
	Delete(ctx context.Context) error
}

type StorageProvider

type StorageProvider interface {
	DeleteObjectsWithPrefix(ctx context.Context, prefix string) error
	UploadSignedURL(ctx context.Context, path string, ttl time.Duration) (string, error)
	OpenObject(ctx context.Context, path string) (StorageObjectProvider, error)
	GetDetails() string
}

func GetBuildCacheStorageProvider

func GetBuildCacheStorageProvider(ctx context.Context, limiter *limit.Limiter) (StorageProvider, error)

func GetTemplateStorageProvider

func GetTemplateStorageProvider(ctx context.Context, limiter *limit.Limiter) (StorageProvider, error)

type TemplateCacheFiles

type TemplateCacheFiles struct {
	TemplateFiles

	// CacheIdentifier is used to distinguish between each entry in the cache to prevent deleting the cache files when the template cache entry is being closed and a new one is being created.
	CacheIdentifier string
}

func (TemplateCacheFiles) CacheMetadataPath

func (c TemplateCacheFiles) CacheMetadataPath() string

func (TemplateCacheFiles) CacheSnapfilePath

func (c TemplateCacheFiles) CacheSnapfilePath() string

func (TemplateCacheFiles) NewSandboxFiles

func (c TemplateCacheFiles) NewSandboxFiles(sandboxID string) *SandboxFiles

func (TemplateCacheFiles) NewSandboxFilesWithStaticID

func (c TemplateCacheFiles) NewSandboxFilesWithStaticID(sandboxID string, staticID string) *SandboxFiles

type TemplateFiles

type TemplateFiles struct {
	BuildID            string `json:"build_id"`
	KernelVersion      string `json:"kernel_version"`
	FirecrackerVersion string `json:"firecracker_version"`
}

func (TemplateFiles) CacheFiles

func (t TemplateFiles) CacheFiles() (TemplateCacheFiles, error)

func (TemplateFiles) CacheKey

func (t TemplateFiles) CacheKey() string

Key for the cache. Unique for template-build pair.

func (TemplateFiles) StorageDir

func (t TemplateFiles) StorageDir() string

func (TemplateFiles) StorageMemfileHeaderPath

func (t TemplateFiles) StorageMemfileHeaderPath() string

func (TemplateFiles) StorageMemfilePath

func (t TemplateFiles) StorageMemfilePath() string

func (TemplateFiles) StorageMetadataPath

func (t TemplateFiles) StorageMetadataPath() string

func (TemplateFiles) StorageRootfsHeaderPath

func (t TemplateFiles) StorageRootfsHeaderPath() string

func (TemplateFiles) StorageRootfsPath

func (t TemplateFiles) StorageRootfsPath() string

func (TemplateFiles) StorageSnapfilePath

func (t TemplateFiles) StorageSnapfilePath() string

type TemporaryMemfile

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

func AcquireTmpMemfile

func AcquireTmpMemfile(
	ctx context.Context,
	buildID string,
) (*TemporaryMemfile, error)

func (*TemporaryMemfile) Close

func (f *TemporaryMemfile) Close() error

func (*TemporaryMemfile) Path

func (f *TemporaryMemfile) Path() string

type WriterCtx

type WriterCtx interface {
	Write(ctx context.Context, p []byte) (n int, err error)
}

type WriterToCtx

type WriterToCtx interface {
	WriteTo(ctx context.Context, w io.Writer) (n int64, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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