Documentation ¶
Overview ¶
Package database manages Tempest's database.
Tempest uses SQLite, but we encapsulate our queries here to avoid having SQL strewn throughout the codebase. This package provides some wrapper objects for the database & transactions, which have methods for the queries we want to support.
Index ¶
- Constants
- type DB
- type GrainInfo
- type Keyring
- type NewAccount
- type NewCredential
- type NewGrain
- type Package
- type SturdyRefKey
- type SturdyRefValue
- type Tx
- func (tx Tx) AccountGrainPermissions(accountID types.AccountID, grainID types.GrainID) (permissions []bool, err error)
- func (tx Tx) AccountKeyring(id types.AccountID) Keyring
- func (tx Tx) AccountProfile(accountID types.AccountID) (identity.Profile, error)
- func (tx Tx) AddAccount(a NewAccount) error
- func (tx Tx) AddCredential(c NewCredential) error
- func (tx Tx) AddGrain(g NewGrain) error
- func (tx Tx) AddPackage(pkg Package) error
- func (tx Tx) Commit() error
- func (tx Tx) CredentialAccount(cred types.Credential) (types.AccountID, error)
- func (tx Tx) CredentialPackages(cred types.Credential) ([]Package, error)
- func (tx Tx) CredentialRole(cred types.Credential) (role types.Role, err error)
- func (tx Tx) DeleteSturdyRef(k SturdyRefKey) error
- func (tx Tx) GrainInfo(grainID types.GrainID) (GrainInfo, error)
- func (tx Tx) GrainPackageID(grainID types.GrainID) (string, error)
- func (tx Tx) NewSharingToken(grainID types.GrainID, perms []bool, note string) (string, error)
- func (tx Tx) ReadyPackage(id types.ID[Package]) error
- func (tx Tx) RestoreSturdyRef(k SturdyRefKey) (SturdyRefValue, error)
- func (tx Tx) Rollback() error
- func (tx Tx) SaveSturdyRef(k SturdyRefKey, v SturdyRefValue) ([sha256.Size]byte, error)
- func (tx Tx) SetGrainViewInfo(grainID string, viewInfo grain.UiView_ViewInfo) error
- type UiViewInfo
Constants ¶
const (
DBPath = config.Localstatedir + "/sandstorm/sandstorm.sqlite3"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
Wrapper object around a SQL database.
type Keyring ¶
type Keyring struct {
// contains filtered or unexported fields
}
Represent's an account's keyring.
func (Keyring) AllUiViews ¶
func (kr Keyring) AllUiViews() ([]UiViewInfo, error)
AllUiViews returns all the UiViews in the keyring.
type NewAccount ¶
type NewCredential ¶
type NewCredential struct { AccountID types.AccountID Login bool Credential types.Credential }
type Package ¶
type Package struct { ID types.ID[Package] // The package id. Manifest spk.Manifest // The manifest as encoded in the spk. }
A Package records information about a package in the database.
type SturdyRefKey ¶
A SturdyRefKey is the data by which a sturdyRef may be fetched from the database (using RestoreSturdyRef).
type SturdyRefValue ¶
A SturdyRefValue is a persistent value stored in the database, which may be fetched via RestoreSturdyRef.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Transaction
func (Tx) AccountGrainPermissions ¶
func (Tx) AccountProfile ¶
func (Tx) AddAccount ¶
func (tx Tx) AddAccount(a NewAccount) error
func (Tx) AddCredential ¶
func (tx Tx) AddCredential(c NewCredential) error
func (Tx) AddPackage ¶
AddPackage adds a package to the database, initally marked as not ready. The caller must then move the extracted package to the right location, and then call ReadyPackage to complete installation.
func (Tx) CredentialAccount ¶
CredentialAccount returns the account ID associated with the credential. If there is no existing account, one is created with the visitor role.
func (Tx) CredentialPackages ¶
func (tx Tx) CredentialPackages(cred types.Credential) ([]Package, error)
CredentialPackages returns a list of all packages installed for the user associated with the credential.
func (Tx) CredentialRole ¶
CredentialRole gets the role corresponding to the credential. Returns RoleVisitor for unknown credentials.
func (Tx) DeleteSturdyRef ¶
func (tx Tx) DeleteSturdyRef(k SturdyRefKey) error
Delete a sturdyref from the database.
func (Tx) GrainPackageID ¶
GrainPackageID returns the package id for the specified grain
func (Tx) NewSharingToken ¶
func (Tx) RestoreSturdyRef ¶
func (tx Tx) RestoreSturdyRef(k SturdyRefKey) (SturdyRefValue, error)
Restore a SturdyRef from the database.
func (Tx) SaveSturdyRef ¶
func (tx Tx) SaveSturdyRef(k SturdyRefKey, v SturdyRefValue) ([sha256.Size]byte, error)
Save a SturdyRef in the database. k's token must not be nil. Returns the sha256 hash of the token, which serves as a key in the database.
func (Tx) SetGrainViewInfo ¶
func (tx Tx) SetGrainViewInfo(grainID string, viewInfo grain.UiView_ViewInfo) error