minimin

package module
v0.0.0-...-66d3d26 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

README

minimin

一个小的CICD的SDK

Documentation

Index

Constants

View Source
const (
	Success Status = "SUCCESS" // 成功
	Fail    Status = "FAIL"    // 失败
	Run     Status = "RUNNING" // 运行中
	Init    Status = "INIT"    // 初始化
	Queue   Status = "QUEUE"   // 队列中

	SimpleFilePerm = 0666 // 普通文件权限
	SimpleDirPerm  = 0755 // 普通文件夹权限
	DangerPerm     = 0777 // 危险权限

	AppListFile    = "apps.json" // app列表存储文件名称
	EnvJsonFile    = ".env.json"
	ConfigYamlFile = "config.yaml"  // yaml配置文件名
	ConfigJsonFile = "config.json"  // json配置文件夹名
	InfoDir        = "info"         // 信息文件夹名
	RunLogJsonFile = "run_log.json" // json配置文件夹名
)

Variables

View Source
var (
	PATH = ""
)

Functions

func DockerBuild

func DockerBuild(obj DockerBuildParams) (err error)

func ExecCmd

func ExecCmd(theCmd *exec.Cmd) (err error)

func GetBasePath

func GetBasePath() string

GetBasePath 获取当前的路径

func GitPull

func GitPull(obj GitParams) (err error)

func InitStorage

func InitStorage(path string) (err error)

InitStorage 初始化存储路径

func ListSynthesis

func ListSynthesis(list []MP, cellSpace string) (err error)

func PathExist

func PathExist(path string) (res bool)

PathExist 路径存在

func SendEmail

func SendEmail(mailConf MailboxConf) (err error)

func Shell

func Shell(obj ShellParams) (err error)

Types

type App

type App struct {
	Project
	Name string `json:"name" yaml:"name"`
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
}

App app

func (*App) CancelApp

func (a *App) CancelApp(path string) (err error)

CancelApp 注销app

func (*App) Delete

func (a *App) Delete() (err error)

Delete 删除app

func (*App) GetConfigJson

func (a *App) GetConfigJson() (aac *AppAdminConfig, err error)

GetConfigJson 获取配置

func (*App) GetConfigYaml

func (a *App) GetConfigYaml() (mf *MinFile, err error)

GetConfigYaml 获取运行配置

func (*App) LoadConfigJsonByByte

func (a *App) LoadConfigJsonByByte(content []byte) (err error)

LoadConfigJsonByFile 通过文件加载配置(管理的json文件)

func (*App) LoadConfigJsonByFile

func (a *App) LoadConfigJsonByFile(path string) (err error)

LoadConfigJsonByFile 通过文件加载配置(管理的json文件)

func (*App) LoadConfigYamlByByte

func (a *App) LoadConfigYamlByByte(content []byte) (err error)

LoadConfigYamlByByte 通过内容加载配置(CI/CD运行使用的文件)

func (*App) LoadConfigYamlByFile

func (a *App) LoadConfigYamlByFile(path string) (err error)

LoadConfigYamlByFile 通过文件加载配置(CI/CD运行使用的文件)

func (*App) New

func (a *App) New() (err error)

New 新建app

func (*App) NewProductionLine

func (a *App) NewProductionLine(num int) (pl *DNA, err error)

NewProductionLine 新启动一条生产线

func (*App) RegisterApp

func (a *App) RegisterApp(path string) (err error)

RegisterApp 注册app

func (*App) Run

func (a *App) Run() (plObj *DNA, err error)

Run 运行app

type AppAdminConfig

type AppAdminConfig struct {
	MaxStorageDays  int `json:"max_storage_days,omitempty"`
	MaxStorageTimes int `json:"max_storage_times,omitempty"`
}

AppAdminConfig app管理的设置

type AppInfo

type AppInfo struct {
	Name string `json:"name"`
}

AppInfo app 信息

type AppList

type AppList map[string]AppInfo

AppList 每个工程目录下的appList

type DNA

type DNA struct {
	Num   string            `yaml:"-" json:"num"`
	Path  string            `yaml:"-" json:"path"`
	Env   map[string]string `yaml:"env" json:"env"`
	Genes []GeneForWork     `yaml:"genes" json:"genes"`
}

DNA 运行使用的最外层数据结构

func (*DNA) HandleMinFile

func (d *DNA) HandleMinFile(file MinFile) (err error)

HandleMinFile 配置文件转换到运行的结构体

func (*DNA) LoadMinFile

func (d *DNA) LoadMinFile() (minFile *MinFile, err error)

func (*DNA) Work

func (d *DNA) Work() (err error)

type DockerBuildParams

type DockerBuildParams struct {
	Name     string `json:"name"`
	Tag      string `json:"tag"`
	Cell     string `json:"-"`
	Repo     string `json:"repo"`
	User     string `json:"user"`
	Password string `json:"password"`
	HubAddr  string `json:"hub_addr,omitempty"`
}

type Gene

type Gene struct {
	Name   string `yaml:"name" json:"name"`
	MPs    []MP   `yaml:"MPs" json:"MPs"`
	Ignore bool   `yaml:"ignore,omitempty" json:"ignore,omitempty"`
	When   string `yaml:"when,omitempty" json:"when,omitempty"`
}

Gene (基因)解析文件产生的对应顺序

type GeneForWork

type GeneForWork struct {
	Name   string      `yaml:"name" json:"name"`
	MPs    []MPForWork `yaml:"MPs" json:"MPs"`
	Ignore bool        `yaml:"ignore,omitempty" json:"ignore,omitempty"`
	When   string      `yaml:"when,omitempty" json:"when,omitempty"`
	Status Status      `yaml:"status" json:"status"`
}

GeneForWork (基因)实际运行使用的阶段级别的数据结构

type GitParams

type GitParams struct {
	URL       string `yaml:"url" json:"url"`
	User      string `yaml:"user;omitempty" json:"user;omitempty"`
	Password  string `yaml:"password;omitempty" json:"password;omitempty"`
	SecretKey string `yaml:"secret_key;omitempty" json:"secret_key;omitempty"`
	Alias     string `yaml:"alias;omitempty" json:"alias;omitempty"`
	Cell      string `yaml:"-" json:"-"`
}

type MP

type MP struct {
	Name        string            `yaml:"name" json:"name"`
	Description string            `yaml:"description,omitempty" json:"description,omitempty"`
	AminoAcid   string            `yaml:"amino_acid" json:"amino_acid"`
	Chain       string            `yaml:"chain,omitempty" json:"chain,omitempty"`
	Params      map[string]string `yaml:"params,omitempty" json:"params,omitempty"`
	Ignore      bool              `yaml:"ignore,omitempty" json:"ignore,omitempty"`
	When        string            `yaml:"when,omitempty" json:"when,omitempty"`
	Status      Status            `yaml:"-" json:"status,omitempty"`
}

MP 最小的单位,CI/CD最小的执行单位

func (*MP) SetStatus

func (mp *MP) SetStatus(status Status)

func (*MP) Synthesis

func (mp *MP) Synthesis(cellSpace string) (status string, err error)

type MPForWork

type MPForWork struct {
	Single *MP
	Multi  map[string][]MP
}

MPForWork 支线或单点

func HandleMPs

func HandleMPs(MPList []MP) (MPB []MPForWork)

HandleMPs 处理处理单元

type MailboxConf

type MailboxConf struct {
	Sender    string `json:"sender"`
	SMTPPort  int
	SPassword string
	SMTPAddr  string
	Title     string `json:"title"`     // 邮件标题
	Body      string `json:"body"`      // 邮件内容
	Addressee string `json:"addressee"` // 收件人列表
}

MailboxConf 邮箱配置

type MinFile

type MinFile struct {
	Name  string            `yaml:"name" json:"name"`
	Env   map[string]string `yaml:"env" json:"env"`
	Genes []Gene            `yaml:"genes" json:"genes"`
}

MinFile 配置文件结构

func YamlLoad

func YamlLoad(path string) (anriFile *MinFile, err error)

YamlLoad 读取配置文件(yaml)类型

func YamlLoadByByte

func YamlLoadByByte(content []byte) (anriFile *MinFile, err error)

YamlLoadByByte 读取配置文件

type MiniMin

type MiniMin struct {
	Queue    []DNA `json:"queue"`
	Capacity int   `json:"capacity"`
	Len      int   `json:"len"`
}

type Project

type Project struct {
	Name string `json:"name" yaml:"name"`
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
}

Project 工程

func (*Project) Delete

func (p *Project) Delete() (err error)

Delete 删除工程

func (*Project) GetApp

func (p *Project) GetApp(name string) (a *App, err error)

GetApp 获取app

func (*Project) GetPath

func (p *Project) GetPath()

func (*Project) New

func (p *Project) New() (err error)

New 新建工程

func (*Project) NewApp

func (p *Project) NewApp(name string) (a *App, err error)

NewApp 新建app

type RunLogJson

type RunLogJson struct {
	Num       int          `json:"num"`
	StartTime sql.NullTime `json:"start_time"`
	EndTime   sql.NullTime `json:"end_time"`
	Status    Status       `json:"status"`
}

RunLogJson 运行记录的json记录文件

type ShellParams

type ShellParams struct {
	Cmd string `json:"cmd"`
}

type Status

type Status string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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