core

package
v0.12.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DOMAIN_TYPE_CICD = "CICD"
View Source
const DOMAIN_TYPE_CODE = "CODE"
View Source
const DOMAIN_TYPE_CODE_REVIEW = "CODEREVIEW"
View Source
const DOMAIN_TYPE_CROSS = "CROSS"
View Source
const DOMAIN_TYPE_TICKET = "TICKET"
View Source
const EncodeKeyEnvStr = "ENCODE_KEY"

Variables

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte) ([]byte, error)

AES decryption

func AesEncrypt

func AesEncrypt(origData, key []byte) ([]byte, error)

AES encryption, CBC

func AllPlugins

func AllPlugins() map[string]PluginMeta

func Decrypt

func Decrypt(encKey, encryptedText string) (string, error)

Base64 + AES decryption using ENCODE_KEY in .env as key

func Encrypt

func Encrypt(encKey, plainText string) (string, error)

TODO: maybe move encryption/decryption into helper? AES + Base64 encryption using ENCODE_KEY in .env as key

func FindPluginNameBySubPkgPath

func FindPluginNameBySubPkgPath(subPkgPath string) (string, error)

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

PKCS7 padding

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

PKCS7 unPadding

func RandLetterBytes added in v0.12.0

func RandLetterBytes(n int) string

func RandomCapsStr

func RandomCapsStr(len int) string

A random string of length len uppercase characters

func RandomEncKey

func RandomEncKey() string

func RegisterPlugin

func RegisterPlugin(name string, plugin PluginMeta) error

Types

type ApiResourceHandler

type ApiResourceHandler func(input *ApiResourceInput) (*ApiResourceOutput, 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
}

Describe response data of a api

type BasicRes added in v0.12.0

type BasicRes interface {
	GetConfig(name string) string
	GetLogger() Logger
	// Deprecated: use dal instead
	GetDb() *gorm.DB
	GetDal() dal.Dal
}

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) error
}

Extends PluginTask, and invokes a Close method after all subtasks are done

type ConfigGetter added in v0.12.0

type ConfigGetter interface {
	GetString(name string) string
}

type ExecContext

type ExecContext interface {
	BasicRes
	GetName() string
	GetContext() context.Context
	GetData() interface{}
	SetProgress(current int, total int)
	IncProgress(quantity int)
}

This interface define all resources that needed for task/subtask execution

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 LogLevel

type LogLevel logrus.Level

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(format string, a ...interface{})
	Error(format string, a ...interface{})
	// return a new logger which output nested log
	Nested(name string) Logger
}

General logger interface, can be used any where

type Migratable

type Migratable interface {
	MigrationScripts() []migration.Script
}

type OutputFile added in v0.12.0

type OutputFile struct {
	ContentType string
	Data        []byte
}

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, error)
}

PluginBlueprint is used to support Blueprint Normal model

type PluginInit

type PluginInit interface {
	Init(config *viper.Viper, logger Logger, db *gorm.DB) error
}

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

func GetPlugin

func GetPlugin(name string) (PluginMeta, error)

type PluginTask

type PluginTask interface {
	// return all available subtasks, framework will run them for you in order
	SubTaskMetas() []SubTaskMeta
	// based on task context and user input options, return data that shared among all subtasks
	PrepareTaskData(taskCtx TaskContext, options map[string]interface{}) (interface{}, error)
}

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 SubTask

type SubTask interface {
	// Execute FIXME ...
	Execute() error
}

type SubTaskContext

type SubTaskContext interface {
	ExecContext
	TaskContext() TaskContext
}

This interface define all resources that needed for subtask execution

type SubTaskEntryPoint

type SubTaskEntryPoint func(c SubTaskContext) error

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
}

Meta data of a subtask

type TaskContext

type TaskContext interface {
	ExecContext
	SetData(data interface{})
	SubTaskContext(subtask string) (SubTaskContext, error)
}

This interface define all resources that needed for task execution

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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