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
- func ConnectDatabase(dbName string, opts ...*DatabaseOptions) (*sql.DB, error)
- type Account
- type AccountPermissions
- type Collaboration
- type CollaborationService
- func (service *CollaborationService) AddAccount(tx *sql.Tx, repositoryFullName string, account *Account) (*Account, error)
- func (service *CollaborationService) CreateRepository(sqlRunner SQLRunner, repositoryFullName string) error
- func (service *CollaborationService) DisconnectAccount(sqlRunner SQLRunner, repositoryFullName, login string) error
- func (service *CollaborationService) EditAccount(sqlRunner SQLRunner, repositoryFullName string, account *Account) error
- func (service *CollaborationService) ListAccounts(sqlRunner SQLRunner, repositoryFullName string) ([]Account, error)
- type DatabaseOptions
- type SQLRunner
Constants ¶
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 ¶
func (*AccountPermissions) Scan ¶
func (perms *AccountPermissions) Scan(src interface{}) 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 (*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().