entities

package
v0.0.0-...-0473bba Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const (
	REPO_TYPE_GIT = "git"
	REPO_TYPE_SVN = "svn"
)
View Source
const (
	AUDIT_STATUS_WAITING  = 10
	AUDIT_STATUS_PASS     = DEPLOYMENT_STATUS_AUDIT_PASS
	AUDIT_STATUS_REJECT   = DEPLOYMENT_STATUS_AUDIT_REJECT
	AUDIT_STATUS_CANCELED = DEPLOYMENT_STATUS_CANCELED
)
View Source
const (
	BUILD_STATUS_CREATED         = 10
	BUILD_STATUS_BUIDING         = 20
	BUILD_STATUS_BUILD_SUCC      = 30
	BUILD_STATUS_BUILD_FAILED    = 40
	BUILD_STATUS_PACK_SUCC       = 50
	BUILD_STATUS_PACK_FAILED     = 60
	BUILD_STATUS_PKG_PUSH_SUCC   = 70
	BUILD_STATUS_PKG_PUSH_FAILED = 80
)
View Source
const (
	FILE_DEPLOY_MODE_FULL  = 1
	FILE_DEPLOY_MODE_DELTA = 2

	DEPLOYMENT_STATUS_CREATED      = 10
	DEPLOYMENT_STATUS_NO_AUDIT     = 20
	DEPLOYMENT_STATUS_WAIT_AUDIT   = 30
	DEPLOYMENT_STATUS_AUDIT_PASS   = 40
	DEPLOYMENT_STATUS_AUDIT_REJECT = 50
	DEPLOYMENT_STATUS_CANCELED     = 60
	DEPLOYMENT_STATUS_DEALING      = 70
	DEPLOYMENT_STATUS_SUCC         = 80
	DEPLOYMENT_STATUS_FAILED       = 90
)
View Source
const (
	JOB_STATUS_CREATED = 10
	JOB_STATUS_READY   = 20
	JOB_STATUS_DEALING = 30
	JOB_STATUS_SUCC    = 40
	JOB_STATUS_FAILED  = 50
)
View Source
const (
	JOB_STEP_STATUS_DEALING = 10
	JOB_STEP_STATUS_SUCC    = 20
	JOB_STEP_STATUS_FAILED  = 30

	// JOB_STEPS
	JOB_STEP_INIT_WORKSPACE         = 10
	JOB_STEP_SYNC_VERISON_PACKAGE   = 20
	JOB_STEP_UNPACK_VERISON_PACKAGE = 30
	JOB_STEP_CMD_BEFORE_DEPLOY      = 40
	JOB_STEP_DO_DEPLOY              = 50
	JOB_STEP_CMD_AFTER_DEPLOY       = 60
	JOB_STEP_CMD_HEALTH_CHECK       = 70
	JOB_STEP_CMD_ONLINE             = 80
	JOB_STEP_END_CLEAN              = 90
)
View Source
const (
	// project permission
	PERM_PROJECT_CREATE = "project.create"
	PERM_PROJECT_UPDATE = "project.update"

	// project member permissions
	PERM_MEMBER_ADD    = "member.add"
	PERM_MEMBER_REMOVE = "member.remove"
	// tips: change other member's role
	PERM_MEMBER_CHANGE_ROLE = "member.change.role"

	// app permissions
	PERM_APP_CREATE = "app.create"
	PERM_APP_UPDATE = "app.update"
	PERM_APP_DELETE = "app.delete"

	// app's env permission
	PERM_ENV_CREATE = "env.create"
	PERM_ENV_UPDATE = "env.update"
	PERM_ENV_DELETE = "env.delete"
	// permission to configure environment's audit
	// and permission pass or reject the environment's deployments
	PERM_ENV_AUDIT = "env.audit"

	// app's cluster permissions
	PERM_CLUSTER_CREATE = "cluster.create"
	PERM_CLUSTER_UPDATE = "cluster.update"
	PERM_CLUSTER_DELETE = "cluster.delete"

	// deployment's permissions
	PERM_DEPLOYMENT_CREAET = "deployment.create"
)
View Source
const (
	// if git url is http(s), need to check which auth type is configured.
	// if git url is SSH, use host's ssh public key and no need to check auth type.
	GIT_CI_AUTH_TYPE_BASIC = 1
	GIT_CI_AUTH_TYPE_TOKEN = 2

	PKG_STORAGE_TYPE_LOCAL  = "local"
	PKG_STORAGE_TYPE_OSS    = "oss"
	PKG_STORAGE_TYPE_COS    = "cos"
	PKG_STORAGE_TYPE_AWS_S3 = "aws-s3"
)
View Source
const (
	ROLE_ADMIN = "admin"
	ROLE_USER  = "user"
)

Variables

View Source
var InitEnvs = []string{
	lang.I("env.dev"),
	lang.I("env.test"),
	lang.I("env.staging"),
	lang.I("env.prod"),
}

init environments while create app

View Source
var PERM_LABELS = map[string]string{

	PERM_PROJECT_CREATE: lang.I("project.create"),
	PERM_PROJECT_UPDATE: lang.I("project.update"),

	PERM_MEMBER_ADD:    lang.I("member.add"),
	PERM_MEMBER_REMOVE: lang.I("member.remove"),

	PERM_MEMBER_CHANGE_ROLE: lang.I("member.change.role"),

	PERM_APP_CREATE: lang.I("app.create"),
	PERM_APP_UPDATE: lang.I("app.update"),
	PERM_APP_DELETE: lang.I("app.delete"),

	PERM_ENV_CREATE: lang.I("env.create"),
	PERM_ENV_UPDATE: lang.I("env.update"),
	PERM_ENV_DELETE: lang.I("env.delete"),

	PERM_ENV_AUDIT: lang.I("env.audit"),

	PERM_CLUSTER_CREATE: lang.I("cluster.create"),
	PERM_CLUSTER_UPDATE: lang.I("cluster.update"),
	PERM_CLUSTER_DELETE: lang.I("cluster.delete"),

	PERM_DEPLOYMENT_CREAET: lang.I("deployment.create"),
}

permission labels

Functions

This section is empty.

Types

type AppEntity

type AppEntity struct {
	BaseEntity

	Uid                 int64  `json:"uid"`
	ProjectId           int64  `json:"project_id"`
	Name                string `json:"name"`
	Description         string `json:"description"`
	DeployType          int    `json:"deploy_type"`
	AppType             int    `json:"app_type"`
	AppConfig           string `json:"app_config"`
	CmdBuild            string `json:"cmd_build"`
	RepoUrl             string `json:"repo_url"`
	RepoUsername        string `json:"repo_username"`
	RepoPassword        string `json:"repo_password"`
	PublicKey           string `json:"public_key"`
	RepoType            string `json:"repo_type"`
	LocalRepoWorkspace  string `json:"local_repo_workspace"`
	LocalBuildWorkspace string `json:"local_build_workspace"`
	LocalPkgWorkspace   string `json:"local_pkg_workspace"`
	Excludes            string `json:"excludes"`
	Files               string `json:"files"`
	CmdBeforeDeploy     string `json:"cmd_before_deploy"`
	CmdAfterDeploy      string `json:"cmd_after_deploy"`
	CmdHealthCheck      string `json:"cmd_health_check"`
	CmdOnline           string `json:"cmd_online"`
	CmdTimeout          int    `json:"cmd_timeout"`
	CmdGetPid           string `json:"cmd_get_pid"`
	DeployUser          string `json:"deploy_user"`
	DeployPath          string `json:"deploy_path"`
	RemotePkgWorkspace  string `json:"remote_pkg_workspace"`
}

func (*AppEntity) FormatKey

func (t *AppEntity) FormatKey(app, pkgName string) string

format package file name key for package repository, e.g: oss/cos/aws s3

func (*AppEntity) FormatLocalVersionPackagePath

func (t *AppEntity) FormatLocalVersionPackagePath(pkgName string) string

format local version package path, e.g: /data/nvwa/demo-01/....tar.gz

func (*AppEntity) FormatRemoteVersionPackagePath

func (t *AppEntity) FormatRemoteVersionPackagePath(pkgName string) string

format remote version package path, e.g:/data/nvwa/demo-01/{pkgName}

func (*AppEntity) FormatRemoteVersionPackageWorkspace

func (t *AppEntity) FormatRemoteVersionPackageWorkspace(pkgName string) string

format remote version package workspace, e.g:/data/nvwa/demo-01/{version}/

func (*AppEntity) FormatTemporaryBuildPath

func (t *AppEntity) FormatTemporaryBuildPath(buildId int64) string

format temporary build path

func (*AppEntity) FormatVersionPackageName

func (t *AppEntity) FormatVersionPackageName(buildId int64, branch, commit string) string

format version package name

func (*AppEntity) GenLocalVersionPackagePath

func (t *AppEntity) GenLocalVersionPackagePath(buildId int64, branch, commit string) string

generate local version package path

type AuditEntity

type AuditEntity struct {
	BaseEntity

	DeploymentId int64 `json:"deployment_id"`
	EnvId        int64 `json:"env_id"`
	ProjectId    int64 `json:"project_id"`
	AppId        int64 `json:"app_id"`
	Uid          int64 `json:"uid"`
	AuditUid     int64 `json:"audit_uid"`
	Status       int   `json:"status"`
}

type BaseEntity

type BaseEntity struct {
	Id      int64  `json:"id"`
	Enabled int    `json:"-"`
	Ctime   string `json:"ctime"`
	Utime   string `json:"utime"`
}

type BuildEntity

type BuildEntity struct {
	BaseEntity

	AppId           int64  `json:"app_id"`
	Uid             int64  `json:"uid"`
	Branch          string `json:"branch"`
	Tag             string `json:"tag"`
	CommitId        string `json:"commit_id"`
	PackageName     string `json:"package_name"`
	JenkinsBuildNum int    `json:"jenkins_build_num"`
	Log             string `json:"log"`
	Notified        bool   `json:"notified"`
	Status          int    `json:"status"`
}

type ClusterEntity

type ClusterEntity struct {
	BaseEntity

	AppId int64  `json:"app_id"`
	EnvId int64  `json:"env_id"`
	Uid   int64  `json:"uid"`
	Name  string `json:"name"`
	Hosts string `json:"hosts"`
}

type DeploymentEntity

type DeploymentEntity struct {
	BaseEntity

	ProjectId      int64  `json:"project_id"`
	AppId          int64  `json:"app_id"`
	Uid            int64  `json:"uid"`
	EnvId          int64  `json:"env_id"`
	PkgId          int64  `json:"pkg_id"`
	Pkg            string `json:"pkg"`
	ClusterIds     string `json:"cluster_ids"`
	ClusterHosts   string `json:"cluster_hosts"`
	IsAutoDeploy   bool   `json:"is_auto_deploy"`
	IsAllCluster   bool   `json:"is_all_cluster"`
	LinkId         string `json:"link_id"`
	Branch         string `json:"branch"`
	CommitId       string `json:"commit_id"`
	FileList       string `json:"file_list"`
	FileDeployMode int    `json:"file_deploy_mode"`
	LatestLinkId   string `json:"latest_link_id"`
	IsNeedAudit    bool   `json:"is_need_audit"`
	Status         int    `json:"status"`
}

func (*DeploymentEntity) GetVersion

func (t *DeploymentEntity) GetVersion() string

type EnvEntity

type EnvEntity struct {
	BaseEntity

	AppId          int64  `json:"app_id"`
	Uid            int64  `json:"uid"`
	Name           string `json:"name"`
	PermitBranches string `json:"permit_branches"`
	IsAutoDeploy   bool   `json:"is_auto_deploy"`
	IsNeedAudit    bool   `json:"is_need_audit"`
	CmdEnv         string `json:"cmd_env"`
}

type Event

type Event struct {
	BaseEntity

	ProjectId int64 `json:"project_id"`
	AppId     int64 `json:"app_id"`
	Uid       int64 `json:"uid"`
	Content   int   `json:"content"`
}

type JobEntity

type JobEntity struct {
	BaseEntity

	DeploymentId int64  `json:"deployment_id"`
	AppId        int64  `json:"app_id"`
	EnvId        int64  `json:"env_id"`
	ClusterId    int64  `json:"cluster_id"`
	AllHosts     string `json:"all_hosts"`
	DeployHosts  string `json:"deploy_hosts"`
	ExcludeHosts string `json:"exclude_hosts"`
	Status       int    `json:"status"`
}

type JobStepEntity

type JobStepEntity struct {
	BaseEntity

	JobId        int64  `json:"job_id"`
	AppId        int64  `json:"app_id"`
	DeploymentId int64  `json:"deployment_id"`
	Cmd          string `json:"cmd"`
	Log          string `json:"log"`
	Consume      int    `json:"consume"`
	Step         int    `json:"step"`
	Status       int    `json:"status"`
}

type MemberEntity

type MemberEntity struct {
	BaseEntity

	ProjectId     int64 `json:"project_id"`
	Uid           int64 `json:"uid"`
	ProjectRoleId int64 `json:"project_role_id"`
}

type NotifyConfig

type NotifyConfig struct {
	Email struct {
		Host       string `json:"host"`
		Port       string `json:"port"`
		Username   string `json:"username"`
		Password   string `json:"password"`
		Encryption string `json:"encryption"` // tls / ssl
	} `json:"email"`

	// @TODO support wechat notification
	WechatWork struct{}
}

type PkgEntity

type PkgEntity struct {
	BaseEntity

	AppId       int64  `json:"app_id"`
	BuildId     int64  `json:"build_id"`
	Name        string `json:"name"`
	Branch      string `json:"branch"`
	Tag         string `json:"tag"`
	CommitId    string `json:"commit_id"`
	StorageType string `json:"storage_type"`
}

type PkgStorageConfig

type PkgStorageConfig struct {
	// local config
	Local *PkgStorageConfigLocal `json:",omitempty"`

	// oss config
	Oss *PkgStorageConfigOss `json:"oss,omitempty"`
}

type PkgStorageConfigLocal

type PkgStorageConfigLocal struct{}

type PkgStorageConfigOss

type PkgStorageConfigOss struct {
	Endpoint     string `json:"endpoint"`
	AccessKey    string `json:"access_key"`
	AccessSecret string `json:"access_secret"`
	Bucket       string `json:"bucket"`
}

type ProjectEntity

type ProjectEntity struct {
	BaseEntity

	Name        string `json:"name"`
	Description string `json:"description"`
	Uid         int64  `json:"uid"`
}

type ProjectRoleEntity

type ProjectRoleEntity struct {
	BaseEntity

	Name string `json:"name"`
}

type ProjectRolePermEntity

type ProjectRolePermEntity struct {
	BaseEntity

	ProjectRoleId int64  `json:"project_role_id"`
	Perm          string `json:"perm"`
}

type SystemEntity

type SystemEntity struct {
	BaseEntity

	Version              string `json:"version"`
	PkgRootPath          string `json:"pkg_root_path"`
	DeployRootPath       string `json:"deploy_root_path"`
	CustomDeployPath     bool   `json:"custom_deploy_path"`
	DeployUser           string `json:"deploy_user"`
	CustomDeployUser     bool   `json:"custom_deploy_user"`
	PkgLimit             int    `json:"pkg_limit"`
	DefaultProjectRoleId int    `json:"default_project_role_id"`
	UseJenkins           bool   `json:"use_jenkins"`
	JenkinsUrl           string `json:"jenkins_url"`
	JenkinsTemplate      string `json:"jenkins_template"`
	JenkinsCredentialId  string `json:"jenkins_credential_id"`
	JenkinsUser          string `json:"jenkins_user"`
	JenkinsPassword      string `json:"jenkins_password"`

	RepoRootPath string `json:"repo_root_path"`

	PkgStorageType   string `json:"pkg_storage_type"`
	PkgStorageConfig string `json:"pkg_storage_config"`

	GitCIAuthType int    `json:"git_ci_auth_type"`
	GitCIUser     string `json:"git_ci_user"`
	GitCIPassword string `json:"git_ci_password"`
	GitCIToken    string `json:"git_ci_token"`

	NotifyEnableTypes string `json:"notify_enable_types"`
	NotifyConfig      string `json:"notify_config"`
}

func (*SystemEntity) DecodePkgStorageConfig

func (t *SystemEntity) DecodePkgStorageConfig() (*PkgStorageConfig, error)

Decode PkgStorageConfig

func (*SystemEntity) FormatJenkinsTemplate

func (t *SystemEntity) FormatJenkinsTemplate(app *AppEntity) (string, error)

type UserEntity

type UserEntity struct {
	BaseEntity

	Username    string `json:"username"`
	Email       string `json:"email"`
	DisplayName string `json:"display_name"`
	Password    string `json:"-"`
	Avatar      string `json:"avatar"`
	Role        string `json:"role"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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