project

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(projects Store, client *http.Client, apiHost, webhookSecret string) http.Handler

Create creates a project (and accompanying webhook if one is not already registered for the repo).

func Delete

func Delete(projects Store) http.Handler

Delete a project.

func GetAccessToken

func GetAccessToken(projects Store) http.Handler

GetAccessToken returns the access token (e.g. GitHub) for the project.

func GetAll

func GetAll(projects Store) http.Handler

GetAll returns all projects for an account.

Types

type Postgres

type Postgres struct {
	DB *sql.DB
}

Postgres is a postgres projects `Store` implementation.

func (*Postgres) Create

func (store *Postgres) Create(accountID, creatorID int64, title, description, repo, refs, vcsAccessToken string) (projectID int64, err error)

Create creates a new project.

func (*Postgres) Delete

func (store *Postgres) Delete(accountID, projectID int64) error

Delete a project.

func (*Postgres) GetAccessToken

func (store *Postgres) GetAccessToken(accountID, projectID int64) (accessToken string, err error)

GetAccessToken returns the vcs (e.g. GitHub) access token for the given account and project.

func (*Postgres) GetAll

func (store *Postgres) GetAll(accountID int64) ([]Project, error)

GetAll returns all projects under the account ID provided.

func (*Postgres) GetAllWatchingRepo

func (store *Postgres) GetAllWatchingRepo(repo string) ([]Project, error)

GetAllWatchingRepo returns all projects watching for chanegs to the repo provided.

func (*Postgres) ReferencesForRepo

func (store *Postgres) ReferencesForRepo(repository string) (regexPerProject map[int64]string, err error)

ReferencesForRepo returns the allowed references regex (branches and tags a project should build) for a repository. The returnd result is a map of project ids to allowed regex.

type Project

type Project struct {
	ID          int64  `json:"projectID"`
	AccountID   int64  `json:"accountID"`
	CreatorID   int64  `json:"creatorID"`
	Creator     string `json:"creator"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Repo        string `json:"repo"`
	Branch      string `json:"branch"`
	Created     string `json:"created"`
	Updated     string `json:"updated"`
}

The Project domain model.

type Store

type Store interface {
	// Delete deletes a project.
	Delete(accountID, projectID int64) error

	// GetAccessToken returns the vcs (e.g. GitHub) access token for the given account and project.
	GetAccessToken(accountID, projectID int64) (string, error)

	// GetAll returns all projects under the account ID provided.
	GetAll(accountID int64) ([]Project, error)

	// GetAllWatchingRepo returns all projects watching for changes to the repo provided.
	GetAllWatchingRepo(repo string) ([]Project, error)

	// ReferencesForRepo returns the allowed references regex (branches and tags a project should build) for a repository.
	// The returnd result is a map of project ids to allowed regex.
	ReferencesForRepo(repository string) (regexPerProject map[int64]string, err error)

	// Create creates a new project.
	Create(accountID, creatorID int64, title, description, repoURL, branch, githubAccessToken string) (projectID int64, err error)
}

Store abstracts communication with the service's persistance mechanism(s).

Jump to

Keyboard shortcuts

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