store

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CL_DEFAULT_ID = ChangelogID("cl_config")
	GH_DEFAULT_ID = GHSourceID("gh_config")
	WS_DEFAULT_ID = WorkspaceID("ws_config")
)

Variables

This section is empty.

Functions

func IsGHID

func IsGHID(id string) bool

Types

type Changelog

type Changelog struct {
	WorkspaceID WorkspaceID
	ID          ChangelogID
	Subdomain   Subdomain
	Domain      Domain
	Title       null.String
	Subtitle    null.String
	LogoSrc     null.String
	LogoLink    null.String
	LogoAlt     null.String
	LogoHeight  null.String
	LogoWidth   null.String
	CreatedAt   time.Time
	GHSource    null.Value[GHSource]
	LocalSource null.Value[LocalSource]
}

type ChangelogID

type ChangelogID string

func NewCID

func NewCID() ChangelogID

func ParseCID

func ParseCID(id string) (ChangelogID, error)

func (ChangelogID) String

func (i ChangelogID) String() string

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Domain added in v0.1.2

type Domain null.String

func DomainFromSQL added in v0.1.2

func DomainFromSQL(d sql.NullString) Domain

func ParseDomain added in v0.1.2

func ParseDomain(d null.String) (Domain, error)

strips everything from d except the host

func (Domain) ToNullString added in v0.1.2

func (d Domain) ToNullString() null.String

type GHSource

type GHSource struct {
	ID             GHSourceID
	WorkspaceID    WorkspaceID
	Owner          string
	Repo           string
	Path           string
	InstallationID int64
}

type GHSourceID

type GHSourceID string

func NewGHID

func NewGHID() GHSourceID

func ParseGHID

func ParseGHID(id string) (GHSourceID, error)

func (GHSourceID) String

func (i GHSourceID) String() string

type LocalSource

type LocalSource struct {
	Path string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Store

type Store interface {
	GetChangelog(context.Context, WorkspaceID, ChangelogID) (Changelog, error)
	GetChangelogByDomainOrSubdomain(ctx context.Context, domain Domain, subdomain Subdomain) (Changelog, error)
	ListChangelogs(context.Context, WorkspaceID) ([]Changelog, error)
	CreateChangelog(context.Context, Changelog) (Changelog, error)
	UpdateChangelog(context.Context, WorkspaceID, ChangelogID, UpdateChangelogArgs) (Changelog, error)
	DeleteChangelog(context.Context, WorkspaceID, ChangelogID) error
	SetChangelogGHSource(context.Context, WorkspaceID, ChangelogID, GHSourceID) error
	DeleteChangelogSource(context.Context, WorkspaceID, ChangelogID) error

	// Workspace
	GetWorkspace(context.Context, WorkspaceID) (Workspace, error)
	SaveWorkspace(context.Context, Workspace) (Workspace, error)
	GetWorkspaceIDByToken(ctx context.Context, token string) (WorkspaceID, error)
	DeleteWorkspace(context.Context, WorkspaceID) error

	// Source
	CreateGHSource(context.Context, GHSource) (GHSource, error)
	GetGHSource(context.Context, WorkspaceID, GHSourceID) (GHSource, error)
	ListGHSources(context.Context, WorkspaceID) ([]GHSource, error)
	DeleteGHSource(context.Context, WorkspaceID, GHSourceID) error
}

func NewConfigStore

func NewConfigStore(cfg config.Config) Store

Create a new store implementation, backed by the config file

func NewSQLiteStore

func NewSQLiteStore(conn string) (Store, error)

type Subdomain added in v0.1.2

type Subdomain string

func NewSubdomain added in v0.1.2

func NewSubdomain(workspaceName string) Subdomain

func ParseSubdomain added in v0.1.2

func ParseSubdomain(subdomain string) Subdomain

func SubdomainFromHost added in v0.1.2

func SubdomainFromHost(host string) (Subdomain, error)

Returns the subdomain from the host. Returns an error if the host doesn't have a subdomain

func (Subdomain) NullString added in v0.1.2

func (s Subdomain) NullString() null.String

func (Subdomain) String added in v0.1.2

func (s Subdomain) String() string

type Token

type Token string

func NewToken

func NewToken() Token

func ParseToken

func ParseToken(key string) (Token, error)

func (Token) IsSet

func (k Token) IsSet() bool

func (Token) String

func (k Token) String() string

type UpdateChangelogArgs

type UpdateChangelogArgs struct {
	Title      null.String
	Subdomain  Subdomain
	Domain     Domain
	Subtitle   null.String
	LogoSrc    null.String
	LogoLink   null.String
	LogoAlt    null.String
	LogoHeight null.String
	LogoWidth  null.String
}

type Workspace

type Workspace struct {
	ID    WorkspaceID
	Name  string
	Token Token
}

type WorkspaceID

type WorkspaceID string

func NewWID

func NewWID() WorkspaceID

func ParseWID

func ParseWID(id string) (WorkspaceID, error)

func (WorkspaceID) String

func (i WorkspaceID) String() string

Jump to

Keyboard shortcuts

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