project

package
v0.3.0-rc6 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package project owns project-file storage. V0.1 ships one backend (local filesystem rooted at a configured path) ; V0.2 adds a weft-block backend so per-project volumes mount into compile microVMs without round-tripping through the host filesystem.

The Store interface centralises authorization : every method takes the caller's Identity, and the implementation enforces "can this user see/edit this project". V0.1 policy : project owner subject == identity.Subject OR identity.Groups contains "loom-admin". V0.2 migrates to openweft project ACL via dex groups.

Index

Constants

This section is empty.

Variables

View Source
var ErrAccessDenied = errors.New("project: access denied")

ErrAccessDenied is returned by Store impls when the caller lacks permission. Handlers translate to 403.

Functions

This section is empty.

Types

type File

type File struct {
	Path string `json:"path"`
	Size int64  `json:"size"`
	Dir  bool   `json:"dir"`
}

File is one entry in ListFiles.

type LocalStore

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

LocalStore is the V0.1 backend : projects live under <root>/<owner>/<name>. Owner is identity.Subject ; the subject is sanitised to a safe filesystem name (alphanumeric + dash + underscore) so dex's "subject can be a URL" doesn't escape the root.

func NewLocalStore

func NewLocalStore(root string) *LocalStore

NewLocalStore returns a store rooted at the given absolute path. The directory is created on first write.

func (*LocalStore) DeleteFile added in v0.4.0

func (s *LocalStore) DeleteFile(_ context.Context, ident auth.Identity, project, path string) error

DeleteFile removes <user>/<project>/<path>. Idempotent on missing paths : returns nil even if the file is already gone, so a concurrent delete from another browser tab doesn't bubble up as an error to the UI. Traversal-safe via resolveFile.

func (*LocalStore) List

func (s *LocalStore) List(_ context.Context, ident auth.Identity) ([]Project, error)

func (*LocalStore) ListFiles

func (s *LocalStore) ListFiles(_ context.Context, ident auth.Identity, project string) ([]File, error)

func (*LocalStore) ReadFile

func (s *LocalStore) ReadFile(_ context.Context, ident auth.Identity, project, path string) (io.ReadCloser, error)

func (*LocalStore) WriteFile

func (s *LocalStore) WriteFile(_ context.Context, ident auth.Identity, project, path string, body io.Reader) error

type PostgresStore added in v0.2.2

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

PostgresStore is the HA-aware project store : metadata lives in PostgreSQL (weft-ha-postgresql handles the failover / replication) and file content lives on a shared weft-block volume mounted at `filesRoot` on every loom-server replica. The two paths are kept in sync transactionally — every WriteFile bumps the projects.updated_at row in the SAME transaction as the file landing on disk via rename-or-fsync, so a crash mid-write leaves the row pointing at the previous content (or the row is rolled back).

Schema migrations run on NewPostgresStore via embedded SQL — see schema.sql. The store IS idempotent across restarts.

func NewPostgresStore added in v0.2.2

func NewPostgresStore(ctx context.Context, dsn, filesRoot string) (*PostgresStore, error)

NewPostgresStore connects to dsn, runs migrations, and returns a ready store. filesRoot is the mount point of the shared volume (typically /var/lib/weft-loom on the microVM ; the volume itself is provisioned by weft-block as a replicated 3-DC volume).

func (*PostgresStore) Close added in v0.2.2

func (s *PostgresStore) Close()

Close drops the connection pool. Safe to call multiple times.

func (*PostgresStore) DeleteFile added in v0.4.0

func (s *PostgresStore) DeleteFile(ctx context.Context, ident auth.Identity, project, path string) error

DeleteFile removes the on-disk file. Idempotent on missing paths. Doesn't bump the project's updated_at row — the V0.2 schema keeps file-level state in the filesystem ; future per-file metadata (history, last_modified_by) will move that bookkeeping here.

func (*PostgresStore) List added in v0.2.2

func (s *PostgresStore) List(ctx context.Context, ident auth.Identity) ([]Project, error)

func (*PostgresStore) ListFiles added in v0.2.2

func (s *PostgresStore) ListFiles(ctx context.Context, ident auth.Identity, project string) ([]File, error)

func (*PostgresStore) ReadFile added in v0.2.2

func (s *PostgresStore) ReadFile(ctx context.Context, ident auth.Identity, project, path string) (io.ReadCloser, error)

func (*PostgresStore) WriteFile added in v0.2.2

func (s *PostgresStore) WriteFile(ctx context.Context, ident auth.Identity, project, path string, body io.Reader) error

type Project

type Project struct {
	Name      string    `json:"name"`
	Language  string    `json:"language"`
	CreatedAt time.Time `json:"created_at"`
}

Project is the summary returned by List.

type Store

type Store interface {
	List(ctx context.Context, ident auth.Identity) ([]Project, error)
	ListFiles(ctx context.Context, ident auth.Identity, project string) ([]File, error)
	ReadFile(ctx context.Context, ident auth.Identity, project, path string) (io.ReadCloser, error)
	WriteFile(ctx context.Context, ident auth.Identity, project, path string, body io.Reader) error
	DeleteFile(ctx context.Context, ident auth.Identity, project, path string) error
}

Store is the storage abstraction.

Jump to

Keyboard shortcuts

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