database

package
v0.7.2 Latest Latest
Warning

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

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

Documentation

Overview

Package database implements a wrapper around the real database with some helper functions to store catalog / log entries

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatalogEntry

type CatalogEntry struct {
	Name string `json:"name" yaml:"name"`
	Tag  string `json:"tag" yaml:"tag"`

	Fetcher       string                           `json:"-" yaml:"fetcher"`
	FetcherConfig *fieldcollection.FieldCollection `json:"-" yaml:"fetcher_config"`

	VersionConstraint *version.Constraint `json:"-" yaml:"version_constraint"`

	Links []CatalogLink `json:"links" yaml:"links"`
}

CatalogEntry represents the entry in the config file

func (CatalogEntry) Key

func (c CatalogEntry) Key() string

Key returns the name / tag combination as a single key

type CatalogLink struct {
	IconClass string `json:"icon_class" yaml:"icon_class"`
	Name      string `json:"name" yaml:"name"`
	URL       string `json:"url" yaml:"url"`
}

CatalogLink represents a link assigned to a CatalogEntry

type CatalogMeta

type CatalogMeta struct {
	CatalogName    string     `gorm:"primaryKey" json:"-"`
	CatalogTag     string     `gorm:"primaryKey" json:"-"`
	CurrentVersion string     `json:"current_version,omitempty"`
	Error          string     `json:"error,omitempty"`
	LastChecked    *time.Time `json:"last_checked,omitempty"`
	VersionTime    *time.Time `json:"version_time,omitempty"`
}

CatalogMeta contains meta-information about the catalog entry

type CatalogMetaStore

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

CatalogMetaStore is an accessor for the meta store and wraps a Client

func (CatalogMetaStore) GetMeta

func (c CatalogMetaStore) GetMeta(ce *CatalogEntry) (*CatalogMeta, error)

GetMeta fetches the current database stored CatalogMeta for the CatalogEntry

func (CatalogMetaStore) Migrate added in v0.3.0

func (c CatalogMetaStore) Migrate(dest *Client) error

Migrate applies the updated database schema for the CatalogMetaStore

func (CatalogMetaStore) PutMeta

func (c CatalogMetaStore) PutMeta(cm *CatalogMeta) error

PutMeta stores the updated CatalogMeta

type Client

type Client struct {
	Catalog CatalogMetaStore
	Logs    LogStore
	// contains filtered or unexported fields
}

Client represents a database client

func NewClient

func NewClient(dbtype, dsn string) (*Client, error)

NewClient creates a new Client and connects to the database using some default configurations. The database is automatically initialized with required tables.

func (Client) Migrate added in v0.3.0

func (c Client) Migrate(dest *Client) error

Migrate executes database migrations for all required types

type LogEntry

type LogEntry struct {
	CatalogName string    `gorm:"index:catalog_key" json:"catalog_name"`
	CatalogTag  string    `gorm:"index:catalog_key" json:"catalog_tag"`
	Timestamp   time.Time `gorm:"index:,sort:desc" json:"timestamp"`
	VersionTo   string    `json:"version_to"`
	VersionFrom string    `json:"version_from"`
}

LogEntry represents a single version change for a given catalog entry

type LogStore

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

LogStore is an accessor for the log store and wraps a Client

func (LogStore) Add

func (l LogStore) Add(le *LogEntry) error

Add creates a new LogEntry inside the LogStore

func (LogStore) List

func (l LogStore) List(num, page int) ([]LogEntry, error)

List retrieves unfiltered log entries by page

func (LogStore) ListForCatalogEntry

func (l LogStore) ListForCatalogEntry(ce *CatalogEntry, num, page int) ([]LogEntry, error)

ListForCatalogEntry retrieves filered log entries by page

func (LogStore) Migrate added in v0.3.0

func (l LogStore) Migrate(dest *Client) error

Migrate applies the updated database schema for the LogStore

Jump to

Keyboard shortcuts

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