gitlab

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package gitlab is a wrapper around the gitlab package in the `./pkg` directory. The difference between this package and that is this package implements a processing layer so that the view layer can interact with interfaces instead of the raw API outputs.

This package also implements other app-specific things such as database table initialisations for custom implemented logic.

Index

Constants

View Source
const (
	TableName = "gl_notifs"
)

Variables

View Source
var SQLite3Migrations = []string{
	fmt.Sprintf("ALTER TABLE `%s` ADD `notification_id` VARCHAR(32) NOT NULL DEFAULT ''", TableName),
	fmt.Sprintf("ALTER TABLE `%s` ADD `message` TEXT NOT NULL DEFAULT ''", TableName),
	fmt.Sprintf("ALTER TABLE `%s` ADD `raw` TEXT NOT NULL DEFAULT ''", TableName),
	fmt.Sprintf("ALTER TABLE `%s` ADD `hostname` VARCHAR(256) NOT NULL DEFAULT ''", TableName),
}

Functions

func GetAccount

func GetAccount(hostname, accessToken string) (types.Account, error)

func GetTodos added in v0.0.4

func GetTodos(hostname, accessToken string, since ...time.Time) (types.Notifications, error)

func InitSQLite3Database added in v0.0.4

func InitSQLite3Database(databasePath string) error

func InsertNotification added in v0.0.4

func InsertNotification(todo pkggitlab.APIv4Todo, hostname string, connection *sql.DB) error

func QueryNotification added in v0.0.4

func QueryNotification(todo pkggitlab.APIv4Todo, hostname string, connection *sql.DB) (bool, error)

func WatchNotifications added in v0.0.4

func WatchNotifications(
	accounts []AccountConfig,
	databaseConnection *sql.DB,
	updateInterval time.Duration,
	stop chan struct{},
) chan types.Notification

Types

type Account

type Account pkg.APIv4UserResponse

Account implements types.Account

func (Account) GetCreatedAt added in v0.0.8

func (a Account) GetCreatedAt() *string

func (Account) GetEmail added in v0.0.8

func (a Account) GetEmail() *string

func (Account) GetFollowerCount added in v0.0.8

func (a Account) GetFollowerCount() *int

func (Account) GetIsAdmin added in v0.0.8

func (a Account) GetIsAdmin() *bool

func (Account) GetLastSeen added in v0.0.8

func (a Account) GetLastSeen() *string
func (a Account) GetLink() *string

func (Account) GetName added in v0.0.8

func (a Account) GetName() *string

func (Account) GetProjectCount added in v0.0.8

func (a Account) GetProjectCount() *int

func (Account) GetUsername added in v0.0.8

func (a Account) GetUsername() *string

type AccountConfig added in v0.0.4

type AccountConfig struct {
	// Name is the user-defined label for this account
	Name string `json:"name" yaml:"name"`
	// Description is a user-defined description of what this account is for
	Description string `json:"description" yaml:"description"`
	// Hostname is the hostname of the Gitlab installation. If this is not provided
	// this should default to "gitlab.com"
	Hostname string `json:"hostname" yaml:"hostname"`
	// AccessToken is your Gitlab Personal Access Token which can be generated
	// from this page at https://gitlab.com/profile/personal_access_tokens
	//
	// The required Scopes are as follows:
	// - read_user
	// - read_api
	// - read_repository
	// - read_registry
	AccessToken string `json:"accessToken" yaml:"accessToken"`
	// Public indicates whether this account should be public, if so, the /platforms
	// endpoint on the dev server will expose this account; this is done to accomodate
	// using both personal and work accounts, note that even if this is set to true,
	// the AccessToken should not be exposed
	Public bool `json:"public" yaml:"public"`
}

AccountConfig defines the configuration structure for a logical Gitlab account to be consumed

func (AccountConfig) GetSanitized added in v0.0.4

func (a AccountConfig) GetSanitized() AccountConfig

GetSanitized returns a copy of this Account instance without sensitive credentials

type AccountConfigs added in v0.0.4

type AccountConfigs []AccountConfig

AccountConfigs defines a list of AccountConfig instances which can be operated on internally

func (AccountConfigs) GetSanitized added in v0.0.4

func (a AccountConfigs) GetSanitized() []AccountConfig

GetSanitized returns a copy of this AccountConfigs instance without sensitive credentials

type Config

type Config struct {
	Accounts AccountConfigs `json:"accounts" yaml:"accounts"`
}

Config defines the structure of the configuration for the Gitlab integration

func (Config) GetSanitized

func (c Config) GetSanitized() Config

GetSanitized returns a copy of this Config instance without sensitive credentials

func (*Config) MergeWith added in v0.0.7

func (c *Config) MergeWith(o Config)

MergeWith merges the current Config instance with a provided Config instance. The merge strategy is add-only

type TodoSerializer added in v0.0.4

type TodoSerializer gl.APIv4Todo

func (TodoSerializer) GetMessage added in v0.0.4

func (ts TodoSerializer) GetMessage() string

func (TodoSerializer) GetTitle added in v0.0.4

func (ts TodoSerializer) GetTitle() string

Jump to

Keyboard shortcuts

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