models

package
v0.0.0-...-f347ef5 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventHeader is the kafka header for webhook event type.
	EventHeader = "event_type"
	// RepoIDHeader is the kafka header for webhook repo_id.
	RepoIDHeader = "repo_id"
	// GitSCMHeader is the kafka header for webhook git_scm provider.
	GitSCMHeader = "git_driver"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// Close closes the db connection.
	Close() error
	// ExecuteTransaction wrapper for executing queries in a transaction.
	ExecuteTransaction(fn func(tx *sqlx.Tx) error) (err error)
	// Execute wrapper for executing the queries.
	Execute(fn func(conn *sqlx.DB) error) (err error)
}

DB represents the MySQL client

type EventType

type EventType string

EventType represents the webhook event

const (
	// EventPush represents the push event.
	EventPush EventType = "push"
	// EventPullRequest represents the pull request event.
	EventPullRequest EventType = "pull-request"
	// EventPing represents the ping event.
	EventPing EventType = "ping"
)

type HookParser

type HookParser interface {
	Parse(req *http.Request, driver SCMDriver) (scm.Webhook, []kafka.Header, error)
}

HookParser parses the webhook from the source code management system.

type Organization

type Organization struct {
	ID          string    `json:"-" db:"id"`
	Name        string    `json:"name" db:"name"`
	Avatar      string    `json:"avatar" db:"avatar"`
	GitProvider SCMDriver `json:"git_provider" db:"git_provider"`
	Created     time.Time `json:"-" db:"created_at"`
	Updated     time.Time `json:"-"  db:"updated_at"`
}

Organization represents a git organization

type OrganizationStore

type OrganizationStore interface {
	// Find finds the organizations in the datastore by name and scm driver.
	Find(ctx context.Context, scmDriver SCMDriver, org *Organization) ([]*Organization, error)
}

OrganizationStore defines operations for working with organizations.

type Perm

type Perm struct {
	Read  bool `db:"perm_read"     json:"read"`
	Write bool `db:"perm_write"    json:"write"`
	Admin bool `db:"perm_admin"    json:"admin"`
}

Perm represents the user' s repository permissions

type Producer

type Producer interface {
	// WriteMessage write the message to the kafka producer.
	WriteMessage(msg []byte, headers ...kafka.Header) error
	// Close closes the kafka producer connection.
	Close() error
	// Stats returns the kafka producer stats.
	Stats() ProducerStats
}

Producer represents the Kafka producer.

type ProducerStats

type ProducerStats struct {
	Duration      time.Duration
	TotalMessages int64
	TotalErrors   int64
	TotalBytes    int64
	Throughput    float64
}

ProducerStats are the metrics of kafka producer.

type RepoStore

type RepoStore interface {
	// FindActiveByName returns the active repositories in the data store by commitID.
	FindActiveByName(ctx context.Context, repoName, orgName string, gitProvider SCMDriver) (repo *Repository, err error)
}

RepoStore defines operations for working with repositories.

type Repository

type Repository struct {
	ID                string    `json:"id,omitempty" db:"id"`
	OrgID             string    `json:"-" db:"org_id"`
	Strict            bool      `json:"-" db:"strict"`
	Name              string    `json:"name,omitempty" db:"name"`
	Admin             string    `json:"-" db:"admin_id"`
	Namespace         string    `json:"namespace,omitempty"`
	Private           bool      `json:"-"`
	Secret            string    `json:"-" db:"webhook_secret"`
	Link              string    `json:"link" db:"link"`
	HTTPURL           string    `json:"http_url,omitempty" db:"git_http_url"`
	SSHURL            string    `json:"ssh_url,omitempty" db:"git_ssh_url"`
	Active            bool      `json:"active" db:"active"`
	TasFileName       string    `json:"-"  db:"tas_file_name"`
	PostMergeStrategy int       `json:"-"  db:"post_merge_strategy"`
	Created           time.Time `json:"-"  db:"created_at"`
	Updated           time.Time `json:"-"  db:"updated_at"`
	Perm              *Perm     `json:"permissions,omitempty"`
	Mask              string    `json:"-" db:"mask"`
}

Repository represents a git repository

type SCM

type SCM struct {
	Client     *scm.Client
	SelfHosted bool
}

SCM is wrapper around scm.Client

type SCMDriver

type SCMDriver string

SCMDriver identifies source code management driver.

const (
	DriverGithub    SCMDriver = "github"
	DriverGitlab    SCMDriver = "gitlab"
	DriverBitbucket SCMDriver = "bitbucket"
)

SCMDriver values.

func (SCMDriver) VerifyDriver

func (d SCMDriver) VerifyDriver() error

VerifyDriver verifies if the SCMDriver is valid.

type SCMProvider

type SCMProvider interface {
	//  GetClient returns a new git scm client
	GetClient(scmClientID SCMDriver) (*SCM, error)
}

SCMProvider return a new git scm client based on the driver.

Jump to

Keyboard shortcuts

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