store

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextKey = &struct{ string }{"store"}

ContextKey is the store context key.

Functions

func WithContext

func WithContext(ctx context.Context, s Store) context.Context

WithContext returns a new context with the given store.

Types

type AccessTokenStore

type AccessTokenStore interface {
	GetAccessToken(ctx context.Context, h db.Handler, id int64) (models.AccessToken, error)
	GetAccessTokenByToken(ctx context.Context, h db.Handler, token string) (models.AccessToken, error)
	GetAccessTokensByUserID(ctx context.Context, h db.Handler, userID int64) ([]models.AccessToken, error)
	CreateAccessToken(ctx context.Context, h db.Handler, name string, userID int64, token string, expiresAt time.Time) (models.AccessToken, error)
	DeleteAccessToken(ctx context.Context, h db.Handler, id int64) error
	DeleteAccessTokenForUser(ctx context.Context, h db.Handler, userID int64, id int64) error
}

AccessTokenStore is an interface for managing access tokens.

type CollaboratorStore

type CollaboratorStore interface {
	GetCollabByUsernameAndRepo(ctx context.Context, h db.Handler, username string, repo string) (models.Collab, error)
	AddCollabByUsernameAndRepo(ctx context.Context, h db.Handler, username string, repo string, level access.AccessLevel) error
	RemoveCollabByUsernameAndRepo(ctx context.Context, h db.Handler, username string, repo string) error
	ListCollabsByRepo(ctx context.Context, h db.Handler, repo string) ([]models.Collab, error)
	ListCollabsByRepoAsUsers(ctx context.Context, h db.Handler, repo string) ([]models.User, error)
}

CollaboratorStore is an interface for managing collaborators.

type LFSStore

type LFSStore interface {
	CreateLFSObject(ctx context.Context, h db.Handler, repoID int64, oid string, size int64) error
	GetLFSObjectByOid(ctx context.Context, h db.Handler, repoID int64, oid string) (models.LFSObject, error)
	GetLFSObjects(ctx context.Context, h db.Handler, repoID int64) ([]models.LFSObject, error)
	GetLFSObjectsByName(ctx context.Context, h db.Handler, name string) ([]models.LFSObject, error)
	DeleteLFSObjectByOid(ctx context.Context, h db.Handler, repoID int64, oid string) error

	CreateLFSLockForUser(ctx context.Context, h db.Handler, repoID int64, userID int64, path string, refname string) error
	GetLFSLocks(ctx context.Context, h db.Handler, repoID int64, page int, limit int) ([]models.LFSLock, error)
	GetLFSLocksWithCount(ctx context.Context, h db.Handler, repoID int64, page int, limit int) ([]models.LFSLock, int64, error)
	GetLFSLocksForUser(ctx context.Context, h db.Handler, repoID int64, userID int64) ([]models.LFSLock, error)
	GetLFSLockForPath(ctx context.Context, h db.Handler, repoID int64, path string) (models.LFSLock, error)
	GetLFSLockForUserPath(ctx context.Context, h db.Handler, repoID int64, userID int64, path string) (models.LFSLock, error)
	GetLFSLockByID(ctx context.Context, h db.Handler, id int64) (models.LFSLock, error)
	GetLFSLockForUserByID(ctx context.Context, h db.Handler, repoID int64, userID int64, id int64) (models.LFSLock, error)
	DeleteLFSLock(ctx context.Context, h db.Handler, repoID int64, id int64) error
	DeleteLFSLockForUserByID(ctx context.Context, h db.Handler, repoID int64, userID int64, id int64) error
}

LFSStore is the interface for the LFS store.

type RepositoryStore

type RepositoryStore interface {
	GetRepoByName(ctx context.Context, h db.Handler, name string) (models.Repo, error)
	GetAllRepos(ctx context.Context, h db.Handler) ([]models.Repo, error)
	GetUserRepos(ctx context.Context, h db.Handler, userID int64) ([]models.Repo, error)
	CreateRepo(ctx context.Context, h db.Handler, name string, userID int64, projectName string, description string, isPrivate bool, isHidden bool, isMirror bool) error
	DeleteRepoByName(ctx context.Context, h db.Handler, name string) error
	SetRepoNameByName(ctx context.Context, h db.Handler, name string, newName string) error

	GetRepoProjectNameByName(ctx context.Context, h db.Handler, name string) (string, error)
	SetRepoProjectNameByName(ctx context.Context, h db.Handler, name string, projectName string) error
	GetRepoDescriptionByName(ctx context.Context, h db.Handler, name string) (string, error)
	SetRepoDescriptionByName(ctx context.Context, h db.Handler, name string, description string) error
	GetRepoIsPrivateByName(ctx context.Context, h db.Handler, name string) (bool, error)
	SetRepoIsPrivateByName(ctx context.Context, h db.Handler, name string, isPrivate bool) error
	GetRepoIsHiddenByName(ctx context.Context, h db.Handler, name string) (bool, error)
	SetRepoIsHiddenByName(ctx context.Context, h db.Handler, name string, isHidden bool) error
	GetRepoIsMirrorByName(ctx context.Context, h db.Handler, name string) (bool, error)
}

RepositoryStore is an interface for managing repositories.

type SettingStore

type SettingStore interface {
	GetAnonAccess(ctx context.Context, h db.Handler) (access.AccessLevel, error)
	SetAnonAccess(ctx context.Context, h db.Handler, level access.AccessLevel) error
	GetAllowKeylessAccess(ctx context.Context, h db.Handler) (bool, error)
	SetAllowKeylessAccess(ctx context.Context, h db.Handler, allow bool) error
}

SettingStore is an interface for managing settings.

type Store

Store is an interface for managing repositories, users, and settings.

func FromContext

func FromContext(ctx context.Context) Store

FromContext returns the store from the given context.

type UserStore

type UserStore interface {
	GetUserByID(ctx context.Context, h db.Handler, id int64) (models.User, error)
	FindUserByUsername(ctx context.Context, h db.Handler, username string) (models.User, error)
	FindUserByPublicKey(ctx context.Context, h db.Handler, pk ssh.PublicKey) (models.User, error)
	FindUserByAccessToken(ctx context.Context, h db.Handler, token string) (models.User, error)
	GetAllUsers(ctx context.Context, h db.Handler) ([]models.User, error)
	CreateUser(ctx context.Context, h db.Handler, username string, isAdmin bool, pks []ssh.PublicKey) error
	DeleteUserByUsername(ctx context.Context, h db.Handler, username string) error
	SetUsernameByUsername(ctx context.Context, h db.Handler, username string, newUsername string) error
	SetAdminByUsername(ctx context.Context, h db.Handler, username string, isAdmin bool) error
	AddPublicKeyByUsername(ctx context.Context, h db.Handler, username string, pk ssh.PublicKey) error
	RemovePublicKeyByUsername(ctx context.Context, h db.Handler, username string, pk ssh.PublicKey) error
	ListPublicKeysByUserID(ctx context.Context, h db.Handler, id int64) ([]ssh.PublicKey, error)
	ListPublicKeysByUsername(ctx context.Context, h db.Handler, username string) ([]ssh.PublicKey, error)
	SetUserPassword(ctx context.Context, h db.Handler, userID int64, password string) error
	SetUserPasswordByUsername(ctx context.Context, h db.Handler, username string, password string) error
}

UserStore is an interface for managing users.

type WebhookStore

type WebhookStore interface {
	// GetWebhookByID returns a webhook by its ID.
	GetWebhookByID(ctx context.Context, h db.Handler, repoID int64, id int64) (models.Webhook, error)
	// GetWebhooksByRepoID returns all webhooks for a repository.
	GetWebhooksByRepoID(ctx context.Context, h db.Handler, repoID int64) ([]models.Webhook, error)
	// GetWebhooksByRepoIDWhereEvent returns all webhooks for a repository where event is in the events.
	GetWebhooksByRepoIDWhereEvent(ctx context.Context, h db.Handler, repoID int64, events []int) ([]models.Webhook, error)
	// CreateWebhook creates a webhook.
	CreateWebhook(ctx context.Context, h db.Handler, repoID int64, url string, secret string, contentType int, active bool) (int64, error)
	// UpdateWebhookByID updates a webhook by its ID.
	UpdateWebhookByID(ctx context.Context, h db.Handler, repoID int64, id int64, url string, secret string, contentType int, active bool) error
	// DeleteWebhookByID deletes a webhook by its ID.
	DeleteWebhookByID(ctx context.Context, h db.Handler, id int64) error
	// DeleteWebhookForRepoByID deletes a webhook for a repository by its ID.
	DeleteWebhookForRepoByID(ctx context.Context, h db.Handler, repoID int64, id int64) error

	// GetWebhookEventByID returns a webhook event by its ID.
	GetWebhookEventByID(ctx context.Context, h db.Handler, id int64) (models.WebhookEvent, error)
	// GetWebhookEventsByWebhookID returns all webhook events for a webhook.
	GetWebhookEventsByWebhookID(ctx context.Context, h db.Handler, webhookID int64) ([]models.WebhookEvent, error)
	// CreateWebhookEvents creates webhook events for a webhook.
	CreateWebhookEvents(ctx context.Context, h db.Handler, webhookID int64, events []int) error
	// DeleteWebhookEventsByWebhookID deletes all webhook events for a webhook.
	DeleteWebhookEventsByID(ctx context.Context, h db.Handler, ids []int64) error

	// GetWebhookDeliveryByID returns a webhook delivery by its ID.
	GetWebhookDeliveryByID(ctx context.Context, h db.Handler, webhookID int64, id uuid.UUID) (models.WebhookDelivery, error)
	// GetWebhookDeliveriesByWebhookID returns all webhook deliveries for a webhook.
	GetWebhookDeliveriesByWebhookID(ctx context.Context, h db.Handler, webhookID int64) ([]models.WebhookDelivery, error)
	// ListWebhookDeliveriesByWebhookID returns all webhook deliveries for a webhook.
	// This only returns the delivery ID, response status, and event.
	ListWebhookDeliveriesByWebhookID(ctx context.Context, h db.Handler, webhookID int64) ([]models.WebhookDelivery, error)
	// CreateWebhookDelivery creates a webhook delivery.
	CreateWebhookDelivery(ctx context.Context, h db.Handler, id uuid.UUID, webhookID int64, event int, url string, method string, requestError error, requestHeaders string, requestBody string, responseStatus int, responseHeaders string, responseBody string) error
	// DeleteWebhookDeliveryByID deletes a webhook delivery by its ID.
	DeleteWebhookDeliveryByID(ctx context.Context, h db.Handler, webhookID int64, id uuid.UUID) error
}

WebhookStore is an interface for managing webhooks.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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