rainbond: github.com/goodrain/rainbond/builder/exector Index | Files

package exector

import "github.com/goodrain/rainbond/builder/exector"

Index

Package Files

build_from_image_run.go build_from_market_slug.go build_from_sourcecode_run.go exector.go export_app.go groupapp_backup.go groupapp_restore.go import_app.go plugin_dockerfile.go plugin_image.go service_check.go share_image.go share_plugin.go share_slug.go worker.go

Constants

const (
    // OldMetadata identify older versions of metadata
    OldMetadata = "OldMetadata"
    // NewMetadata identify new version of metadata
    NewMetadata = "NewMetadata"
)

Variables

var ErrCallback = fmt.Errorf("callback task to mq")

ErrCallback do not handle this task

var MetricBackTaskNum float64

MetricBackTaskNum back task number

var MetricErrorTaskNum float64

MetricErrorTaskNum error run task number

var MetricTaskNum float64

MetricTaskNum task number

func GetServiceType Uses

func GetServiceType(labels []*dbmodel.TenantServiceLable) string

GetServiceType get service deploy type

func GetVolumeDir Uses

func GetVolumeDir() (string, string)

GetVolumeDir get volume path prifix

func RegisterWorker Uses

func RegisterWorker(name string, fun func([]byte, *exectorManager) (TaskWorker, error))

RegisterWorker register worker creater

type AppSnapshot Uses

type AppSnapshot struct {
    Services            []*RegionServiceSnapshot
    Plugins             []*dbmodel.TenantPlugin
    PluginBuildVersions []*dbmodel.TenantPluginBuildVersion
}

AppSnapshot holds a snapshot of your app

type BackupAPPNew Uses

type BackupAPPNew struct {
    GroupID      string   `json:"group_id" `
    ServiceIDs   []string `json:"service_ids" `
    Version      string   `json:"version"`
    EventID      string
    SourceDir    string `json:"source_dir"`
    SourceType   string `json:"source_type"`
    BackupID     string `json:"backup_id"`
    BackupSize   int64
    Logger       event.Logger
    DockerClient *client.Client

    //full-online,full-offline
    Mode     string `json:"mode"`
    S3Config struct {
        Provider   string `json:"provider"`
        Endpoint   string `json:"endpoint"`
        AccessKey  string `json:"access_key"`
        SecretKey  string `json:"secret_key"`
        BucketName string `json:"bucket_name"`
    }   `json:"s3_config"`
}

BackupAPPNew backup group app new version

func (*BackupAPPNew) ErrorCallBack Uses

func (b *BackupAPPNew) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*BackupAPPNew) GetLogger Uses

func (b *BackupAPPNew) GetLogger() event.Logger

GetLogger GetLogger

func (*BackupAPPNew) Name Uses

func (b *BackupAPPNew) Name() string

Name return worker name

func (*BackupAPPNew) Run Uses

func (b *BackupAPPNew) Run(timeout time.Duration) error

Run Run

func (*BackupAPPNew) Stop Uses

func (b *BackupAPPNew) Stop() error

Stop stop

type BackupAPPRestore Uses

type BackupAPPRestore struct {
    //full-online,full-offline
    EventID  string
    BackupID string `json:"backup_id"`
    TenantID string `json:"tenant_id"`
    Logger   event.Logger
    //RestoreMode(cdct) current datacenter and current tenant
    //RestoreMode(cdot) current datacenter and other tenant
    //RestoreMode(od)     other datacenter
    RestoreMode  string `json:"restore_mode"`
    RestoreID    string `json:"restore_id"`
    DockerClient *client.Client

    S3Config struct {
        Provider   string `json:"provider"`
        Endpoint   string `json:"endpoint"`
        AccessKey  string `json:"access_key"`
        SecretKey  string `json:"secret_key"`
        BucketName string `json:"bucket_name"`
    }   `json:"s3_config"`
    // contains filtered or unexported fields
}

BackupAPPRestore restrore the group app backup

func (*BackupAPPRestore) ErrorCallBack Uses

func (b *BackupAPPRestore) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*BackupAPPRestore) GetLogger Uses

func (b *BackupAPPRestore) GetLogger() event.Logger

GetLogger GetLogger

func (*BackupAPPRestore) Name Uses

func (b *BackupAPPRestore) Name() string

Name return worker name

func (*BackupAPPRestore) Run Uses

func (b *BackupAPPRestore) Run(timeout time.Duration) error

Run Run

func (*BackupAPPRestore) Stop Uses

func (b *BackupAPPRestore) Stop() error

Stop stop

type Commit Uses

type Commit struct {
    Hash    string
    Author  string
    Message string
}

Commit code Commit

type DockerComposeYaml Uses

type DockerComposeYaml struct {
    Version  string              `yaml:"version"`
    Volumes  map[string]string   `yaml:"volumes,omitempty"`
    Services map[string]*Service `yaml:"services,omitempty"`
}

DockerComposeYaml docker compose struct

type Error Uses

type Error struct {
    Code    uint   `json:"code"`
    Msg     string `json:"msg"`
    Details string `json:"details,omitempty"`
}

Error Error

type ExportApp Uses

type ExportApp struct {
    EventID      string `json:"event_id"`
    Format       string `json:"format"`
    SourceDir    string `json:"source_dir"`
    Logger       event.Logger
    DockerClient *client.Client
}

ExportApp Export app to specified format(rainbond-app or dockercompose)

func (*ExportApp) CleanSourceDir Uses

func (i *ExportApp) CleanSourceDir() error

CleanSourceDir clean export dir

func (*ExportApp) ErrorCallBack Uses

func (i *ExportApp) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*ExportApp) GetLogger Uses

func (i *ExportApp) GetLogger() event.Logger

GetLogger GetLogger

func (*ExportApp) Name Uses

func (i *ExportApp) Name() string

Name return worker name

func (*ExportApp) Run Uses

func (i *ExportApp) Run(timeout time.Duration) error

Run Run

func (*ExportApp) Stop Uses

func (i *ExportApp) Stop() error

Stop stop

type ImageBuildItem Uses

type ImageBuildItem struct {
    Namespace     string       `json:"namespace"`
    TenantName    string       `json:"tenant_name"`
    ServiceAlias  string       `json:"service_alias"`
    Image         string       `json:"image"`
    DestImage     string       `json:"dest_image"`
    Logger        event.Logger `json:"logger"`
    EventID       string       `json:"event_id"`
    DockerClient  *client.Client
    TenantID      string
    ServiceID     string
    DeployVersion string
    HubUser       string
    HubPassword   string
    Action        string
    Configs       map[string]gjson.Result `json:"configs"`
}

ImageBuildItem ImageBuildItem

func NewImageBuildItem Uses

func NewImageBuildItem(in []byte) *ImageBuildItem

NewImageBuildItem 创建实体

func (*ImageBuildItem) ImageNameHandler Uses

func (i *ImageBuildItem) ImageNameHandler(source string) string

ImageNameHandler 根据平台配置处理镜像名称

func (*ImageBuildItem) Run Uses

func (i *ImageBuildItem) Run(timeout time.Duration) error

Run Run

func (*ImageBuildItem) StorageVersionInfo Uses

func (i *ImageBuildItem) StorageVersionInfo(imageURL string) error

StorageVersionInfo 存储version信息

func (*ImageBuildItem) UpdateVersionInfo Uses

func (i *ImageBuildItem) UpdateVersionInfo(status string) error

UpdateVersionInfo 更新任务执行结果

type ImageShareItem Uses

type ImageShareItem struct {
    Namespace      string `json:"namespace"`
    TenantName     string `json:"tenant_name"`
    ServiceID      string `json:"service_id"`
    ServiceAlias   string `json:"service_alias"`
    ImageName      string `json:"image_name"`
    LocalImageName string `json:"local_image_name"`
    ShareID        string `json:"share_id"`
    Logger         event.Logger
    ShareInfo      struct {
        ServiceKey string `json:"service_key" `
        AppVersion string `json:"app_version" `
        EventID    string `json:"event_id"`
        ShareUser  string `json:"share_user"`
        ShareScope string `json:"share_scope"`
        ImageInfo  struct {
            HubURL      string `json:"hub_url"`
            HubUser     string `json:"hub_user"`
            HubPassword string `json:"hub_password"`
            Namespace   string `json:"namespace"`
            IsTrust     bool   `json:"is_trust,omitempty"`
        }   `json:"image_info,omitempty"`
    }   `json:"share_info"`
    DockerClient *client.Client
    EtcdCli      *clientv3.Client
}

ImageShareItem ImageShareItem

func NewImageShareItem Uses

func NewImageShareItem(in []byte, DockerClient *client.Client, EtcdCli *clientv3.Client) (*ImageShareItem, error)

NewImageShareItem 创建实体

func (*ImageShareItem) ShareService Uses

func (i *ImageShareItem) ShareService() error

ShareService ShareService

func (*ImageShareItem) UpdateShareStatus Uses

func (i *ImageShareItem) UpdateShareStatus(status string) error

UpdateShareStatus 更新任务执行结果

type ImportApp Uses

type ImportApp struct {
    EventID      string   `json:"event_id"`
    Format       string   `json:"format"`
    SourceDir    string   `json:"source_dir"`
    Apps         []string `json:"apps"`
    ServiceImage model.ServiceImage
    ServiceSlug  model.ServiceSlug
    Logger       event.Logger
    DockerClient *client.Client
    // contains filtered or unexported fields
}

ImportApp Export app to specified format(rainbond-app or dockercompose)

func (*ImportApp) ErrorCallBack Uses

func (i *ImportApp) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*ImportApp) GetLogger Uses

func (i *ImportApp) GetLogger() event.Logger

GetLogger GetLogger

func (*ImportApp) Name Uses

func (i *ImportApp) Name() string

Name return worker name

func (*ImportApp) Run Uses

func (i *ImportApp) Run(timeout time.Duration) error

Run Run

func (*ImportApp) Stop Uses

func (i *ImportApp) Stop() error

Stop stop

type Info Uses

type Info struct {
    ServiceID    string
    ServiceAlias string
    Status       string
    LBPorts      map[int]int
}

Info service cache info

type Manager Uses

type Manager interface {
    GetMaxConcurrentTask() float64
    GetCurrentConcurrentTask() float64
    AddTask(*pb.TaskMessage) error
    SetReturnTaskChan(func(*pb.TaskMessage))
    Start() error
    Stop() error
}

Manager 任务执行管理器

func NewManager Uses

func NewManager(conf option.Config, mqc mqclient.MQClient) (Manager, error)

NewManager new manager

type MarketSlugItem Uses

type MarketSlugItem struct {
    TenantName    string       `json:"tenant_name"`
    ServiceAlias  string       `json:"service_alias"`
    Logger        event.Logger `json:"logger"`
    EventID       string       `json:"event_id"`
    Operator      string       `json:"operator"`
    DeployVersion string       `json:"deploy_version"`
    TenantID      string       `json:"tenant_id"`
    ServiceID     string       `json:"service_id"`
    Action        string       `json:"action"`
    TGZPath       string
    Configs       map[string]string `json:"configs"`
    SlugInfo      struct {
        SlugPath    string `json:"slug_path"`
        FTPHost     string `json:"ftp_host"`
        FTPPort     string `json:"ftp_port"`
        FTPUser     string `json:"ftp_username"`
        FTPPassword string `json:"ftp_password"`
    }   `json:"slug_info"`
}

MarketSlugItem MarketSlugItem

func NewMarketSlugItem Uses

func NewMarketSlugItem(in []byte) (*MarketSlugItem, error)

NewMarketSlugItem 创建实体

func (*MarketSlugItem) Run Uses

func (i *MarketSlugItem) Run() error

Run Run

func (*MarketSlugItem) UpdateVersionInfo Uses

func (i *MarketSlugItem) UpdateVersionInfo(vi *dbmodel.VersionInfo) error

UpdateVersionInfo 更新任务执行结果

type PluginShareItem Uses

type PluginShareItem struct {
    EventID        string `json:"event_id"`
    ImageName      string `json:"image_name"`
    LocalImageName string `json:"local_image_name"`
    ShareID        string `json:"share_id"`
    Logger         event.Logger
    ImageInfo      struct {
        HubURL      string `json:"hub_url"`
        HubUser     string `json:"hub_user"`
        HubPassword string `json:"hub_password"`
        Namespace   string `json:"namespace"`
        IsTrust     bool   `json:"is_trust,omitempty"`
    }   `json:"image_info,omitempty"`
    DockerClient *client.Client
    EtcdCli      *clientv3.Client
}

PluginShareItem PluginShareItem

func (*PluginShareItem) ErrorCallBack Uses

func (i *PluginShareItem) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*PluginShareItem) GetLogger Uses

func (i *PluginShareItem) GetLogger() event.Logger

GetLogger GetLogger

func (*PluginShareItem) Name Uses

func (i *PluginShareItem) Name() string

Name return worker name

func (*PluginShareItem) Run Uses

func (i *PluginShareItem) Run(timeout time.Duration) error

Run Run

func (*PluginShareItem) Stop Uses

func (i *PluginShareItem) Stop() error

Stop stop

type RegionServiceSnapshot Uses

type RegionServiceSnapshot struct {
    ServiceID          string
    Service            *dbmodel.TenantServices
    ServiceProbe       []*dbmodel.TenantServiceProbe
    LBMappingPort      []*dbmodel.TenantServiceLBMappingPort
    ServiceEnv         []*dbmodel.TenantServiceEnvVar
    ServiceLabel       []*dbmodel.TenantServiceLable
    ServiceMntRelation []*dbmodel.TenantServiceMountRelation
    ServiceRelation    []*dbmodel.TenantServiceRelation
    ServiceStatus      string
    ServiceVolume      []*dbmodel.TenantServiceVolume
    ServicePort        []*dbmodel.TenantServicesPort
    Versions           []*dbmodel.VersionInfo

    PluginRelation    []*dbmodel.TenantServicePluginRelation
    PluginConfigs     []*dbmodel.TenantPluginVersionDiscoverConfig
    PluginEnvs        []*dbmodel.TenantPluginVersionEnv
    PluginStreamPorts []*dbmodel.TenantServicesStreamPluginPort
}

RegionServiceSnapshot RegionServiceSnapshot

type RestoreResult Uses

type RestoreResult struct {
    Status        string           `json:"status"`
    Message       string           `json:"message"`
    CreateTime    time.Time        `json:"create_time"`
    ServiceChange map[string]*Info `json:"service_change"`
    BackupID      string           `json:"backup_id"`
    RestoreMode   string           `json:"restore_mode"`
    EventID       string           `json:"event_id"`
    RestoreID     string           `json:"restore_id"`
    CacheDir      string           `json:"cache_dir"`
}

RestoreResult RestoreResult

type Service Uses

type Service struct {
    Image         string            `yaml:"image"`
    ContainerName string            `yaml:"container_name,omitempty"`
    Restart       string            `yaml:"restart,omitempty"`
    NetworkMode   string            `yaml:"network_mode,omitempty"`
    Volumes       []string          `yaml:"volumes,omitempty"`
    Command       string            `yaml:"command,omitempty"`
    Environment   map[string]string `yaml:"environment,omitempty"`
    DependsOn     []string          `yaml:"depends_on,omitempty"`
    Loggin        struct {
        Driver  string `yaml:"driver,omitempty"`
        Options struct {
            MaxSize string `yaml:"max-size,omitempty"`
            MaxFile string `yaml:"max-file,omitempty"`
        }
    }   `yaml:"logging,omitempty"`
}

Service service

type ServiceCheckInput Uses

type ServiceCheckInput struct {
    CheckUUID string `json:"uuid"`
    //检测来源类型
    SourceType string `json:"source_type"`

    // 检测来源定义,
    // 代码: https://github.com/shurcooL/githubql.git master
    // docker-run: docker run --name xxx nginx:latest nginx
    // docker-compose: compose全文
    SourceBody string `json:"source_body"`
    Username   string `json:"username"`
    Password   string `json:"password"`
    TenantID   string
    EventID    string `json:"event_id"`
}

ServiceCheckInput 任务输入数据

type ServiceCheckResult Uses

type ServiceCheckResult struct {
    //检测状态 Success Failure
    CheckStatus string                `json:"check_status"`
    ErrorInfos  parser.ParseErrorList `json:"error_infos"`
    ServiceInfo []parser.ServiceInfo  `json:"service_info"`
}

ServiceCheckResult 应用检测结果

func CreateResult Uses

func CreateResult(ErrorInfos parser.ParseErrorList, ServiceInfo []parser.ServiceInfo) (ServiceCheckResult, error)

CreateResult 创建检测结果

type ShareStatus Uses

type ShareStatus struct {
    ShareID string `json:"share_id,omitempty"`
    Status  string `json:"status,omitempty"`
}

ShareStatus share status result ShareStatus share status result

func (ShareStatus) String Uses

func (s ShareStatus) String() string

type SlugShareItem Uses

type SlugShareItem struct {
    Namespace     string `json:"namespace"`
    TenantName    string `json:"tenant_name"`
    ServiceID     string `json:"service_id"`
    ServiceAlias  string `json:"service_alias"`
    SlugPath      string `json:"slug_path"`
    LocalSlugPath string `json:"local_slug_path"`
    ShareID       string `json:"share_id"`
    Logger        event.Logger
    ShareInfo     struct {
        ServiceKey string `json:"service_key" `
        AppVersion string `json:"app_version" `
        EventID    string `json:"event_id"`
        ShareUser  string `json:"share_user"`
        ShareScope string `json:"share_scope"`
        SlugInfo   struct {
            Namespace   string `json:"namespace"`
            FTPHost     string `json:"ftp_host"`
            FTPPort     string `json:"ftp_port"`
            FTPUser     string `json:"ftp_username"`
            FTPPassword string `json:"ftp_password"`
        }   `json:"slug_info,omitempty"`
    }   `json:"share_info"`
    EtcdCli     *clientv3.Client
    PackageName string
}

SlugShareItem SlugShareItem

func NewSlugShareItem Uses

func NewSlugShareItem(in []byte, etcdCli *clientv3.Client) (*SlugShareItem, error)

NewSlugShareItem 创建实体

func (*SlugShareItem) CheckMD5FileExist Uses

func (i *SlugShareItem) CheckMD5FileExist(md5path, packageName string) bool

CheckMD5FileExist CheckMD5FileExist

func (*SlugShareItem) ShareService Uses

func (i *SlugShareItem) ShareService() error

ShareService Run

func (*SlugShareItem) ShareToFTP Uses

func (i *SlugShareItem) ShareToFTP() error

ShareToFTP ShareToFTP

func (*SlugShareItem) ShareToLocal Uses

func (i *SlugShareItem) ShareToLocal() error

ShareToLocal ShareToLocal

func (*SlugShareItem) UpdateShareStatus Uses

func (i *SlugShareItem) UpdateShareStatus(status string) error

UpdateShareStatus 更新任务执行结果

type SourceCodeBuildItem Uses

type SourceCodeBuildItem struct {
    Namespace    string       `json:"namespace"`
    TenantName   string       `json:"tenant_name"`
    ServiceAlias string       `json:"service_alias"`
    Action       string       `json:"action"`
    DestImage    string       `json:"dest_image"`
    Logger       event.Logger `json:"logger"`
    EventID      string       `json:"event_id"`
    CacheDir     string       `json:"cache_dir"`
    //SourceDir     string       `json:"source_dir"`
    TGZDir        string `json:"tgz_dir"`
    DockerClient  *client.Client
    TenantID      string
    ServiceID     string
    DeployVersion string
    Lang          string
    Runtime       string
    BuildEnvs     map[string]string
    CodeSouceInfo sources.CodeSourceInfo
    RepoInfo      *sources.RepostoryBuildInfo

    Configs map[string]gjson.Result `json:"configs"`
    // contains filtered or unexported fields
}

SourceCodeBuildItem SouceCodeBuildItem

func NewSouceCodeBuildItem Uses

func NewSouceCodeBuildItem(in []byte) *SourceCodeBuildItem

NewSouceCodeBuildItem create

func (*SourceCodeBuildItem) IsDockerfile Uses

func (i *SourceCodeBuildItem) IsDockerfile() bool

IsDockerfile CheckDockerfile

func (*SourceCodeBuildItem) Run Uses

func (i *SourceCodeBuildItem) Run(timeout time.Duration) error

Run Run

func (*SourceCodeBuildItem) UpdateBuildVersionInfo Uses

func (i *SourceCodeBuildItem) UpdateBuildVersionInfo(res *build.Response) error

UpdateBuildVersionInfo update service build version info to db

func (*SourceCodeBuildItem) UpdateCheckResult Uses

func (i *SourceCodeBuildItem) UpdateCheckResult(result *dbmodel.CodeCheckResult) error

UpdateCheckResult UpdateCheckResult

func (*SourceCodeBuildItem) UpdateVersionInfo Uses

func (i *SourceCodeBuildItem) UpdateVersionInfo(vi *dbmodel.VersionInfo) error

UpdateVersionInfo Update build application service version info

type TaskWorker Uses

type TaskWorker interface {
    Run(timeout time.Duration) error
    GetLogger() event.Logger
    Name() string
    Stop() error
    //ErrorCallBack if run error will callback
    ErrorCallBack(err error)
}

TaskWorker worker interface

func BackupAPPNewCreater Uses

func BackupAPPNewCreater(in []byte, m *exectorManager) (TaskWorker, error)

BackupAPPNewCreater create

func BackupAPPRestoreCreater Uses

func BackupAPPRestoreCreater(in []byte, m *exectorManager) (TaskWorker, error)

BackupAPPRestoreCreater create

func NewExportApp Uses

func NewExportApp(in []byte, m *exectorManager) (TaskWorker, error)

NewExportApp create

func NewImportApp Uses

func NewImportApp(in []byte, m *exectorManager) (TaskWorker, error)

NewImportApp create

func SharePluginItemCreater Uses

func SharePluginItemCreater(in []byte, m *exectorManager) (TaskWorker, error)

SharePluginItemCreater create

type Worker Uses

type Worker struct {
    // contains filtered or unexported fields
}

Worker 工作器

func NewWorker Uses

func NewWorker(cmdpath, user string, envs []string, in []byte) *Worker

NewWorker 创建一个worker

Package exector imports 45 packages (graph) and is imported by 5 packages. Updated 2019-11-22. Refresh now. Tools for package owners.