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(encKey, encryptedText string) (string, errors.Error)
- func Encrypt(encKey, plainText string) (string, errors.Error)
- func FindPluginNameBySubPkgPath(subPkgPath string) (string, errors.Error)
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func RandLetterBytes(n int) string
- func RandomCapsStr(len int) string
- func RandomEncKey() string
- func RegisterPlugin(name string, plugin PluginMeta) errors.Error
- func TraversalPlugin(handle PluginCallBack) errors.Error
- type ApiResourceHandler
- type ApiResourceInput
- type ApiResourceOutput
- type BasicRes
- type BlueprintConnectionV100
- type BlueprintScopeV100
- type CloseablePluginTask
- type ConfigGetter
- type ExecContext
- type GrafanaDashboard
- type InjectConfigGetter
- type InjectLogger
- type LogLevel
- type Logger
- type LoggerConfig
- type LoggerStreamConfig
- type Migratable
- type OutputFile
- type PipelinePlan
- type PipelineStage
- type PipelineTask
- type PluginApi
- type PluginBlueprintV100
- type PluginCallBack
- type PluginDashboard
- type PluginIcon
- type PluginInit
- type PluginMeta
- type PluginModel
- type PluginTask
- type ProgressType
- type RunningProgress
- type SubTask
- type SubTaskContext
- type SubTaskEntryPoint
- type SubTaskMeta
- type Tabler
- type TaskContext
Constants ¶
const ( LOG_DEBUG = LogLevel(logrus.DebugLevel) LOG_INFO = LogLevel(logrus.InfoLevel) LOG_WARN = LogLevel(logrus.WarnLevel) LOG_ERROR = LogLevel(logrus.ErrorLevel) )
const DOMAIN_TYPE_CICD = "CICD"
const DOMAIN_TYPE_CODE = "CODE"
const DOMAIN_TYPE_CODE_REVIEW = "CODEREVIEW"
const DOMAIN_TYPE_CROSS = "CROSS"
const DOMAIN_TYPE_TICKET = "TICKET"
const EncodeKeyEnvStr = "ENCODE_KEY"
Variables ¶
var DOMAIN_TYPES = []string{ DOMAIN_TYPE_CODE, DOMAIN_TYPE_TICKET, DOMAIN_TYPE_CODE_REVIEW, DOMAIN_TYPE_CROSS, DOMAIN_TYPE_CICD, }
Functions ¶
func AllPlugins ¶
func AllPlugins() map[string]PluginMeta
func Encrypt ¶
TODO: maybe move encryption/decryption into helper? AES + Base64 encryption using ENCODE_KEY in .env as key
func RandLetterBytes ¶ added in v0.12.0
func RandomCapsStr ¶
A random string of length len uppercase characters
func RandomEncKey ¶
func RandomEncKey() string
func RegisterPlugin ¶
func RegisterPlugin(name string, plugin PluginMeta) errors.Error
func TraversalPlugin ¶ added in v0.13.0
func TraversalPlugin(handle PluginCallBack) errors.Error
Types ¶
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 }
Contains api request information
type ApiResourceOutput ¶
type ApiResourceOutput struct { Body interface{} // response body Status int File *OutputFile ContentType string }
Describe response data of a api
type BlueprintConnectionV100 ¶ added in v0.12.0
type BlueprintConnectionV100 struct { Plugin string `json:"plugin" validate:"required"` ConnectionId uint64 `json:"connectionId" validate:"required"` Scope []*BlueprintScopeV100 `json:"scope" validate:"required"` }
BlueprintConnectionV100 is the connection definition for protocol v1.0.0
type BlueprintScopeV100 ¶ added in v0.12.0
type BlueprintScopeV100 struct { Entities []string `json:"entities"` Options json.RawMessage `json:"options"` Transformation json.RawMessage `json:"transformation"` }
BlueprintScopeV100 is the scope definition for protocol v1.0.0
type CloseablePluginTask ¶ added in v0.12.0
type CloseablePluginTask interface { PluginTask Close(taskCtx TaskContext) errors.Error }
CloseablePluginTask Extends PluginTask, and invokes a Close method after all subtasks are done
type ConfigGetter ¶ added in v0.12.0
type ExecContext ¶
type ExecContext interface { 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 ¶ added in v0.14.0
type InjectConfigGetter ¶ added in v0.12.0
type InjectConfigGetter interface {
SetConfigGetter(getter ConfigGetter)
}
type InjectLogger ¶ added in v0.12.0
type InjectLogger interface {
SetLogger(logger Logger)
}
type Logger ¶
type Logger interface { IsLevelEnabled(level LogLevel) bool Printf(format string, a ...interface{}) Log(level LogLevel, format string, a ...interface{}) Debug(format string, a ...interface{}) Info(format string, a ...interface{}) // Warn logs a message. The err field can be left `nil`, otherwise the logger will format it into the message. Warn(err error, format string, a ...interface{}) // Error logs an error. The err field can be left `nil`, otherwise the logger will format it into the message. Error(err error, format string, a ...interface{}) // Nested return a new logger instance. `name` is the extra prefix to be prepended to each message. Leaving it blank // will add no additional prefix. The new Logger will inherit the properties of the original. Nested(name string) Logger // GetConfig Returns a copy of the LoggerConfig associated with this Logger. This is meant to be used by the framework. GetConfig() *LoggerConfig // SetStream sets the output of this Logger. This is meant to be used by the framework. SetStream(config *LoggerStreamConfig) }
Logger General logger interface, can be used anywhere
type LoggerConfig ¶ added in v0.13.0
LoggerConfig config related to the Logger. This needs to be serializable, so it can be passed around over the wire.
type LoggerStreamConfig ¶ added in v0.13.0
LoggerStreamConfig stream related config to set on a Logger
type Migratable ¶
type OutputFile ¶ added in v0.12.0
OutputFile is the file returned
type PipelinePlan ¶ added in v0.12.0
type PipelinePlan []PipelineStage
PipelinePlan consist of multiple PipelineStages, they will be executed in sequential order
type PipelineStage ¶ added in v0.12.0
type PipelineStage []*PipelineTask
PipelineStage consist of multiple PipelineTasks, they will be executed in parallel
type PipelineTask ¶ added in v0.12.0
type PipelineTask struct { // Plugin name Plugin string `json:"plugin" binding:"required"` Subtasks []string `json:"subtasks"` Options map[string]interface{} `json:"options"` }
PipelineTask represents a smallest unit of execution inside a PipelinePlan
type PluginApi ¶
type PluginApi interface {
ApiResources() map[string]map[string]ApiResourceHandler
}
Implement this interface if plugin offered API Code sample to register a api on `sources/:connectionId`:
func (plugin Jira) ApiResources() map[string]map[string]core.ApiResourceHandler { return map[string]map[string]core.ApiResourceHandler{ "connections/:connectionId": { "PUT": api.PutConnection, "DELETE": api.DeleteConnection, "GET": api.GetConnection, }, } }
type PluginBlueprintV100 ¶ added in v0.12.0
type PluginBlueprintV100 interface { // MakePipelinePlan generates `pipeline.tasks` based on `version` and `scope` // // `version` semver from `blueprint.settings.version` // `scope` arbitrary json.RawMessage, depends on `version`, for v0.0.1, it is an Array of Objects MakePipelinePlan(connectionId uint64, scope []*BlueprintScopeV100) (PipelinePlan, errors.Error) }
PluginBlueprint is used to support Blueprint Normal model
type PluginCallBack ¶ added in v0.13.0
type PluginCallBack func(name string, plugin PluginMeta) errors.Error
type PluginDashboard ¶ added in v0.14.0
type PluginDashboard interface {
Dashboards() []GrafanaDashboard
}
PluginDashboard return it's dashboard which should be display at grafana
type PluginIcon ¶ added in v0.14.0
type PluginIcon interface {
SvgIcon() string
}
PluginIcon return it's 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 }
Minimal features a plugin should comply, should be implemented by all plugins
type PluginModel ¶ added in v0.13.0
type PluginModel interface {
GetTablesInfo() []Tabler
}
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 ProgressType ¶
type ProgressType int
const ( TaskSetProgress ProgressType = iota TaskIncProgress SubTaskSetProgress SubTaskIncProgress SetCurrentSubTask )
type RunningProgress ¶
type RunningProgress struct { Type ProgressType Current int Total int SubTaskName string SubTaskNumber int }
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 }
SubTaskMeta Metadata of a subtask
type TaskContext ¶
type TaskContext interface { ExecContext SetData(data interface{}) SubTaskContext(subtask string) (SubTaskContext, errors.Error) }
TaskContext This interface define all resources that needed for task execution