db

package
v0.0.0-...-4010536 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildNotFound

type BuildNotFound struct{ ErrNotFound }

func (BuildNotFound) Error

func (BuildNotFound) Error() string

type DB

type DB struct {
	Client *models.Client
}

func NewClient

func NewClient() (*DB, error)

func (*DB) CheckBaseEnvHasSnapshots

func (db *DB) CheckBaseEnvHasSnapshots(ctx context.Context, envID string) (result bool, err error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) DeleteEnv

func (db *DB) DeleteEnv(ctx context.Context, envID string) error

func (*DB) DeleteEnvAlias

func (db *DB) DeleteEnvAlias(ctx context.Context, alias string) error

func (*DB) EnvBuildSetStatus

func (db *DB) EnvBuildSetStatus(
	ctx context.Context,
	envID string,
	buildID uuid.UUID,
	status envbuild.Status,
) error

func (*DB) FinishEnvBuild

func (db *DB) FinishEnvBuild(
	ctx context.Context,
	envID string,
	buildID uuid.UUID,
	totalDiskSizeMB int64,
	envdVersion string,
) error

func (*DB) GetEnv

func (db *DB) GetEnv(ctx context.Context, aliasOrEnvID string) (result *Template, build *models.EnvBuild, err error)

func (*DB) GetEnvs

func (db *DB) GetEnvs(ctx context.Context, teamID uuid.UUID) (result []*Template, err error)

func (*DB) GetLastSnapshot

func (db *DB) GetLastSnapshot(ctx context.Context, sandboxID string, teamID uuid.UUID) (
	*models.Snapshot,
	*models.EnvBuild,
	error,
)

func (*DB) GetSnapshotBuilds

func (db *DB) GetSnapshotBuilds(ctx context.Context, sandboxID string, teamID uuid.UUID) (
	*models.Env,
	[]*models.EnvBuild,
	error,
)

func (*DB) GetTeamAuth

func (db *DB) GetTeamAuth(ctx context.Context, apiKey string) (*models.Team, *models.Tier, error)

func (*DB) GetTeamByIDAndUserIDAuth

func (db *DB) GetTeamByIDAndUserIDAuth(ctx context.Context, teamID string, userID uuid.UUID) (*models.Team, *models.Tier, error)

func (*DB) GetTeams

func (db *DB) GetTeams(ctx context.Context, userID uuid.UUID) ([]*models.Team, error)

func (*DB) GetUserID

func (db *DB) GetUserID(ctx context.Context, token string) (*uuid.UUID, error)

func (*DB) NewSnapshotBuild

func (db *DB) NewSnapshotBuild(
	ctx context.Context,
	snapshotConfig *SnapshotInfo,
	teamID uuid.UUID,
) (*models.EnvBuild, error)

Check if there exists snapshot with the ID, if yes then return a new snapshot and env build. Otherwise create a new one.

func (*DB) UpdateEnv

func (db *DB) UpdateEnv(ctx context.Context, envID string, input UpdateEnvInput) error

func (*DB) UpdateEnvAlias

func (db *DB) UpdateEnvAlias(ctx context.Context, alias, envID string) error

func (*DB) UpdateEnvLastUsed

func (db *DB) UpdateEnvLastUsed(ctx context.Context, count int64, time time.Time, envID string) (err error)

type EnvNotFound

type EnvNotFound struct{ ErrNotFound }

func (EnvNotFound) Error

func (EnvNotFound) Error() string

type ErrNotFound

type ErrNotFound error

type SnapshotInfo

type SnapshotInfo struct {
	SandboxID          string
	BaseTemplateID     string
	VCPU               int64
	RAMMB              int64
	Metadata           map[string]string
	TotalDiskSizeMB    int64
	KernelVersion      string
	FirecrackerVersion string
	EnvdVersion        string
}

type SnapshotNotFound

type SnapshotNotFound struct{ ErrNotFound }

func (SnapshotNotFound) Error

func (SnapshotNotFound) Error() string

type TeamUsageError

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

func (*TeamUsageError) Error

func (e *TeamUsageError) Error() string

type Template

type Template struct {
	TemplateID    string
	BuildID       string
	TeamID        uuid.UUID
	VCPU          int64
	DiskMB        int64
	RAMMB         int64
	Public        bool
	Aliases       *[]string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	LastSpawnedAt time.Time
	SpawnCount    int64
	BuildCount    int32
	CreatedBy     *TemplateCreator
}

type TemplateCreator

type TemplateCreator struct {
	Email string
	Id    uuid.UUID
}

type TemplateNotFound

type TemplateNotFound struct{ ErrNotFound }

func (TemplateNotFound) Error

func (TemplateNotFound) Error() string

type UpdateEnvInput

type UpdateEnvInput struct {
	Public bool
}

Jump to

Keyboard shortcuts

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