Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package store is the API server's PostgreSQL-backed repo configuration store. It is a concrete integration adapter (analogous to internal/github): it owns the SQL connection, embedded migrations, and the sqlc-generated query layer. Only the server/api layer consumes it; nothing in core (engine/git) or actions may import it.

Index

Constants

This section is empty.

Variables

View Source
var ErrRepoNotFound = errors.New("repo not found")

ErrRepoNotFound is returned by GetRepo when no row matches the given ID.

Functions

This section is empty.

Types

type Repo

type Repo struct {
	ID          string
	DisplayName string
	Owner       string
	Name        string
	Path        string
	Remote      string
	// AddedBy is the GitHub login of the user who onboarded the repo at
	// runtime, or empty for operator-seeded repos (shared with everyone).
	AddedBy   string
	CreatedAt time.Time
	UpdatedAt time.Time
}

Repo is a persisted repo-configuration row. Fields mirror the server's repoConfig minus reposRoot, which is a server-level resolution input rather than a per-repo property: keeping it out of the row lets two hosts point the same table at different checkout roots. Path is the RAW stored value (may be empty, relative, or owner/name-derivable); the server resolves it after loading via normalizeRepoEntry.

type Store

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

Store holds the Postgres connection pool and the generated query layer.

func Open

func Open(ctx context.Context, connString string) (*Store, error)

Open connects to Postgres at connString, applies pending migrations, and returns a ready-to-use Store. The connection is closed if migrations fail.

func (*Store) AddRepo

func (s *Store) AddRepo(ctx context.Context, r Repo) (Repo, error)

AddRepo inserts r and returns the stored row with its server-assigned timestamps. The caller is responsible for validating r.ID (see repoIDPattern in apps/server) before calling.

func (*Store) Close

func (s *Store) Close() error

Close releases the underlying connection pool.

func (*Store) DB

func (s *Store) DB() *sql.DB

DB exposes the underlying pool so other server-scoped stores (e.g. a future session store) can share the same connection.

func (*Store) DeleteRepo

func (s *Store) DeleteRepo(ctx context.Context, id string) error

DeleteRepo removes the repo with the given ID. Deleting a missing row is a no-op (no error), matching DELETE semantics.

func (*Store) GetRepo

func (s *Store) GetRepo(ctx context.Context, id string) (Repo, error)

GetRepo returns the repo with the given ID, or ErrRepoNotFound.

func (*Store) ListRepos

func (s *Store) ListRepos(ctx context.Context) ([]Repo, error)

ListRepos returns all stored repos ordered by ID.

Directories

Path Synopsis
Package testpostgres provisions a Postgres backend for store tests.
Package testpostgres provisions a Postgres backend for store tests.

Jump to

Keyboard shortcuts

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