repository

package
v0.0.0-...-b6f1020 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrgNotFoundMsg             = "organization not found with orgId:%d"
	OrgFailedToGetMsg          = "failed to get organization with orgId:%d"
	ProjNotFoundMsg            = "project not found with projId:%d"
	ProjFailedToGetMsg         = "failed to get project with projId:%d"
	ProjFailedToRemove         = "failed to remove project with projId:%d"
	SourceNotFoundMsg          = "source not found with sourceId:%d"
	SourceFailedToGetMsg       = "failed to get source with sourceId:%d"
	SourceFailedToRemove       = "failed to remove source with sourceId:%d"
	OauthSourceNotFoundMsg     = "oauth source not found with source:%s"
	AccessTokenAlreadyExistMsg = "access token already exist with type:%s user:%s"
	AccessTokenNotFoundMsg     = "access token not found with type:%s user:%s"
	AccessTokenFailedToGetMsg  = "failed to get access token with type:%s user:%s"
)
View Source
const (
	// EntryNameDefault default entry name
	EntryNameDefault = "datastore"
)

Variables

This section is empty.

Functions

func RegisterRepositoryFromConfig

func RegisterRepositoryFromConfig(configFilePath string) map[string]rkentry.Entry

RegisterRepositoryFromConfig is an implementation of: type EntryRegFunc func(string) map[string]rkentry.Entry

Types

type AccessToken

type AccessToken struct {
	Base
	Id    int    `yaml:"id" json:"id" gorm:"primaryKey"`
	Type  string `yaml:"type" json:"type" gorm:"index"`
	User  string `yaml:"user" json:"user"`
	Token string `yaml:"-" json:"-"`
}

func NewAccessToken

func NewAccessToken(repoType, repoUser, repoToken string) *AccessToken

NewAccessToken create a project with params. A new name will be assigned with random Id if name is empty.

func (*AccessToken) String

func (token *AccessToken) String() string

String will marshal token into json format.

type AlreadyExist

type AlreadyExist struct {
	// contains filtered or unexported fields
}

func (*AlreadyExist) Error

func (e *AlreadyExist) Error() string

type Base

type Base struct {
	CreatedAt time.Time      `yaml:"createdAt" json:"createdAt"`
	UpdatedAt time.Time      `yaml:"updatedAt" json:"updatedAt"`
	DeletedAt gorm.DeletedAt `yaml:"-" json:"-" gorm:"index"`
}

Base defines base model of gorm model

type BootConfig

type BootConfig struct {
	Repository struct {
		Enabled  bool   `yaml:"enabled" json:"enabled"`
		Provider string `yaml:"provider" json:"provider"`
		MySql    struct {
			User     string   `yaml:"user" json:"user"`
			Pass     string   `yaml:"pass" json:"pass"`
			Protocol string   `yaml:"protocol" json:"protocol"`
			Addr     string   `yaml:"addr" json:"addr"`
			Database string   `yaml:"database" json:"database"`
			Params   []string `yaml:"params" json:"params"`
		} `yaml:"mySql" json:"mySql"`
		Logger struct {
			ZapLogger struct {
				Ref string `yaml:"ref" json:"ref"`
			} `yaml:"zapLogger" json:"zapLogger"`
			EventLogger struct {
				Ref string `yaml:"ref" json:"ref"`
			} `yaml:"eventLogger" json:"eventLogger"`
		} `yaml:"logger" json:"logger"`
	} `yaml:"repository" json:"repository"`
}

BootConfig is a struct which is for unmarshalled YAML

type Memory

type Memory struct {
	EntryName        string                    `json:"entryName" yaml:"entryName"`
	EntryType        string                    `json:"entryType" yaml:"entryType"`
	EntryDescription string                    `json:"entryDescription" yaml:"entryDescription"`
	ZapLoggerEntry   *rkentry.ZapLoggerEntry   `json:"zapLoggerEntry" yaml:"zapLoggerEntry"`
	EventLoggerEntry *rkentry.EventLoggerEntry `json:"eventLoggerEntry" yaml:"eventLoggerEntry"`

	AccessTokenList []*AccessToken `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

Memory implements interface of DataStore whose underlying storage is memory

func RegisterMemory

func RegisterMemory() *Memory

RegisterMemory will register Entry into GlobalAppCtx

func (*Memory) Bootstrap

func (m *Memory) Bootstrap(ctx context.Context)

Bootstrap will bootstrap datastore

func (*Memory) Connect

func (m *Memory) Connect() error

Connect to to remote/local provider

func (*Memory) CreateOrg

func (m *Memory) CreateOrg(org *Org) (bool, error)

CreateOrg as function name described

func (*Memory) CreateProj

func (m *Memory) CreateProj(proj *Proj) (bool, error)

CreateProj as function name described

func (*Memory) CreateSource

func (m *Memory) CreateSource(src *Source) (bool, error)

CreateSource as function name described

func (*Memory) GetAccessToken

func (m *Memory) GetAccessToken(repoType, repoUser string) (*AccessToken, error)

GetAccessToken as function name described

func (*Memory) GetDescription

func (m *Memory) GetDescription() string

GetDescription returns datastore entry description

func (*Memory) GetName

func (m *Memory) GetName() string

GetName returns datastore entry name

func (*Memory) GetOrg

func (m *Memory) GetOrg(orgId int) (*Org, error)

GetOrg as function name described

func (*Memory) GetProj

func (m *Memory) GetProj(projId int) (*Proj, error)

GetProj as function name described

func (*Memory) GetSource

func (m *Memory) GetSource(sourceId int) (*Source, error)

GetSource as function name described

func (*Memory) GetType

func (m *Memory) GetType() string

GetType returns datastore entry type

func (*Memory) Interrupt

func (m *Memory) Interrupt(ctx context.Context)

Interrupt will interrupt datastore

func (*Memory) IsHealthy

func (m *Memory) IsHealthy() bool

IsHealthy checks healthy status remote provider

func (*Memory) ListOrg

func (m *Memory) ListOrg() ([]*Org, error)

ListOrg as function name described

func (*Memory) ListPipelineTemplate

func (m *Memory) ListPipelineTemplate() ([]*PipelineTemplate, error)

func (*Memory) ListProj

func (m *Memory) ListProj(orgId int) ([]*Proj, error)

ListProj as function name described

func (*Memory) RemoveAccessToken

func (m *Memory) RemoveAccessToken(repoType, repoUser string) (bool, error)

RemoveAccessToken as function name described

func (*Memory) RemoveOrg

func (m *Memory) RemoveOrg(orgId int) (bool, error)

RemoveOrg as function name described

func (*Memory) RemoveProj

func (m *Memory) RemoveProj(projId int) (bool, error)

RemoveProj as function name described

func (*Memory) RemoveSource

func (m *Memory) RemoveSource(sourceId int) (bool, error)

RemoveSource as function name described

func (*Memory) String

func (m *Memory) String() string

String returns datastore as string

func (*Memory) UpdateOrg

func (m *Memory) UpdateOrg(org *Org) (bool, error)

UpdateOrg as function name described

func (*Memory) UpdateProj

func (m *Memory) UpdateProj(proj *Proj) (bool, error)

UpdateProj as function name described

func (*Memory) UpsertAccessToken

func (m *Memory) UpsertAccessToken(token *AccessToken) (bool, error)

UpsertAccessToken as function name described

type MySql

type MySql struct {
	EntryName        string                    `json:"entryName" yaml:"entryName"`
	EntryType        string                    `json:"entryType" yaml:"entryType"`
	EntryDescription string                    `json:"entryDescription" yaml:"entryDescription"`
	ZapLoggerEntry   *rkentry.ZapLoggerEntry   `json:"zapLoggerEntry" yaml:"zapLoggerEntry"`
	EventLoggerEntry *rkentry.EventLoggerEntry `json:"eventLoggerEntry" yaml:"eventLoggerEntry"`
	// contains filtered or unexported fields
}

MySql implements interface of DataStore whose underlying storage is MySQL DB

func RegisterMySql

func RegisterMySql(opts ...MySqlOption) *MySql

RegisterEntry will register Entry into GlobalAppCtx

func (*MySql) Bootstrap

func (m *MySql) Bootstrap(ctx context.Context)

Bootstrap will bootstrap datastore

func (*MySql) Connect

func (m *MySql) Connect() error

Connect to to remote/local provider

func (*MySql) CreateOrg

func (m *MySql) CreateOrg(org *Org) (bool, error)

CreateOrg as function name described

func (*MySql) CreateProj

func (m *MySql) CreateProj(proj *Proj) (bool, error)

CreateProj as function name described

func (*MySql) CreateSource

func (m *MySql) CreateSource(src *Source) (bool, error)

CreateSource as function name described

func (*MySql) GetAccessToken

func (m *MySql) GetAccessToken(repoType, repoUser string) (*AccessToken, error)

GetAccessToken as function name described

func (*MySql) GetDescription

func (m *MySql) GetDescription() string

GetDescription returns datastore entry description

func (*MySql) GetName

func (m *MySql) GetName() string

GetName returns datastore entry name

func (*MySql) GetOrg

func (m *MySql) GetOrg(orgId int) (*Org, error)

GetOrg as function name described

func (*MySql) GetProj

func (m *MySql) GetProj(projId int) (*Proj, error)

GetProj as function name described

func (*MySql) GetSource

func (m *MySql) GetSource(sourceId int) (*Source, error)

GetSource as function name described

func (*MySql) GetType

func (m *MySql) GetType() string

GetType returns datastore entry type

func (*MySql) Interrupt

func (m *MySql) Interrupt(ctx context.Context)

Interrupt will interrupt datastore

func (*MySql) IsHealthy

func (m *MySql) IsHealthy() bool

IsHealthy checks healthy status remote provider

func (*MySql) ListOrg

func (m *MySql) ListOrg() ([]*Org, error)

ListOrg as function name described

func (*MySql) ListPipelineTemplate

func (m *MySql) ListPipelineTemplate() ([]*PipelineTemplate, error)

ListPipelineTemplate as function name described

func (*MySql) ListProj

func (m *MySql) ListProj(orgId int) ([]*Proj, error)

ListProj as function name described

func (*MySql) RemoveAccessToken

func (m *MySql) RemoveAccessToken(repoType, repoUser string) (bool, error)

RemoveAccessToken as function name described

func (*MySql) RemoveOrg

func (m *MySql) RemoveOrg(orgId int) (bool, error)

RemoveOrg as function name described

func (*MySql) RemoveProj

func (m *MySql) RemoveProj(projId int) (bool, error)

RemoveProj as function name described

func (*MySql) RemoveSource

func (m *MySql) RemoveSource(sourceId int) (bool, error)

RemoveProj as function name described

func (*MySql) String

func (m *MySql) String() string

String returns datastore as string

func (*MySql) UpdateOrg

func (m *MySql) UpdateOrg(org *Org) (bool, error)

UpdateOrg as function name described

func (*MySql) UpdateProj

func (m *MySql) UpdateProj(proj *Proj) (bool, error)

UpdateProj as function name described

func (*MySql) UpsertAccessToken

func (m *MySql) UpsertAccessToken(token *AccessToken) (bool, error)

UpsertAccessToken as function name described

type MySqlOption

type MySqlOption func(*MySql)

DataStore will be extended in future.

func WithAddr

func WithAddr(addr string) MySqlOption

WithAddr provide address

func WithDatabase

func WithDatabase(database string) MySqlOption

WithDatabase provide database

func WithEnableMockDb

func WithEnableMockDb() MySqlOption

WithEnableMockDb enables mock DB

func WithNowFunc

func WithNowFunc(f func() time.Time) MySqlOption

WithNowFunc provides now functions for unit test

func WithParams

func WithParams(params []string) MySqlOption

WithParams provide params

func WithPass

func WithPass(pass string) MySqlOption

WithPass provide password

func WithProtocol

func WithProtocol(protocol string) MySqlOption

WithProtocol provide protocol

func WithUser

func WithUser(user string) MySqlOption

WithUser provide user

type NotFound

type NotFound struct {
	// contains filtered or unexported fields
}

func NewAlreadyExist

func NewAlreadyExist(msg string) *NotFound

func NewAlreadyExistf

func NewAlreadyExistf(format string, a ...interface{}) *NotFound

func NewNotFound

func NewNotFound(msg string) *NotFound

func NewNotFoundf

func NewNotFoundf(format string, a ...interface{}) *NotFound

func (*NotFound) Error

func (e *NotFound) Error() string

type Org

type Org struct {
	Base
	Id       int     `yaml:"id" json:"id" gorm:"primaryKey"`
	Name     string  `yaml:"name" json:"name"`
	ProjList []*Proj `yaml:"-" json:"-"`
}

Org defines organizations in workstation.

func NewOrg

func NewOrg(name string) *Org

NewOrg create a new organization with name. A new name will be assigned as the same as random Id if name is empty.

func (*Org) String

func (org *Org) String() string

String will marshal organization into json format.

type PipelineTemplate

type PipelineTemplate struct {
	Base
	Id       int    `yaml:"id" json:"id" gorm:"primaryKey"`
	Name     string `yaml:"name" json:"name"`
	Language string `yaml:"language" json:"language"`
	Content  string `yaml:"content" json:"content"`
}

type Proj

type Proj struct {
	Base
	Id      int     `yaml:"id" json:"id" gorm:"primaryKey"`
	OrgId   int     `yaml:"orgId" json:"orgId" gorm:"index"`
	OrgName string  `yaml:"orgName" json:"orgName" gorm:"index"`
	Name    string  `yaml:"name" json:"name" gorm:"index"`
	Source  *Source `yaml:"source" json:"source"`
}

Proj defines projects in workstation.

func NewProj

func NewProj(name string) *Proj

NewProject create a project with params. A new name will be assigned with random Id if name is empty.

func (*Proj) String

func (proj *Proj) String() string

String will marshal project into json format.

type Repository

type Repository interface {
	rkentry.Entry

	// Connect to to remote/local provider
	Connect() error

	// IsHealthy checks healthy status remote provider
	IsHealthy() bool

	// ListOrg as function name described
	ListOrg() ([]*Org, error)

	// CreateOrg as function name described
	CreateOrg(org *Org) (bool, error)

	// GetOrg as function name described
	GetOrg(int) (*Org, error)

	// RemoveOrg as function name described
	RemoveOrg(int) (bool, error)

	// UpdateOrg as function name described
	UpdateOrg(org *Org) (bool, error)

	// ListProj as function name described
	ListProj(int) ([]*Proj, error)

	// CreateProj as function name described
	CreateProj(proj *Proj) (bool, error)

	// GetProj as function name described
	GetProj(int) (*Proj, error)

	// RemoveProj as function name described
	RemoveProj(int) (bool, error)

	// UpdateProj as function name described
	UpdateProj(org *Proj) (bool, error)

	// CreateSource as function name described
	CreateSource(src *Source) (bool, error)

	// RemoveSource as function name described
	RemoveSource(int) (bool, error)

	// GetSource as function name described
	GetSource(int) (*Source, error)

	// UpsertAccessToken as function name described
	UpsertAccessToken(*AccessToken) (bool, error)

	// GetAccessToken as function name described
	GetAccessToken(repoType, repoUser string) (*AccessToken, error)

	// RemoveAccessToken as function name described
	RemoveAccessToken(string, string) (bool, error)

	// ListPipelineTemplate as function name described
	ListPipelineTemplate() ([]*PipelineTemplate, error)
}

func GetRepository

func GetRepository() Repository

type Source

type Source struct {
	Base
	Id         int    `yaml:"id" json:"id" gorm:"primaryKey"`
	ProjId     int    `yaml:"projId" json:"projId" gorm:"index"`
	Type       string `yaml:"type" json:"type" gorm:"index"`
	Repository string `yaml:"repository" json:"repository"`
	User       string `yaml:"user" json:"user"`
}

func NewSource

func NewSource(repoType, repository string) *Source

NewSource create a project with params. A new name will be assigned with random Id if name is empty.

func (*Source) String

func (src *Source) String() string

String will marshal source into json format.

Jump to

Keyboard shortcuts

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