db

package
v0.17.6 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package db provides database access and management for the k8Shell Provisioner service. It provides persistence for org-scoped blueprint definitions, layered on top of the file-based blueprints loaded by internal/blueprint.

Index

Constants

This section is empty.

Variables

View Source
var ErrBlueprintConflict = errors.New("org blueprint was modified concurrently")

ErrBlueprintConflict is returned by UpdateBlueprint when the stored blueprint no longer matches the content the caller based its update on.

View Source
var ErrBlueprintExists = errors.New("org blueprint already exists")

ErrBlueprintExists is returned by CreateBlueprint when a blueprint with the same (org, name) already exists.

View Source
var ErrBlueprintNotFound = errors.New("org blueprint not found")

ErrBlueprintNotFound is returned by GetBlueprint/UpdateBlueprint/ DeleteBlueprint when no blueprint with the given (org, name) exists.

View Source
var ErrOrgNotFound = errors.New("organization not found")

ErrOrgNotFound is returned by CreateBlueprint when org does not exist in identity.organizations (see the FK on org_blueprints.org).

Functions

This section is empty.

Types

type DB

type DB struct {
	db.DB
	// contains filtered or unexported fields
}

DB wraps the shared database implementation for the provisioner service.

func NewDB

func NewDB(config db.DBConfig) (*DB, error)

NewDB creates a new DB for the provisioner service.

func (*DB) CreateBlueprint

func (d *DB) CreateBlueprint(org, name, description string, yaml []byte, isTemplate bool) (*models.OrgBlueprint, error)

CreateBlueprint registers a new org-scoped blueprint.

func (*DB) DeleteBlueprint

func (d *DB) DeleteBlueprint(org, name string) error

DeleteBlueprint removes an org blueprint from the registry. Returns ErrBlueprintNotFound when no blueprint with that (org, name) exists.

func (*DB) GetBlueprint

func (d *DB) GetBlueprint(org, name string) (*models.OrgBlueprint, error)

GetBlueprint retrieves a single org blueprint by org and name. Returns ErrBlueprintNotFound when no blueprint with that (org, name) exists.

func (*DB) ListAllBlueprints

func (d *DB) ListAllBlueprints() ([]*models.OrgBlueprint, error)

ListAllBlueprints returns every org blueprint across every org, ordered by org then name. Used by the blueprint manager to build its merged, file-plus-database view on load and on every reload.

func (*DB) ListBlueprints

func (d *DB) ListBlueprints(org string) ([]*models.OrgBlueprint, error)

ListBlueprints returns every blueprint stored for a single org, ordered by name.

func (*DB) LookupBlueprint

func (d *DB) LookupBlueprint(org, name string) (*models.OrgBlueprint, error)

LookupBlueprint behaves like GetBlueprint but returns (nil, nil) instead of ErrBlueprintNotFound when no row with that (org, name) exists, for callers that treat "absent" as a normal outcome rather than an error.

func (*DB) UpdateBlueprint

func (d *DB) UpdateBlueprint(org, name string, description *string, yaml []byte, isTemplate bool,
	expectedYAML []byte) (*models.OrgBlueprint, error)

UpdateBlueprint replaces an existing org blueprint's yaml content, its is_template flag, and optionally its description. name and org together identify the blueprint and are immutable; pass a nil description to leave it unchanged. A non-nil expectedYAML makes the update a compare-and-swap: it is applied only if the stored yaml still equals expectedYAML, and ErrBlueprintConflict is returned otherwise. Returns ErrBlueprintNotFound when no blueprint with that (org, name) exists.

Jump to

Keyboard shortcuts

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