database

package
v0.0.0-...-040dba6 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(db *bun.DB)

func Connect

func Connect(dsn string) *bun.DB

Types

type App

type App struct {
	bun.BaseModel `bun:"table:apps"`
	Id            int64     `bun:"id,pk,autoincrement"`
	Vendor        string    `bun:"vendor"`
	Product       string    `bun:"product"`
	Name          string    `bun:"name"`
	Active        bool      `bun:"active,default:true"`
	Locked        bool      `bun:"locked,default:false"`
	AllowRegister bool      `bun:"allow_register,default:true"`
	UpgradeTarget string    `bun:"upgrade_target"` // If empty, the default upgrade target will be used
	CreatedAt     time.Time `bun:"created_at"`
	UpdatedAt     time.Time `bun:"updated_at"`
	Groups        []Group   `bun:"rel:has-many,join:id=app_id"`
	Variants      []Variant `bun:"rel:has-many,join:id=app_id"`
}

func FromCatalogApp

func FromCatalogApp(app *catalog.App) App

func (*App) GetDefaultGroups

func (app *App) GetDefaultGroups() []Group

func (*App) ToCatalogApp

func (app *App) ToCatalogApp() *catalog.App

type Client

type Client struct {
	bun.BaseModel `bun:"table:clients"`
	Id            int64     `bun:"id,pk,autoincrement"`
	AppId         int64     `bun:"app_id"`
	App           *App      `bun:"rel:belongs-to,join:app_id=id"`
	Variant       string    `bun:"variant"` // will be enforced when fetching releases
	Uuid          string    `bun:"uuid"`
	Name          string    `bun:"name"`
	Active        bool      `bun:"active,default:true"`
	Locked        bool      `bun:"locked,default:false"`
	CreatedAt     time.Time `bun:"created_at"`
	UpdatedAt     time.Time `bun:"updated_at"`
	Groups        []Group   `bun:"m2m:clients_groups,join:Client=Group"`
}

func (*Client) ToCatalogClient

func (c *Client) ToCatalogClient() *catalog.Client

type ClientToGroup

type ClientToGroup struct {
	bun.BaseModel `bun:"table:clients_groups"`
	Id            int64     `bun:"id,pk,autoincrement"`
	ClientId      int64     `bun:"client_id"`
	Client        *Client   `bun:"rel:belongs-to,join:client_id=id"`
	GroupId       int64     `bun:"group_id"`
	Group         *Group    `bun:"rel:belongs-to,join:group_id=id"`
	CreatedAt     time.Time `bun:"created_at"`
	UpdatedAt     time.Time `bun:"updated_at"`
}

type DbCatalogStore

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

func NewDbCatalogStore

func NewDbCatalogStore(db *bun.DB, ctx context.Context) *DbCatalogStore

func (*DbCatalogStore) FetchReleases

func (store *DbCatalogStore) FetchReleases(filter catalog.Filter, limit int) ([]*catalog.Release, error)

func (*DbCatalogStore) FindApp

func (store *DbCatalogStore) FindApp(vendor string, product string) (*catalog.App, error)

func (*DbCatalogStore) LatestReleases

func (store *DbCatalogStore) LatestReleases(limit int) ([]*catalog.Release, error)

func (*DbCatalogStore) ListApps

func (store *DbCatalogStore) ListApps(limit int) ([]*catalog.App, error)

func (*DbCatalogStore) ListGroups

func (store *DbCatalogStore) ListGroups(filter catalog.GroupFilter, limit int) ([]*catalog.Group, error)

func (*DbCatalogStore) ListVariants

func (store *DbCatalogStore) ListVariants(filter catalog.VariantFilter, limit int) ([]*catalog.Variant, error)

func (*DbCatalogStore) RegisterClient

func (store *DbCatalogStore) RegisterClient(app *catalog.App, variant string, groups []string) (*catalog.Client, error)

func (*DbCatalogStore) SetAppDefaultGroups

func (store *DbCatalogStore) SetAppDefaultGroups(app *catalog.App) (*catalog.App, error)

func (*DbCatalogStore) SetCriticality

func (store *DbCatalogStore) SetCriticality(filter catalog.Filter, criticality catalog.Criticality) ([]*catalog.Release, error)

func (*DbCatalogStore) SetStability

func (store *DbCatalogStore) SetStability(filter catalog.Filter, stability bool) ([]*catalog.Release, error)

func (*DbCatalogStore) SetUpgradeTarget

func (store *DbCatalogStore) SetUpgradeTarget(filter catalog.Filter, target catalog.UpgradeTarget) ([]*catalog.Release, error)

func (*DbCatalogStore) StoreApp

func (store *DbCatalogStore) StoreApp(app *catalog.App, allowUpdate bool) (*catalog.App, error)

func (*DbCatalogStore) StoreGroup

func (store *DbCatalogStore) StoreGroup(
	group *catalog.Group,
	allowUpdate bool,
) (*catalog.Group, error)

func (*DbCatalogStore) StoreRelease

func (store *DbCatalogStore) StoreRelease(
	release *catalog.Release,
	allowUpdate bool,
) (*catalog.Release, error)

func (*DbCatalogStore) StoreVariant

func (store *DbCatalogStore) StoreVariant(
	variant *catalog.Variant,
	allowUpdate bool,
) (*catalog.Variant, error)

type Group

type Group struct {
	bun.BaseModel `bun:"table:groups"`
	Id            int64     `bun:"id,pk,autoincrement"`
	AppId         int64     `bun:"app_id"`
	App           *App      `bun:"rel:belongs-to,join:app_id=id"`
	Name          string    `bun:"name"`
	Default       bool      `bun:"default"`
	CreatedAt     time.Time `bun:"created_at"`
	UpdatedAt     time.Time `bun:"updated_at"`
}

func FromCatalogGroup

func FromCatalogGroup(g *catalog.Group) Group

func (*Group) ToCatalogGroup

func (g *Group) ToCatalogGroup() *catalog.Group

type Release

type Release struct {
	bun.BaseModel `bun:"table:releases"`
	Id            int64     `bun:"id,pk,autoincrement"`
	AppId         int64     `bun:"app_id"`
	App           *App      `bun:"rel:belongs-to,join:app_id=id"`
	Variant       string    `bun:"variant"`
	Description   string    `bun:"description"`
	OS            string    `bun:"os"`
	Arch          string    `bun:"arch"`
	ReleasedAt    time.Time `bun:"released_at"`
	Version       string    `bun:"version"`
	Unstable      bool      `bun:"unstable"`
	Alias         string    `bun:"alias"`
	Link          string    `bun:"link"`
	Format        string    `bun:"format"`
	Signature     string    `bun:"signature"` // a cryptographical representation (hash etc)
	Tags          []string  `bun:"tags,array"`
	UpgradeTarget string    `bun:"upgrade_target"` // If empty, the default upgrade target will be used
	ShouldUpgrade int       `bun:"should_upgrade"`
	UpdatedAt     time.Time `bun:"updated_at"`
	Groups        []Group   `bun:"m2m:releases_groups,join:Release=Group"`
}

func FromCatalogRelease

func FromCatalogRelease(r *catalog.Release) Release

func (*Release) ToCatalogRelease

func (r *Release) ToCatalogRelease() *catalog.Release

type ReleaseToGroup

type ReleaseToGroup struct {
	bun.BaseModel `bun:"table:releases_groups"`
	Id            int64     `bun:"id,pk,autoincrement"`
	ReleaseId     int64     `bun:"release_id"`
	Release       *Release  `bun:"rel:belongs-to,join:release_id=id"`
	GroupId       int64     `bun:"group_id"`
	Group         *Group    `bun:"rel:belongs-to,join:group_id=id"`
	CreatedAt     time.Time `bun:"created_at"`
	UpdatedAt     time.Time `bun:"updated_at"`
}

type Variant

type Variant struct {
	bun.BaseModel `bun:"table:variants"`
	Id            int64     `bun:"id,pk,autoincrement"`
	AppId         int64     `bun:"app_id"`
	App           *App      `bun:"rel:belongs-to,join:app_id=id"`
	Name          string    `bun:"name"`
	Active        bool      `bun:"active,default:true"`
	Locked        bool      `bun:"locked,default:false"`
	AllowRegister bool      `bun:"allow_register,default:true"`
	UpgradeTarget string    `bun:"upgrade_target"` // If empty, the default upgrade target will be used
	CreatedAt     time.Time `bun:"created_at"`
	UpdatedAt     time.Time `bun:"updated_at"`
	Groups        []Group   `bun:"m2m:variants_default_groups,join:Variant=Group"`
}

func FromCatalogVariant

func FromCatalogVariant(v *catalog.Variant) Variant

func (*Variant) ToCatalogVariant

func (v *Variant) ToCatalogVariant() *catalog.Variant

type VariantToDefaultGroup

type VariantToDefaultGroup struct {
	bun.BaseModel `bun:"table:variants_default_groups"`
	Id            int64     `bun:"id,pk,autoincrement"`
	VariantId     int64     `bun:"variant_id"`
	Variant       *Variant  `bun:"rel:belongs-to,join:variant_id=id"`
	GroupId       int64     `bun:"group_id"`
	Group         *Group    `bun:"rel:belongs-to,join:group_id=id"`
	CreatedAt     time.Time `bun:"created_at"`
	UpdatedAt     time.Time `bun:"updated_at"`
}

Jump to

Keyboard shortcuts

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