Documentation
¶
Index ¶
- Constants
- Variables
- func BlobID(content []byte) string
- func DecryptBlob(key CryptoKey, envelope EncryptedEnvelope, aad []byte) ([]byte, error)
- func EncryptionSecretRef(config Config) string
- func IsNotConfigured(err error) bool
- func IsSupportedScheme(scheme string) bool
- func Logout(root string) error
- func PathHash(path string) string
- func RedactedData(state State) map[string]any
- func Register(scheme string, factory StoreFactory)
- type BlobStore
- type CachedBlobStore
- func (c *CachedBlobStore) Delete(ctx context.Context, key string) error
- func (c *CachedBlobStore) Get(ctx context.Context, key string) ([]byte, string, error)
- func (c *CachedBlobStore) Put(ctx context.Context, key string, data []byte, baseRev string) (string, error)
- func (c *CachedBlobStore) Stat(ctx context.Context, key string) (string, error)
- type ConditionalWriteCapability
- type Config
- type CryptoKey
- type DeviceSession
- type DoctorResult
- type EncryptedEnvelope
- type ExtendedBlobStore
- type FakeBlobCheckRequest
- type FakeBlobCheckResponse
- type FakeContractError
- type FakeContractErrorResponse
- type FakeErrorResponse
- type FakeManifestPutRequest
- type FakeManifestResponse
- type FakeRevisionCommitRequest
- type FakeRevisionCommitResponse
- type FakeRevisionResponse
- type FakeServer
- type FileBackend
- func (b *FileBackend) BatchStat(ctx context.Context, keys []string) (map[string]string, error)
- func (b *FileBackend) Delete(ctx context.Context, key string) error
- func (b *FileBackend) Exists(ctx context.Context, key string) (bool, error)
- func (b *FileBackend) Get(ctx context.Context, key string) ([]byte, string, error)
- func (b *FileBackend) List(ctx context.Context, prefix string) ([]ObjectInfo, error)
- func (b *FileBackend) Put(ctx context.Context, key string, data []byte, baseRev string) (string, error)
- func (b *FileBackend) Stat(ctx context.Context, key string) (string, error)
- func (b *FileBackend) SupportsConditionalWrites() bool
- type LoginRequest
- type Manifest
- type ManifestDelete
- type ManifestEntry
- type ManifestFileTooLargeError
- type ManifestUnsafePathError
- type ObjectInfo
- type RcloneBackend
- func (b *RcloneBackend) BatchStat(ctx context.Context, keys []string) (map[string]string, error)
- func (b *RcloneBackend) Delete(ctx context.Context, key string) error
- func (b *RcloneBackend) Exists(ctx context.Context, key string) (bool, error)
- func (b *RcloneBackend) Get(ctx context.Context, key string) ([]byte, string, error)
- func (b *RcloneBackend) List(ctx context.Context, prefix string) ([]ObjectInfo, error)
- func (b *RcloneBackend) Put(ctx context.Context, key string, data []byte, _ string) (string, error)
- func (b *RcloneBackend) Stat(ctx context.Context, key string) (string, error)
- func (b *RcloneBackend) SupportsConditionalWrites() bool
- type S3Backend
- func (s *S3Backend) BatchStat(ctx context.Context, keys []string) (map[string]string, error)
- func (s *S3Backend) Delete(ctx context.Context, key string) error
- func (s *S3Backend) Exists(ctx context.Context, key string) (bool, error)
- func (s *S3Backend) Get(ctx context.Context, key string) ([]byte, string, error)
- func (s *S3Backend) List(ctx context.Context, prefix string) ([]ObjectInfo, error)
- func (s *S3Backend) Put(ctx context.Context, key string, data []byte, baseRev string) (string, error)
- func (s *S3Backend) Stat(ctx context.Context, key string) (string, error)
- func (s *S3Backend) SupportsConditionalWrites() bool
- type S3BackendOptions
- type S3Config
- type State
- type StoreFactory
Constants ¶
View Source
const ( ConfigSchemaVersion = "pinax.cloud.config.v1" SessionSchemaVersion = "pinax.cloud.session.v1" )
View Source
const CreateIfAbsentRevision = "__pinax_create_if_absent__"
View Source
const CryptoEnvelopeSchemaVersion = "pinax.cloud.envelope.v1"
View Source
const ManifestSchemaVersion = "pinax.cloud.manifest.v1"
View Source
const MaxManifestFileBytes = 100 * 1024 * 1024
Variables ¶
View Source
var ( ErrObjectNotFound = errors.New("object not found") ErrConflict = errors.New("revision conflict") )
View Source
var ErrNotConfigured = errors.New("cloud not configured")
Functions ¶
func DecryptBlob ¶
func DecryptBlob(key CryptoKey, envelope EncryptedEnvelope, aad []byte) ([]byte, error)
func EncryptionSecretRef ¶
func IsNotConfigured ¶
func IsSupportedScheme ¶
IsSupportedScheme returns true if the scheme has a registered factory.
func RedactedData ¶
func Register ¶
func Register(scheme string, factory StoreFactory)
Register registers a new BlobStore factory for a URI scheme.
Types ¶
type BlobStore ¶
type BlobStore interface {
// Get retrieves the object. If not found, returns ErrObjectNotFound.
Get(ctx context.Context, key string) (data []byte, rev string, err error)
// Put uploads the object. baseRev is the expected current revision.
// If baseRev is CreateIfAbsentRevision, the object must not exist.
// If baseRev is not empty and doesn't match, returns ErrConflict.
// Returns the new revision string.
Put(ctx context.Context, key string, data []byte, baseRev string) (newRev string, err error)
// Stat retrieves the revision of the object. If not found, returns ErrObjectNotFound.
Stat(ctx context.Context, key string) (rev string, err error)
// Delete removes the object.
Delete(ctx context.Context, key string) error
}
BlobStore abstracts the underlying blind storage system (S3, File, etc.).
type CachedBlobStore ¶
type CachedBlobStore struct {
// contains filtered or unexported fields
}
CachedBlobStore decorates a BlobStore with local file caching for Get operations.
func NewCachedBlobStore ¶
func NewCachedBlobStore(inner BlobStore, cacheDir string, maxSize int64) *CachedBlobStore
NewCachedBlobStore creates a new caching decorator.
func (*CachedBlobStore) Delete ¶
func (c *CachedBlobStore) Delete(ctx context.Context, key string) error
Delete delegates to inner store and invalidates cache.
type ConditionalWriteCapability ¶
type ConditionalWriteCapability interface {
SupportsConditionalWrites() bool
}
ConditionalWriteCapability reports whether Put enforces baseRev preconditions durably.
type Config ¶
type Config struct {
SchemaVersion string `json:"schema_version" yaml:"schema_version"`
BackendKind string `json:"backend_kind,omitempty" yaml:"backend_kind,omitempty"`
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
WorkspaceID string `json:"workspace_id" yaml:"workspace_id"`
DeviceID string `json:"device_id" yaml:"device_id"`
SecretRef string `json:"secret_ref,omitempty" yaml:"secret_ref,omitempty"`
EncryptionSecretRef string `json:"encryption_secret_ref,omitempty" yaml:"encryption_secret_ref,omitempty"`
S3 *S3Config `json:"s3,omitempty" yaml:"s3,omitempty"`
CreatedAt string `json:"created_at" yaml:"created_at"`
UpdatedAt string `json:"updated_at" yaml:"updated_at"`
}
type DeviceSession ¶
type DoctorResult ¶
type DoctorResult struct {
Configured bool `json:"configured"`
Status string `json:"status"`
Code string `json:"code,omitempty"`
Message string `json:"message"`
BackendKind string `json:"backend_kind,omitempty"`
AuthBoundary string `json:"auth_boundary,omitempty"`
ServerAudit bool `json:"server_audit"`
Endpoint string `json:"endpoint,omitempty"`
Workspace string `json:"workspace_id,omitempty"`
DeviceID string `json:"device_id,omitempty"`
}
func Doctor ¶
func Doctor(root string) DoctorResult
type EncryptedEnvelope ¶
type EncryptedEnvelope struct {
SchemaVersion string `json:"schema_version"`
Alg string `json:"alg"`
KeyID string `json:"key_id"`
Nonce string `json:"nonce"`
Ciphertext string `json:"ciphertext"`
PlainSHA256 string `json:"plain_sha256"`
}
func EncryptBlob ¶
func EncryptBlob(key CryptoKey, plaintext, aad []byte) (EncryptedEnvelope, error)
func EncryptManifest ¶
func EncryptManifest(key CryptoKey, manifest Manifest) (EncryptedEnvelope, error)
type ExtendedBlobStore ¶
type ExtendedBlobStore interface {
BlobStore
List(ctx context.Context, prefix string) ([]ObjectInfo, error)
Exists(ctx context.Context, key string) (bool, error)
BatchStat(ctx context.Context, keys []string) (map[string]string, error)
}
ExtendedBlobStore extends BlobStore with list and batch operations.
type FakeBlobCheckRequest ¶
type FakeBlobCheckRequest struct {
BlobIDs []string `json:"blob_ids"`
}
type FakeBlobCheckResponse ¶
type FakeBlobCheckResponse struct {
MissingBlobIDs []string `json:"missing_blob_ids"`
}
type FakeContractError ¶
type FakeContractErrorResponse ¶
type FakeContractErrorResponse struct {
Error FakeContractError `json:"error"`
}
type FakeErrorResponse ¶
type FakeManifestPutRequest ¶
type FakeManifestResponse ¶
type FakeRevisionResponse ¶
type FakeServer ¶
type FakeServer struct {
URL string
// contains filtered or unexported fields
}
func NewFakeServer ¶
func NewFakeServer() *FakeServer
func (*FakeServer) Close ¶
func (s *FakeServer) Close()
type FileBackend ¶
type FileBackend struct {
// contains filtered or unexported fields
}
func NewFileBackend ¶
func NewFileBackend(baseDir string) (*FileBackend, error)
func (*FileBackend) List ¶
func (b *FileBackend) List(ctx context.Context, prefix string) ([]ObjectInfo, error)
List returns objects under the given prefix.
func (*FileBackend) SupportsConditionalWrites ¶
func (b *FileBackend) SupportsConditionalWrites() bool
type LoginRequest ¶
type Manifest ¶
type Manifest struct {
SchemaVersion string `json:"schema_version"`
GeneratedAt string `json:"generated_at"`
EntryCount int `json:"entry_count"`
Entries []ManifestEntry `json:"entries"`
Deletes []ManifestDelete `json:"deletes,omitempty"`
}
func BuildManifest ¶
func DecryptManifest ¶
func DecryptManifest(key CryptoKey, envelope EncryptedEnvelope) (Manifest, error)
type ManifestDelete ¶ added in v0.1.3
type ManifestEntry ¶
type ManifestEntry struct {
Path string `json:"path"`
PathHash string `json:"path_hash"`
BlobID string `json:"blob_id"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
ObjectKind string `json:"object_kind,omitempty"`
Mode uint32 `json:"mode,omitempty"`
MediaType string `json:"media_type,omitempty"`
}
type ManifestFileTooLargeError ¶ added in v0.1.3
func (*ManifestFileTooLargeError) Error ¶ added in v0.1.3
func (e *ManifestFileTooLargeError) Error() string
type ManifestUnsafePathError ¶ added in v0.1.3
type ManifestUnsafePathError struct{ Path string }
func (*ManifestUnsafePathError) Error ¶ added in v0.1.3
func (e *ManifestUnsafePathError) Error() string
type ObjectInfo ¶
ObjectInfo describes a remote object.
type RcloneBackend ¶
type RcloneBackend struct {
// contains filtered or unexported fields
}
func NewRcloneBackend ¶
func NewRcloneBackend(endpoint string) (*RcloneBackend, error)
func (*RcloneBackend) Delete ¶
func (b *RcloneBackend) Delete(ctx context.Context, key string) error
func (*RcloneBackend) List ¶
func (b *RcloneBackend) List(ctx context.Context, prefix string) ([]ObjectInfo, error)
func (*RcloneBackend) SupportsConditionalWrites ¶
func (b *RcloneBackend) SupportsConditionalWrites() bool
type S3Backend ¶
type S3Backend struct {
// contains filtered or unexported fields
}
func NewS3Backend ¶
func NewS3BackendWithOptions ¶
func (*S3Backend) SupportsConditionalWrites ¶
type S3BackendOptions ¶
type S3Config ¶
type S3Config struct {
Bucket string `json:"bucket" yaml:"bucket"`
Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"`
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
Region string `json:"region,omitempty" yaml:"region,omitempty"`
Profile string `json:"profile,omitempty" yaml:"profile,omitempty"`
PathStyle bool `json:"path_style,omitempty" yaml:"path_style,omitempty"`
}
type State ¶
type State struct {
Config Config `json:"config"`
Session DeviceSession `json:"session"`
}
Click to show internal directories.
Click to hide internal directories.