Documentation
¶
Index ¶
- Constants
- Variables
- func AesDecrypt(crypted, key []byte) ([]byte, errors.Error)
- func AesEncrypt(origData, key []byte) ([]byte, errors.Error)
- func AllPlugins() map[string]PluginMeta
- func Decrypt(encryptionSecret, encryptedText string) (string, errors.Error)
- func Encrypt(encryptionSecret, plainText string) (string, errors.Error)
- func FindPluginNameBySubPkgPath(subPkgPath string) (string, errors.Error)
- func InitPlugins(basicRes context.BasicRes)
- func MarshalScopeParams(params interface{}) string
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func RandomEncryptionSecret() (string, errors.Error)
- func RegisterPlugin(name string, plugin PluginMeta) errors.Error
- func TraversalPlugin(handle PluginCallBack) errors.Error
- func WrapTestConnectionErrResp(basicRes context.BasicRes, err errors.Error) errors.Error
- type AccessTokenAuthenticator
- type ApiAsyncCallback
- type ApiAuthenticator
- type ApiClient
- type ApiClientAfterResponse
- type ApiClientBeforeRequest
- type ApiConnection
- type ApiGroup
- type ApiResourceHandler
- type ApiResourceInput
- type ApiResourceOutput
- type ApiScope
- type AppKeyAuthenticator
- type BasicAuthenticator
- type CacheableConnection
- type CloseablePluginTask
- type CompositeDataSourcePluginBlueprintV200
- type CompositeMetricPluginBlueprintV200
- type CompositePluginBlueprintV200
- type CompositeProjectMapper
- type ConnectionValidator
- type DataSourcePluginBlueprintV200
- type ExecContext
- type GrafanaDashboard
- type MetricPluginBlueprintV200
- type MigrationScript
- type Migrator
- type MultiAuthenticator
- type OutputFile
- type PluginApi
- type PluginCallBack
- type PluginDashboard
- type PluginIcon
- type PluginInit
- type PluginMeta
- type PluginMetric
- type PluginMigration
- type PluginModel
- type PluginOpenApiSpec
- type PluginSource
- type PluginTask
- type PrepareApiClient
- type ProgressType
- type ProjectMapper
- type RunningProgress
- type Scope
- type SubTask
- type SubTaskContext
- type SubTaskEntryPoint
- type SubTaskMeta
- type TaskContext
- type ToolLayerApiConnection
- type ToolLayerConnection
- type ToolLayerScope
- type ToolLayerScopeConfig
Constants ¶
const ( AUTH_METHOD_BASIC = "BasicAuth" AUTH_METHOD_TOKEN = "AccessToken" AUTH_METHOD_APPKEY = "AppKey" )
MultiAuth
const DOMAIN_TYPE_CICD = "CICD" //nolint
const DOMAIN_TYPE_CODE = "CODE" //nolint
const DOMAIN_TYPE_CODE_QUALITY = "CODEQUALITY" //nolint
const DOMAIN_TYPE_CODE_REVIEW = "CODEREVIEW" //nolint
const DOMAIN_TYPE_CROSS = "CROSS" //nolint
const DOMAIN_TYPE_TICKET = "TICKET" //nolint
const EncodeKeyEnvStr = "ENCRYPTION_SECRET"
Variables ¶
var ALL_AUTH = map[string]bool{ AUTH_METHOD_BASIC: true, AUTH_METHOD_TOKEN: true, AUTH_METHOD_APPKEY: true, }
var DOMAIN_TYPES = []string{ DOMAIN_TYPE_CODE, DOMAIN_TYPE_TICKET, DOMAIN_TYPE_CODE_REVIEW, DOMAIN_TYPE_CROSS, DOMAIN_TYPE_CICD, DOMAIN_TYPE_CODE_QUALITY, } //nolint
Functions ¶
func AesDecrypt ¶
AesDecrypt AES decryption
func AesEncrypt ¶
AesEncrypt AES encryption, CBC
func AllPlugins ¶
func AllPlugins() map[string]PluginMeta
func Encrypt ¶
TODO: maybe move encryption/decryption into helper? AES + Base64 encryption using ENCRYPTION_SECRET in .env as key
func InitPlugins ¶
func MarshalScopeParams ¶
func MarshalScopeParams(params interface{}) string
func PKCS7Padding ¶
PKCS7Padding PKCS7 padding
func RandomEncryptionSecret ¶
RandomEncryptionSecret will return a random string of length 128
func RegisterPlugin ¶
func RegisterPlugin(name string, plugin PluginMeta) errors.Error
func TraversalPlugin ¶
func TraversalPlugin(handle PluginCallBack) errors.Error
Types ¶
type AccessTokenAuthenticator ¶
type AccessTokenAuthenticator interface {
GetAccessTokenAuthenticator() ApiAuthenticator
}
AccessTokenAuthenticator represents HTTP Bearer Authentication with Access Token
type ApiAsyncCallback ¶
ApiAsyncCallback FIXME ...
type ApiAuthenticator ¶
type ApiAuthenticator interface {
// SetupAuthentication is a hook function for connection to set up authentication for the HTTP request
// before sending it to the server
SetupAuthentication(request *http.Request) errors.Error
}
ApiAuthenticator is to be implemented by a Concreate Connection if Authorization is required
type ApiClient ¶
type ApiClient interface {
SetData(name string, data interface{})
GetData(name string) interface{}
SetHeaders(headers map[string]string)
SetBeforeFunction(callback ApiClientBeforeRequest)
GetBeforeFunction() ApiClientBeforeRequest
SetAfterFunction(callback ApiClientAfterResponse)
GetAfterFunction() ApiClientAfterResponse
Get(path string, query url.Values, headers http.Header) (*http.Response, errors.Error)
Post(path string, query url.Values, body interface{}, headers http.Header) (*http.Response, errors.Error)
}
ApiClientAbstract defines the functionalities needed by all plugins for Synchronized API Request
type ApiClientAfterResponse ¶
ApiClientAfterResponse FIXME ...
type ApiClientBeforeRequest ¶
ApiClientBeforeRequest FIXME ...
type ApiConnection ¶
ApiConnection represents a API Connection
type ApiResourceHandler ¶
type ApiResourceHandler func(input *ApiResourceInput) (*ApiResourceOutput, errors.Error)
type ApiResourceInput ¶
type ApiResourceInput struct {
Params map[string]string // path variables
Query url.Values // query string
Body map[string]interface{} // json body
Request *http.Request
User *common.User
}
ApiResourceInput Contains api request information
func (*ApiResourceInput) GetPlugin ¶
func (input *ApiResourceInput) GetPlugin() string
GetPlugin get the plugin in context
type ApiResourceOutput ¶
type ApiResourceOutput struct {
Body interface{} // response body
Status int
File *OutputFile
ContentType string
Header http.Header // optional response header
}
ApiResourceOutput Describe response data of a api
type ApiScope ¶
type ApiScope interface {
ConvertApiScope() ToolLayerScope
}
type AppKeyAuthenticator ¶
type AppKeyAuthenticator interface {
GetAppKeyAuthenticator() ApiAuthenticator
}
AppKeyAuthenticator represents the API Key and Secret authentication mechanism
type BasicAuthenticator ¶
type BasicAuthenticator interface {
GetBasicAuthenticator() ApiAuthenticator
}
BasicAuthenticator represents HTTP Basic Authentication
type CacheableConnection ¶
type CacheableConnection interface {
ApiConnection
GetHash() string
}
type CloseablePluginTask ¶
type CloseablePluginTask interface {
PluginTask
Close(taskCtx TaskContext) errors.Error
}
CloseablePluginTask Extends PluginTask, and invokes a Close method after all subtasks are done or fail
type CompositeDataSourcePluginBlueprintV200 ¶
type CompositeDataSourcePluginBlueprintV200 interface {
PluginMeta
DataSourcePluginBlueprintV200
}
CompositeDataSourcePluginBlueprintV200 is for unit test
type CompositeMetricPluginBlueprintV200 ¶
type CompositeMetricPluginBlueprintV200 interface {
PluginMeta
MetricPluginBlueprintV200
}
CompositeMetricPluginBlueprintV200 is for unit test
type CompositePluginBlueprintV200 ¶
type CompositePluginBlueprintV200 interface {
PluginMeta
DataSourcePluginBlueprintV200
MetricPluginBlueprintV200
}
CompositePluginBlueprintV200 is for unit test
type CompositeProjectMapper ¶
type CompositeProjectMapper interface {
PluginMeta
ProjectMapper
}
CompositeProjectMapper is for unit test
type ConnectionValidator ¶
type ConnectionValidator interface {
ValidateConnection(connection interface{}, validator *validator.Validate) errors.Error
}
TODO: deprecated, remove ConnectionValidator represents the API Connection would validate its fields with customized logic
type DataSourcePluginBlueprintV200 ¶
type DataSourcePluginBlueprintV200 interface {
MakeDataSourcePipelinePlanV200(
connectionId uint64,
scopes []*models.BlueprintScope,
) (models.PipelinePlan, []Scope, errors.Error)
}
DataSourcePluginBlueprintV200 extends the V100 to provide support for Project, so that complex metrics like DORA can be implemented based on a set of Data Scopes
type ExecContext ¶
type ExecContext interface {
corecontext.BasicRes
GetName() string
GetContext() context.Context
GetData() interface{}
SetProgress(current int, total int)
IncProgress(quantity int)
}
ExecContext This interface define all resources that needed for task/subtask execution
type GrafanaDashboard ¶
type MetricPluginBlueprintV200 ¶
type MetricPluginBlueprintV200 interface {
MakeMetricPluginPipelinePlanV200(projectName string, options json.RawMessage) (models.PipelinePlan, errors.Error)
}
MetricPluginBlueprintV200 is similar to the DataSourcePluginBlueprintV200 but for Metric Plugin, take dora as an example, it doens't have any scope, nor does it produce any, however, it does require other plugin to be executed beforehand, like calcuating refdiff before it can connect PR to the right Deployment keep in mind it would be called IFF the plugin was enabled for the project.
type MigrationScript ¶
type MigrationScript interface {
Up(basicRes context.BasicRes) errors.Error
Version() uint64
Name() string
}
MigrationScript upgrades database to a newer version
type Migrator ¶
type Migrator interface {
Register(scripts []MigrationScript, comment string)
Execute() errors.Error
HasPendingScripts() bool
}
Migrator is responsible for making sure the registered scripts get applied to database and only once
type MultiAuthenticator ¶
type MultiAuthenticator interface {
GetAuthMethod() string
}
MultiAuthenticator represents the API Connection supports multiple authorization methods
type OutputFile ¶
OutputFile is the file returned
type PluginApi ¶
type PluginApi interface {
ApiResources() map[string]map[string]ApiResourceHandler
}
PluginApi: Implement this interface if plugin offered API Code sample to register a api on `sources/:connectionId`:
func (p Jira) ApiResources() map[string]map[string]plugin.ApiResourceHandler {
return map[string]map[string]plugin.ApiResourceHandler{
"connections/:connectionId": {
"PUT": api.PutConnection,
"DELETE": api.DeleteConnection,
"GET": api.GetConnection,
},
}
}
type PluginCallBack ¶
type PluginCallBack func(name string, plugin PluginMeta) errors.Error
type PluginDashboard ¶
type PluginDashboard interface {
Dashboards() []GrafanaDashboard
}
PluginDashboard return its dashboard which should be display at grafana
type PluginIcon ¶
type PluginIcon interface {
SvgIcon() string
}
PluginIcon return its icon (.svg text)
type PluginInit ¶
PluginInit Implement this interface if plugin needed some initialization
type PluginMeta ¶
type PluginMeta interface {
Description() string
// PkgPath information lost when compiled as plugin(.so)
RootPkgPath() string
Name() string
}
PluginMeta is the Minimal features a plugin should comply, should be implemented by all plugins
type PluginMetric ¶
type PluginMetric interface {
// returns a list of required data entities and expected features.
// [{ "model": "cicd_tasks", "requiredFields": {"column": "type", "execptedValue": "Deployment"}}, ...]
RequiredDataEntities() (data []map[string]interface{}, err errors.Error)
// returns if the metric depends on Project for calculation.
// Currently, only dora would return true.
IsProjectMetric() bool
// indicates which plugins must be executed before executing this one.
// declare a set of dependencies with this
RunAfter() ([]string, errors.Error)
// returns an empty pointer of the plugin setting struct.
// (no concrete usage at this point)
Settings() (p interface{})
}
type PluginMigration ¶
type PluginMigration interface {
MigrationScripts() []MigrationScript
}
PluginMigration is implemented by the plugin to declare all migration script that have to be applied to the database
type PluginModel ¶
type PluginOpenApiSpec ¶
type PluginOpenApiSpec interface {
OpenApiSpec() string
}
PluginApiSpec let a plugin document its API with an OpenAPI spec. This is useful for remote plugins because whose standardized API spec template need to be instantiated with remote plugin's specific schemas, something that is not supported by swaggo.
type PluginSource ¶
type PluginSource interface {
Connection() dal.Tabler
Scope() ToolLayerScope
ScopeConfig() dal.Tabler
}
PluginSource abstracts data sources
type PluginTask ¶
type PluginTask interface {
// SubTaskMetas return all available subtasks, framework will run them for you in order
SubTaskMetas() []SubTaskMeta
// PrepareTaskData based on task context and user input options, return data that shared among all subtasks
PrepareTaskData(taskCtx TaskContext, options map[string]interface{}) (interface{}, errors.Error)
}
PluginTask Implement this interface to let framework run tasks for you
type PrepareApiClient ¶
PrepareApiClient is to be implemented by the concrete Connection which requires preparation for the ApiClient created by NewApiClientFromConnection, i.e. fetch token for future requests
type ProgressType ¶
type ProgressType int
const ( TaskSetProgress ProgressType = iota TaskIncProgress SubTaskSetProgress SubTaskIncProgress SetCurrentSubTask )
type ProjectMapper ¶
type ProjectMapper interface {
MapProject(projectName string, scopes []Scope) (models.PipelinePlan, errors.Error)
}
ProjectMapper is implemented by the plugin org, which binding project and scopes
type RunningProgress ¶
type Scope ¶
Scope represents the top level entity for a data source, i.e. github repo, gitlab project, jira board. They turn into repo, board in Domain Layer. In Apache Devlake, a Project is essentially a set of these top level entities, for the framework to maintain these relationships dynamically and automatically, all Domain Layer Top Level Entities should implement this interface
type SubTaskContext ¶
type SubTaskContext interface {
ExecContext
TaskContext() TaskContext
}
SubTaskContext This interface define all resources that needed for subtask execution
type SubTaskEntryPoint ¶
type SubTaskEntryPoint func(c SubTaskContext) errors.Error
SubTaskEntryPoint All subtasks from plugins should comply to this prototype, so they could be orchestrated by framework
type SubTaskMeta ¶
type SubTaskMeta struct {
Name string
EntryPoint SubTaskEntryPoint
// Required SubTask will be executed no matter what
Required bool
EnabledByDefault bool
Description string
DomainTypes []string
Dependencies []*SubTaskMeta
DependencyTables []string
ProductTables []string
ForceRunOnResume bool // Should a subtask be ran dispite it was finished before
}
SubTaskMeta Metadata of a subtask
type TaskContext ¶
type TaskContext interface {
ExecContext
SetData(data interface{})
SetSyncPolicy(syncPolicy *models.SyncPolicy)
SyncPolicy() *models.SyncPolicy
SubTaskContext(subtask string) (SubTaskContext, errors.Error)
}
TaskContext This interface define all resources that needed for task execution
type ToolLayerApiConnection ¶
type ToolLayerApiConnection interface {
ApiConnection
ToolLayerConnection
}