model

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Rsync  = 1
	SSH    = 2
	Script = 3
)

install trace type

View Source
const (
	Fail = iota
	Success
)

state type

View Source
const (
	Disable = iota
	Enable
)

state type

View Source
const (
	ProjectNotDeploy = 0
	ProjectDeploying = 1
	ProjectSuccess   = 2
	ProjectFail      = 3
)

Project deploy state

View Source
const (
	ProjectManualDeploy  = 0
	ProjectWebhookDeploy = 1
)

Project deploy type

View Source
const (
	NotifyWeiXin   = 1
	NotifyDingTalk = 2
	NotifyFeiShu   = 3
	NotifyCustom   = 255
)

Project notify type

View Source
const (
	NotRun = iota
	Run
)

state type

View Source
const (
	BeforePull = 1

	Pull = 2

	AfterPull = 3

	BeforeDeploy = 4

	Deploy = 5

	AfterDeploy = 6
)

publish trace state

View Source
const GeneralUser = 0

GeneralUser general user

View Source
const SuperManager = 1

SuperManager super manager

Variables

View Source
var DB *sql.DB

DB init when the program start

Functions

func ImportSQL

func ImportSQL(db *sql.DB) error

ImportSQL -

func Init

func Init()

Init DB

Types

type Chart

type Chart struct {
	Hour         int `json:"hour"`
	CommitNumber int `json:"commitNumber"`
	DeployNumber int `json:"deployNumber"`
	FailNumber   int `json:"failNumber"`
	BackNumber   int `json:"backNumber"`
}

Chart struct

type Charts

type Charts []Chart

Charts struct

func (*Charts) Query

func (c *Charts) Query(date string) error

Query chart row

type Crontab

type Crontab struct {
	ID          int64  `json:"id"`
	NamespaceID int64  `json:"namespace_id"`
	Command     string `json:"command"`
	CommandMD5  string `json:"commandMD5"`
	Creator     string `json:"creator"`
	CreatorID   int64  `json:"creatorId"`
	Editor      string `json:"editor"`
	EditorID    int64  `json:"editorId"`
	InsertTime  string `json:"insertTime"`
	UpdateTime  string `json:"updateTime"`
}

Crontab -

func (Crontab) AddRow

func (c Crontab) AddRow() (int64, error)

AddRow return LastInsertId

func (Crontab) AddRowsInCommand

func (c Crontab) AddRowsInCommand(commands []string) error

AddRowsInCommand add many rows in command

func (Crontab) DeleteRow

func (c Crontab) DeleteRow() error

DeleteRow -

func (Crontab) EditRow

func (c Crontab) EditRow() error

EditRow -

func (Crontab) GetAllInCommandMD5

func (c Crontab) GetAllInCommandMD5(commandMD5s []string) (Crontabs, error)

GetAllInCommandMD5 return all row in command md5

func (Crontab) GetData

func (c Crontab) GetData() (Crontab, error)

GetData return Crontab

func (Crontab) GetList

func (c Crontab) GetList(pagination Pagination) (Crontabs, error)

GetList -

func (Crontab) GetTotal

func (c Crontab) GetTotal() (int64, error)

GetTotal -

type CrontabServer

type CrontabServer struct {
	ID                int64  `json:"id"`
	CrontabID         int64  `json:"crontabId"`
	ServerID          int64  `json:"serverId"`
	ServerName        string `json:"serverName"`
	ServerIP          string `json:"serverIP"`
	ServerPort        int64  `json:"serverPort"`
	ServerOwner       string `json:"serverOwner"`
	ServerDescription string `json:"serverDescription"`
	InsertTime        string `json:"insertTime"`
	UpdateTime        string `json:"updateTime"`
}

CrontabServer -

func (CrontabServer) DeleteByCrontabID added in v1.0.2

func (cs CrontabServer) DeleteByCrontabID() error

DeleteByCrontabID -

func (CrontabServer) DeleteRow

func (cs CrontabServer) DeleteRow() error

DeleteRow -

func (CrontabServer) GetAllByCrontabID

func (cs CrontabServer) GetAllByCrontabID() (CrontabServers, error)

GetAllByCrontabID return CrontabServers by CrontabID

func (CrontabServer) GetBindServerListByProjectID

func (cs CrontabServer) GetBindServerListByProjectID() (CrontabServers, error)

GetBindServerListByProjectID return bind server list by project id

type CrontabServers

type CrontabServers []CrontabServer

CrontabServers -

func (CrontabServers) AddMany

func (cs CrontabServers) AddMany() error

AddMany -

type Crontabs

type Crontabs []Crontab

Crontabs -

type InstallTrace

type InstallTrace struct {
	ID           int64  `json:"id"`
	Token        string `json:"token"`
	ServerID     int64  `json:"serverId"`
	ServerName   string `json:"serverName"`
	Detail       string `json:"detail"`
	State        uint8  `json:"state"`
	OperatorID   int64  `json:"operatorId"`
	OperatorName string `json:"operatorName"`
	Type         int64  `json:"type"`
	Ext          string `json:"ext"`
	InstallState int64  `json:"installState"`
	InsertTime   string `json:"insertTime"`
	UpdateTime   string `json:"updateTime"`
}

InstallTrace -

func (InstallTrace) AddRow

func (it InstallTrace) AddRow() (int64, error)

AddRow return LastInsertId

func (InstallTrace) GetListByToken

func (it InstallTrace) GetListByToken() (InstallTraces, error)

GetListByToken -

func (InstallTrace) GetListGroupByToken

func (it InstallTrace) GetListGroupByToken() (InstallTraces, error)

GetListGroupByToken -

func (InstallTrace) GetPreviewByProjectID

func (it InstallTrace) GetPreviewByProjectID() (InstallTraces, error)

GetPreviewByProjectID -

type InstallTraces

type InstallTraces []InstallTrace

InstallTraces -

type Monitor

type Monitor struct {
	ID           int64  `json:"id"`
	NamespaceID  int64  `json:"namespaceId"`
	Name         string `json:"name"`
	Domain       string `json:"domain"`
	Port         int    `json:"port"`
	Second       int    `json:"second"`
	Times        uint16 `json:"times"`
	NotifyType   uint8  `json:"notifyType"`
	NotifyTarget string `json:"notifyTarget"`
	NotifyTimes  uint16 `json:"notifyTimes"`
	Description  string `json:"description"`
	ErrorContent string `json:"errorContent"`
	State        uint8  `json:"state"`
	InsertTime   string `json:"insertTime"`
	UpdateTime   string `json:"updateTime"`
}

Monitor -

func (Monitor) AddRow

func (m Monitor) AddRow() (int64, error)

AddRow return LastInsertId

func (Monitor) DeleteRow

func (m Monitor) DeleteRow() error

DeleteRow -

func (Monitor) EditRow

func (m Monitor) EditRow() error

EditRow -

func (Monitor) GetAllByState

func (m Monitor) GetAllByState() (Monitors, error)

GetAllByState -

func (Monitor) GetData

func (m Monitor) GetData() (Monitor, error)

GetData -

func (Monitor) GetList

func (m Monitor) GetList(pagination Pagination) (Monitors, error)

GetList -

func (Monitor) GetTotal

func (m Monitor) GetTotal() (int64, error)

GetTotal -

func (Monitor) ToggleState

func (m Monitor) ToggleState() error

ToggleState -

func (Monitor) TurnOff added in v1.0.3

func (m Monitor) TurnOff(errorContent string) error

TurnOff -

type Monitors

type Monitors []Monitor

Monitors -

type Namespace

type Namespace struct {
	ID         int64  `json:"id"`
	Name       string `json:"name"`
	UserID     int64  `json:"-"`
	Role       string `json:"role"`
	InsertTime string `json:"insertTime,omitempty"`
	UpdateTime string `json:"updateTime,omitempty"`
}

Namespace -

func (Namespace) AddRow

func (ns Namespace) AddRow() (int64, error)

AddRow return LastInsertId

func (Namespace) EditRow

func (ns Namespace) EditRow() error

EditRow -

func (Namespace) GetAllByUserID

func (ns Namespace) GetAllByUserID() (Namespaces, error)

GetAllByUserID -

func (Namespace) GetData

func (ns Namespace) GetData() (Namespace, error)

GetData -

func (Namespace) GetListByUserID

func (ns Namespace) GetListByUserID(pagination Pagination) (Namespaces, error)

GetListByUserID -

func (Namespace) GetTotalByUserID

func (ns Namespace) GetTotalByUserID() (int64, error)

GetTotalByUserID -

type NamespaceUser

type NamespaceUser struct {
	ID            int64  `json:"id,omitempty"`
	NamespaceID   int64  `json:"namespaceId,omitempty"`
	NamespaceName string `json:"namespaceName,omitempty"`
	UserID        int64  `json:"userId,omitempty"`
	UserName      string `json:"userName,omitempty"`
	Role          string `json:"role,omitempty"`
	InsertTime    string `json:"insertTime,omitempty"`
	UpdateTime    string `json:"updateTime,omitempty"`
}

NamespaceUser -

func (NamespaceUser) AddAdminByNamespaceID

func (nu NamespaceUser) AddAdminByNamespaceID() error

AddAdminByNamespaceID -

func (NamespaceUser) AddAdminByUserID

func (nu NamespaceUser) AddAdminByUserID() error

AddAdminByUserID -

func (NamespaceUser) DeleteByUserID

func (nu NamespaceUser) DeleteByUserID() error

DeleteByUserID -

func (NamespaceUser) DeleteRow

func (nu NamespaceUser) DeleteRow() error

DeleteRow -

func (NamespaceUser) GetAllGteManagerByNamespaceID

func (nu NamespaceUser) GetAllGteManagerByNamespaceID() (NamespaceUsers, error)

GetAllGteManagerByNamespaceID -

func (NamespaceUser) GetAllUserByNamespaceID

func (nu NamespaceUser) GetAllUserByNamespaceID() (NamespaceUsers, error)

GetAllUserByNamespaceID -

func (NamespaceUser) GetBindUserListByNamespaceID

func (nu NamespaceUser) GetBindUserListByNamespaceID() (NamespaceUsers, error)

GetBindUserListByNamespaceID -

type NamespaceUsers

type NamespaceUsers []NamespaceUser

NamespaceUsers -

func (NamespaceUsers) AddMany

func (nu NamespaceUsers) AddMany() error

AddMany -

type Namespaces

type Namespaces []Namespace

Namespaces -

type Package

type Package struct {
	ID         int64  `json:"id"`
	Name       string `json:"name"`
	Size       int64  `json:"size"`
	InsertTime string `json:"insertTime"`
	UpdateTime string `json:"updateTime"`
}

Package -

func (Package) AddRow

func (p Package) AddRow() (int64, error)

AddRow return LastInsertId

func (Package) EditRow

func (p Package) EditRow() error

EditRow -

func (Package) GetAll

func (p Package) GetAll() (Packages, error)

GetAll -

func (Package) GetAllInID added in v1.0.2

func (p Package) GetAllInID(IDs []string) (Packages, error)

GetAllInID -

func (Package) GetData

func (p Package) GetData() (Package, error)

GetData -

func (Package) GetDataByName

func (p Package) GetDataByName() (Package, error)

GetDataByName -

func (Package) GetList

func (p Package) GetList(pagination Pagination) (Packages, error)

GetList -

func (Package) GetTotal

func (p Package) GetTotal() (int64, error)

GetTotal -

type Packages

type Packages []Package

Packages -

type Pagination

type Pagination struct {
	Page  uint64 `json:"page"`
	Rows  uint64 `json:"rows"`
	Total uint64 `json:"total"`
}

Pagination struct

func PaginationFrom

func PaginationFrom(param url.Values) (Pagination, error)

PaginationFrom param return pagination struct

type Project

type Project struct {
	ID                    int64  `json:"id"`
	NamespaceID           int64  `json:"namespaceId"`
	UserID                int64  `json:"userId,omitempty"`
	Name                  string `json:"name"`
	URL                   string `json:"url"`
	Path                  string `json:"path"`
	SymlinkPath           string `json:"symlinkPath"`
	Environment           uint8  `json:"environment"`
	Branch                string `json:"branch"`
	AfterPullScriptMode   string `json:"afterPullScriptMode"`
	AfterPullScript       string `json:"afterPullScript"`
	AfterDeployScriptMode string `json:"afterDeployScriptMode"`
	AfterDeployScript     string `json:"afterDeployScript"`
	RsyncOption           string `json:"rsyncOption"`
	AutoDeploy            uint8  `json:"autoDeploy"`
	PublisherID           int64  `json:"publisherId"`
	PublisherName         string `json:"publisherName"`
	PublishExt            string `json:"publishExt"`
	DeployState           uint8  `json:"deployState"`
	LastPublishToken      string `json:"lastPublishToken"`
	NotifyType            uint8  `json:"notifyType"`
	NotifyTarget          string `json:"notifyTarget"`
	State                 uint8  `json:"state"`
	InsertTime            string `json:"insertTime"`
	UpdateTime            string `json:"updateTime"`
}

Project -

func (Project) AddRow

func (p Project) AddRow() (int64, error)

AddRow return LastInsertId

func (Project) DeployFail

func (p Project) DeployFail() error

DeployFail set deploy_state to fail

func (Project) DeploySuccess

func (p Project) DeploySuccess() error

DeploySuccess set deploy_state to success

func (Project) EditRow

func (p Project) EditRow() error

EditRow -

func (Project) GetData

func (p Project) GetData() (Project, error)

GetData -

func (Project) GetList

func (p Project) GetList(pagination Pagination) (Projects, error)

GetList -

func (Project) GetTotal

func (p Project) GetTotal() (int64, error)

GetTotal -

func (Project) GetUserProjectData

func (p Project) GetUserProjectData() (Project, error)

GetUserProjectData -

func (Project) GetUserProjectList

func (p Project) GetUserProjectList() (Projects, error)

GetUserProjectList -

func (Project) Publish

func (p Project) Publish() error

Publish project

func (Project) RemoveRow

func (p Project) RemoveRow() error

RemoveRow -

func (Project) SetAutoDeploy added in v1.0.2

func (p Project) SetAutoDeploy() error

SetAutoDeploy set auto_deploy

type ProjectServer

type ProjectServer struct {
	ID                int64  `json:"id"`
	ProjectID         int64  `json:"projectId"`
	ServerID          int64  `json:"serverId"`
	ServerName        string `json:"serverName"`
	ServerIP          string `json:"serverIP"`
	ServerPort        int64  `json:"serverPort"`
	ServerOwner       string `json:"serverOwner"`
	ServerDescription string `json:"serverDescription"`
	InsertTime        string `json:"insertTime"`
	UpdateTime        string `json:"updateTime"`
}

ProjectServer -

func (ProjectServer) DeleteRow

func (ps ProjectServer) DeleteRow() error

DeleteRow -

func (ProjectServer) GetBindServerListByProjectID

func (ps ProjectServer) GetBindServerListByProjectID() (ProjectServers, error)

GetBindServerListByProjectID -

type ProjectServers

type ProjectServers []ProjectServer

ProjectServers -

func (ProjectServers) AddMany

func (ps ProjectServers) AddMany() error

AddMany -

type ProjectTask

type ProjectTask struct {
	ID         int64  `json:"id"`
	ProjectID  int64  `json:"projectId"`
	CommitID   string `json:"commitId"`
	Date       string `json:"date"`
	State      uint8  `json:"state"`
	IsRun      uint8  `json:"isRun"`
	Creator    string `json:"creator"`
	CreatorID  int64  `json:"creatorId"`
	Editor     string `json:"editor"`
	EditorID   int64  `json:"editorId"`
	InsertTime string `json:"insertTime"`
	UpdateTime string `json:"updateTime"`
}

ProjectTask -

func (ProjectTask) AddRow

func (pt ProjectTask) AddRow() (int64, error)

AddRow -

func (ProjectTask) EditRow

func (pt ProjectTask) EditRow() error

EditRow -

func (ProjectTask) GetListByProjectID

func (pt ProjectTask) GetListByProjectID(pagination Pagination) (ProjectTasks, Pagination, error)

GetListByProjectID -

func (ProjectTask) GetNotRunListLTDate

func (pt ProjectTask) GetNotRunListLTDate(date string) (ProjectTasks, error)

GetNotRunListLTDate -

func (ProjectTask) RemoveRow

func (pt ProjectTask) RemoveRow() error

RemoveRow -

func (ProjectTask) SetRun

func (pt ProjectTask) SetRun() error

SetRun set project task to run

type ProjectTasks

type ProjectTasks []ProjectTask

ProjectTasks -

type ProjectUser

type ProjectUser struct {
	ID          int64  `json:"id"`
	NamespaceID int64  `json:"namespaceId,omitempty"`
	ProjectID   int64  `json:"projectId"`
	ProjectName string `json:"projectName"`
	UserID      int64  `json:"userId"`
	UserName    string `json:"userName"`
	Role        string `json:"role,omitempty"`
	InsertTime  string `json:"insertTime"`
	UpdateTime  string `json:"updateTime"`
}

ProjectUser -

func (ProjectUser) AddAdminByUserID

func (pu ProjectUser) AddAdminByUserID() error

AddAdminByUserID add admin to table project_user

func (ProjectUser) AddNamespaceProjectInUserID

func (pu ProjectUser) AddNamespaceProjectInUserID(namespaceID int64, userIDs []int64) error

AddNamespaceProjectInUserID add all project with namespace in user id

func (ProjectUser) DeleteByUserID

func (pu ProjectUser) DeleteByUserID() error

DeleteByUserID -

func (ProjectUser) DeleteRow

func (pu ProjectUser) DeleteRow() error

DeleteRow -

func (ProjectUser) GetBindUserListByProjectID

func (pu ProjectUser) GetBindUserListByProjectID() (ProjectUsers, error)

GetBindUserListByProjectID -

type ProjectUsers

type ProjectUsers []ProjectUser

ProjectUsers -

func (ProjectUsers) AddMany

func (pu ProjectUsers) AddMany() error

AddMany -

type Projects

type Projects []Project

Projects -

type PublishTrace

type PublishTrace struct {
	ID            int64  `json:"id"`
	Token         string `json:"token"`
	ProjectID     int64  `json:"projectId"`
	ProjectName   string `json:"projectName"`
	Detail        string `json:"detail"`
	State         int    `json:"state"`
	PublisherID   int64  `json:"publisherId"`
	PublisherName string `json:"publisherName"`
	Type          int    `json:"type"`
	Ext           string `json:"ext"`
	PublishState  int    `json:"publishState"`
	InsertTime    string `json:"insertTime"`
	UpdateTime    string `json:"updateTime"`
}

PublishTrace -

func (PublishTrace) AddRow

func (pt PublishTrace) AddRow() (int64, error)

AddRow return LastInsertId

func (PublishTrace) GetListByToken

func (pt PublishTrace) GetListByToken() (PublishTraces, error)

GetListByToken -

func (PublishTrace) GetPreview

func (pt PublishTrace) GetPreview(pagination Pagination) (PublishTraces, Pagination, error)

GetPreview -

type PublishTraces

type PublishTraces []PublishTrace

PublishTraces -

type Server

type Server struct {
	ID               int64  `json:"id"`
	LastInstallToken string `json:"lastInstallToken"`
	Name             string `json:"name"`
	IP               string `json:"ip"`
	Port             int    `json:"port"`
	Owner            string `json:"owner"`
	NamespaceID      int64  `json:"namespaceId"`
	Description      string `json:"description"`
	InsertTime       string `json:"insertTime"`
	UpdateTime       string `json:"updateTime"`
}

Server -

func (Server) AddRow

func (s Server) AddRow() (int64, error)

AddRow return LastInsertId

func (Server) EditRow

func (s Server) EditRow() error

EditRow -

func (Server) GetAll

func (s Server) GetAll() (Servers, error)

GetAll -

func (Server) GetData

func (s Server) GetData() (Server, error)

GetData -

func (Server) GetList

func (s Server) GetList(pagination Pagination) (Servers, error)

GetList -

func (Server) GetTotal

func (s Server) GetTotal() (int64, error)

GetTotal -

func (Server) Install

func (s Server) Install() error

Install server

func (Server) RemoveRow added in v1.0.2

func (s Server) RemoveRow() error

RemoveRow -

type Servers

type Servers []Server

Servers -

type Template

type Template struct {
	ID           int64  `json:"id"`
	Name         string `json:"name"`
	Remark       string `json:"remark"`
	PackageIDStr string `json:"packageIdStr"`
	Script       string `json:"script"`
	InsertTime   string `json:"insertTime"`
	UpdateTime   string `json:"updateTime"`
}

Template -

func (Template) AddRow

func (tpl Template) AddRow() (int64, error)

AddRow return LastInsertId

func (Template) DeleteRow

func (tpl Template) DeleteRow() error

DeleteRow -

func (Template) EditRow

func (tpl Template) EditRow() error

EditRow -

func (Template) GetAll

func (tpl Template) GetAll() (Templates, error)

GetAll -

func (Template) GetData

func (tpl Template) GetData() (Template, error)

GetData -

func (Template) GetList

func (tpl Template) GetList(pagination Pagination) (Templates, error)

GetList -

func (Template) GetTotal

func (tpl Template) GetTotal() (int64, error)

GetTotal -

type Templates

type Templates []Template

Templates -

type User

type User struct {
	ID            int64  `json:"id"`
	Account       string `json:"account"`
	Password      string `json:"password"`
	Name          string `json:"name"`
	Contact       string `json:"contact"`
	SuperManager  int64  `json:"superManager"`
	State         uint8  `json:"state"`
	InsertTime    string `json:"insertTime"`
	UpdateTime    string `json:"updateTime"`
	LastLoginTime string `json:"lastLoginTime"`
}

User -

func (User) AddRow

func (u User) AddRow() (int64, error)

AddRow return LastInsertId

func (User) CreateToken

func (u User) CreateToken() (string, error)

CreateToken -

func (User) EditRow

func (u User) EditRow() error

EditRow -

func (User) GetAll

func (u User) GetAll() (Users, error)

GetAll -

func (User) GetData

func (u User) GetData() (User, error)

GetData -

func (User) GetDataByAccount

func (u User) GetDataByAccount() (User, error)

GetDataByAccount -

func (User) GetList

func (u User) GetList(pagination Pagination) (Users, error)

GetList -

func (User) GetTotal

func (u User) GetTotal() (int64, error)

GetTotal -

func (User) RemoveRow

func (u User) RemoveRow() error

RemoveRow -

func (User) UpdateLastLoginTime

func (u User) UpdateLastLoginTime() error

UpdateLastLoginTime -

func (User) UpdatePassword

func (u User) UpdatePassword() error

UpdatePassword -

func (User) Validate

func (u User) Validate(inputPassword string) error

Validate if user exists

type Users

type Users []User

Users -

Jump to

Keyboard shortcuts

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