blamewarrior

package
v0.0.0-...-d521bd7 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetListRepositoryByOwnerQuery = `SELECT owner, name, private FROM repositories WHERE owner=$1`
	GetRepositoryQuery            = `SELECT owner, name, private FROM repositories WHERE owner=$1 AND name=$2`
	CreateRepositoryQuery         = `INSERT INTO repositories (owner, name, private) VALUES ($1, $2, $3) RETURNING id`
	DeleteRepositoryQuery         = `DELETE FROM repositories WHERE owner=$1 and name=$2`
)

Variables

View Source
var IncorrectFullName = fmt.Errorf("incorrect full name for repository")

Functions

func ConnectDatabase

func ConnectDatabase(dbName string, opts ...*DatabaseOptions) (*sql.DB, error)

func CreateRepository

func CreateRepository(runner SQLRunner, repo *Repository) (err error)

func DeleteRepository

func DeleteRepository(runner SQLRunner, fullName string) (err error)

Types

type DatabaseOptions

type DatabaseOptions struct {
	// Host is PostgreSQL database host
	Host string
	// Port is PostgreSQL database port
	Port string
	// User is connection user
	User string
	// Password is connection password to authenticate with
	Password string
}

DatabaseOptions is a configuration object type to pass PostgreSQL connection options.

func (*DatabaseOptions) ConnectionString

func (opts *DatabaseOptions) ConnectionString() string

ConnectionString returns a connection string suitable to for sql.DB().

type Repository

type Repository struct {
	ID      int    `json:"-"`
	Owner   string `json:"owner"`
	Name    string `json:"name"`
	Private bool   `json:"private"`
}

func GetListRepositoryByOwner

func GetListRepositoryByOwner(runner SQLRunner, owner string) (repositories []Repository, err error)

func GetRepositoryByFullName

func GetRepositoryByFullName(runner SQLRunner, fullName string) (*Repository, error)

func (*Repository) FullName

func (repo *Repository) FullName() string

func (*Repository) MarshalJSON

func (repo *Repository) MarshalJSON() ([]byte, error)

func (*Repository) Validate

func (repo *Repository) Validate() error

type SQLRunner

type SQLRunner interface {
	Query(string, ...interface{}) (*sql.Rows, error)
	QueryRow(string, ...interface{}) *sql.Row
	Prepare(string) (*sql.Stmt, error)
	Exec(string, ...interface{}) (sql.Result, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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