blamewarrior

package
v0.0.0-...-59f949b Latest Latest
Warning

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

Go to latest
Published: May 26, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Copyright (C) 2016 The BlameWarrior Authors.

This file is a part of BlameWarrior service.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright (C) 2016 The BlameWarrior Authors.

This file is a part of BlameWarrior service.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright (C) 2016 The BlameWarrior Authors.

This file is a part of BlameWarrior service.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	CreateRepositoryQuery = `
    INSERT INTO repositories(full_name) VALUES($1) RETURNING id
  `

	GetListAccountsQuery = `` /* 304-byte string literal not displayed */

	AddAccountQuery = `
      INSERT INTO accounts(uid, login, permissions) VALUES ($1, $2, $3) RETURNING id
  `

	BuildCollaborationQuery = `
    INSERT INTO collaboration (SELECT DISTINCT id, $2::int FROM repositories WHERE full_name=$1)
  `

	EditAccountQuery = `` /* 230-byte string literal not displayed */

	DisconnectAccountQuery = `` /* 253-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func ConnectDatabase

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

Types

type Account

type Account struct {
	Id          int                `json:"-"`
	Uid         int                `json:"uid"`
	Login       string             `json:"login"`
	Permissions AccountPermissions `json:"permissions"`
}

Account represents GitHub user account stored in BlameWarrior database.

type AccountPermissions

type AccountPermissions map[string]bool

func (*AccountPermissions) Scan

func (perms *AccountPermissions) Scan(src interface{}) error

func (AccountPermissions) Value

func (perms AccountPermissions) Value() (driver.Value, error)

type Collaboration

type Collaboration interface {
	CreateRepository(sqlRunner SQLRunner, repositoryFullName string) error
	ListAccounts(sqlRunner SQLRunner, repositoryFullName string) ([]Account, error)
	AddAccount(tx *sql.Tx, repositoryFullName string, account *Account) (*Account, error)
	EditAccount(sqlRunner SQLRunner, repositoryFullName string, account *Account) error
	DisconnectAccount(sqlRunner SQLRunner, repositoryFullName, login string) error
}

type CollaborationService

type CollaborationService struct{}

func NewCollaborationService

func NewCollaborationService() *CollaborationService

func (*CollaborationService) AddAccount

func (service *CollaborationService) AddAccount(tx *sql.Tx, repositoryFullName string, account *Account) (*Account, error)

func (*CollaborationService) CreateRepository

func (service *CollaborationService) CreateRepository(sqlRunner SQLRunner, repositoryFullName string) error

func (*CollaborationService) DisconnectAccount

func (service *CollaborationService) DisconnectAccount(sqlRunner SQLRunner, repositoryFullName, login string) error

func (*CollaborationService) EditAccount

func (service *CollaborationService) EditAccount(sqlRunner SQLRunner, repositoryFullName string, account *Account) error

func (*CollaborationService) ListAccounts

func (service *CollaborationService) ListAccounts(sqlRunner SQLRunner, repositoryFullName string) ([]Account, error)

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 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