Documentation ¶
Index ¶
- Constants
- func RegisterRepositoryFromConfig(configFilePath string) map[string]rkentry.Entry
- type AccessToken
- type AlreadyExist
- type Base
- type BootConfig
- type Memory
- func (m *Memory) Bootstrap(ctx context.Context)
- func (m *Memory) Connect() error
- func (m *Memory) CreateOrg(org *Org) (bool, error)
- func (m *Memory) CreateProj(proj *Proj) (bool, error)
- func (m *Memory) CreateSource(src *Source) (bool, error)
- func (m *Memory) GetAccessToken(repoType, repoUser string) (*AccessToken, error)
- func (m *Memory) GetDescription() string
- func (m *Memory) GetName() string
- func (m *Memory) GetOrg(orgId int) (*Org, error)
- func (m *Memory) GetProj(projId int) (*Proj, error)
- func (m *Memory) GetSource(sourceId int) (*Source, error)
- func (m *Memory) GetType() string
- func (m *Memory) Interrupt(ctx context.Context)
- func (m *Memory) IsHealthy() bool
- func (m *Memory) ListOrg() ([]*Org, error)
- func (m *Memory) ListPipelineTemplate() ([]*PipelineTemplate, error)
- func (m *Memory) ListProj(orgId int) ([]*Proj, error)
- func (m *Memory) RemoveAccessToken(repoType, repoUser string) (bool, error)
- func (m *Memory) RemoveOrg(orgId int) (bool, error)
- func (m *Memory) RemoveProj(projId int) (bool, error)
- func (m *Memory) RemoveSource(sourceId int) (bool, error)
- func (m *Memory) String() string
- func (m *Memory) UpdateOrg(org *Org) (bool, error)
- func (m *Memory) UpdateProj(proj *Proj) (bool, error)
- func (m *Memory) UpsertAccessToken(token *AccessToken) (bool, error)
- type MySql
- func (m *MySql) Bootstrap(ctx context.Context)
- func (m *MySql) Connect() error
- func (m *MySql) CreateOrg(org *Org) (bool, error)
- func (m *MySql) CreateProj(proj *Proj) (bool, error)
- func (m *MySql) CreateSource(src *Source) (bool, error)
- func (m *MySql) GetAccessToken(repoType, repoUser string) (*AccessToken, error)
- func (m *MySql) GetDescription() string
- func (m *MySql) GetName() string
- func (m *MySql) GetOrg(orgId int) (*Org, error)
- func (m *MySql) GetProj(projId int) (*Proj, error)
- func (m *MySql) GetSource(sourceId int) (*Source, error)
- func (m *MySql) GetType() string
- func (m *MySql) Interrupt(ctx context.Context)
- func (m *MySql) IsHealthy() bool
- func (m *MySql) ListOrg() ([]*Org, error)
- func (m *MySql) ListPipelineTemplate() ([]*PipelineTemplate, error)
- func (m *MySql) ListProj(orgId int) ([]*Proj, error)
- func (m *MySql) RemoveAccessToken(repoType, repoUser string) (bool, error)
- func (m *MySql) RemoveOrg(orgId int) (bool, error)
- func (m *MySql) RemoveProj(projId int) (bool, error)
- func (m *MySql) RemoveSource(sourceId int) (bool, error)
- func (m *MySql) String() string
- func (m *MySql) UpdateOrg(org *Org) (bool, error)
- func (m *MySql) UpdateProj(proj *Proj) (bool, error)
- func (m *MySql) UpsertAccessToken(token *AccessToken) (bool, error)
- type MySqlOption
- func WithAddr(addr string) MySqlOption
- func WithDatabase(database string) MySqlOption
- func WithEnableMockDb() MySqlOption
- func WithNowFunc(f func() time.Time) MySqlOption
- func WithParams(params []string) MySqlOption
- func WithPass(pass string) MySqlOption
- func WithProtocol(protocol string) MySqlOption
- func WithUser(user string) MySqlOption
- type NotFound
- type Org
- type PipelineTemplate
- type Proj
- type Repository
- type Source
Constants ¶
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" )
const (
// EntryNameDefault default entry name
EntryNameDefault = "datastore"
)
Variables ¶
This section is empty.
Functions ¶
func RegisterRepositoryFromConfig ¶
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) CreateProj ¶
CreateProj as function name described
func (*Memory) CreateSource ¶
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 ¶
GetDescription returns datastore entry description
func (*Memory) ListPipelineTemplate ¶
func (m *Memory) ListPipelineTemplate() ([]*PipelineTemplate, error)
func (*Memory) RemoveAccessToken ¶
RemoveAccessToken as function name described
func (*Memory) RemoveProj ¶
RemoveProj as function name described
func (*Memory) RemoveSource ¶
RemoveSource as function name described
func (*Memory) UpdateProj ¶
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) CreateProj ¶
CreateProj as function name described
func (*MySql) CreateSource ¶
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 ¶
GetDescription returns datastore entry description
func (*MySql) ListPipelineTemplate ¶
func (m *MySql) ListPipelineTemplate() ([]*PipelineTemplate, error)
ListPipelineTemplate as function name described
func (*MySql) RemoveAccessToken ¶
RemoveAccessToken as function name described
func (*MySql) RemoveProj ¶
RemoveProj as function name described
func (*MySql) RemoveSource ¶
RemoveProj as function name described
func (*MySql) UpdateProj ¶
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 WithNowFunc ¶
func WithNowFunc(f func() time.Time) MySqlOption
WithNowFunc provides now functions for unit test
type NotFound ¶
type NotFound struct {
// contains filtered or unexported fields
}
func NewAlreadyExist ¶
func NewAlreadyExistf ¶
func NewNotFound ¶
func NewNotFoundf ¶
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.
type PipelineTemplate ¶
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.
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"` }