models

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ClusterModel = &Cluster{}
)
View Source
var (
	ClusterNodeModel = &ClusterNode{}
)
View Source
var (
	DB orm.Ormer
)
View Source
var (
	DeployHistoryModel = &DeployHistory{}
)
View Source
var (
	DeployModel = &Deploy{}
)
View Source
var (
	NodeModel = &Node{}
)
View Source
var (
	ProjectClusterModel = &ProjectCluster{}
)
View Source
var (
	ProjectModel = &Project{}
)
View Source
var (
	UserModel = &User{}
)

Functions

func InitModels

func InitModels() error

Types

type Cluster

type Cluster struct {
	Id       int       `json:"id"`
	Name     string    `json:"name"`
	Tags     string    `json:"tags"`
	Note     string    `json:"note"`
	Created  time.Time `json:"created"`
	Modified time.Time `json:"modified"`
	Nodes    []*Node   `orm:"-" json:"nodes"`
}

func (Cluster) Add

func (m Cluster) Add(name, tags, note string) (*Cluster, error)

func (Cluster) Delete

func (m Cluster) Delete(id int) error

func (Cluster) GetAll

func (m Cluster) GetAll() ([]*Cluster, error)

func (Cluster) GetOne

func (m Cluster) GetOne(id int) (*Cluster, error)

func (Cluster) TableName

func (m Cluster) TableName() string

func (Cluster) TableUnique

func (m Cluster) TableUnique() [][]string

func (Cluster) Update

func (m Cluster) Update(id int, name, tags, note string) (*Cluster, error)

type ClusterNode

type ClusterNode struct {
	Id      int       `json:"id"`
	Cid     int       `json:"cid"`
	Mid     int       `json:"mid"`
	Created time.Time `json:"created"`
}

func (ClusterNode) Add

func (m ClusterNode) Add(cid, mid int) error

func (ClusterNode) Delete

func (m ClusterNode) Delete(cid int) error

func (ClusterNode) GetAll

func (m ClusterNode) GetAll(cid int) ([]*Node, error)

func (ClusterNode) TableName

func (m ClusterNode) TableName() string

func (ClusterNode) TableUnique

func (m ClusterNode) TableUnique() [][]string

type Deploy

type Deploy struct {
	Id            int              `json:"id"`
	Pid           int              `json:"pid"`
	Commit        string           `json:"commit"`
	Diff          string           `json:"diff"`
	Status        int              `json:"status"`
	Created       time.Time        `json:"created"`
	Modified      time.Time        `json:"modified"`
	DeployHistory []*DeployHistory `orm:"-" json:"deployHistory"`
}

status - 0 未开始 - 1 发布中 - 2 发布完成 - 3 发布失败 - 4 发布失败(部分机器)

func (Deploy) Add

func (m Deploy) Add(pid int, commit, diff string) (*Deploy, error)

func (Deploy) GetAll

func (m Deploy) GetAll(pid, limits int) ([]*Deploy, error)

func (Deploy) GetOne

func (m Deploy) GetOne(id int) (*Deploy, error)

func (Deploy) TableIndex

func (m Deploy) TableIndex() [][]string

func (Deploy) TableName

func (m Deploy) TableName() string

func (Deploy) UpdateStatus

func (m Deploy) UpdateStatus(id, status int) error

type DeployHistory

type DeployHistory struct {
	Id      int       `json:"id"`
	Did     int       `json:"did"`
	Ip      string    `json:"ip"`
	Status  int       `json:"status"`
	Note    string    `json:"note"`
	Created time.Time `json:"created"`
}

status - 0 未开始 - 1 发布中 - 2 发布完成 - 3 发布失败

func (DeployHistory) Add

func (m DeployHistory) Add(did int, ip string) (*DeployHistory, error)

func (DeployHistory) GetAll

func (m DeployHistory) GetAll(did int) ([]*DeployHistory, error)

func (DeployHistory) GetOne

func (m DeployHistory) GetOne(id int) (*DeployHistory, error)

func (DeployHistory) TableIndex

func (m DeployHistory) TableIndex() [][]string

func (DeployHistory) TableName

func (m DeployHistory) TableName() string

func (DeployHistory) Update

func (m DeployHistory) Update(id, status int, note string) error

type Node

type Node struct {
	Id         int       `json:"id"`
	Ip         string    `json:"ip"`
	Port       string    `json:"port"`
	Note       string    `json:"note"`
	Status     int       `json:"status"`
	Created    time.Time `json:"created"`
	Modified   time.Time `json:"modified"`
	LastReport time.Time `json:"lastReport"`
}

status 0-未启用 1-正常 -1-停用

func (Node) Add

func (m Node) Add(ip, port, note string) (*Node, error)

func (Node) Del

func (m Node) Del(id int) error

set status

func (Node) GetAll

func (m Node) GetAll() ([]*Node, error)

func (Node) GetOne

func (m Node) GetOne(id int) (*Node, error)

func (Node) GetOneByIp

func (m Node) GetOneByIp(ip string) (*Node, error)

func (Node) TableName

func (m Node) TableName() string

func (Node) TableUnique

func (m Node) TableUnique() [][]string

func (Node) Update

func (m Node) Update(id int, ip, port, note string, status int, lastReport time.Time) (*Node, error)

type Project

type Project struct {
	Id       int       `json:"id"`
	Name     string    `json:"name"`
	Path     string    `json:"path"`
	PushPath string    `json:"pushPath"`
	Tags     string    `json:"tags"`
	Note     string    `json:"note"`
	Created  time.Time `json:"created"`
	Modified time.Time `json:"modified"`

	ProjectClusters []*ProjectCluster `orm:"-" json:"projectClusters"`
}

func (Project) Add

func (m Project) Add(name, path, pushpath, tags, note string) (*Project, error)

func (Project) Del

func (m Project) Del(id int) error

func (Project) GetAll

func (m Project) GetAll() ([]*Project, error)

func (Project) GetOne

func (m Project) GetOne(id int) (*Project, error)

func (Project) TableName

func (m Project) TableName() string

func (Project) TableUnique

func (m Project) TableUnique() [][]string

func (Project) Update

func (m Project) Update(id int, name, path, pushpath, tags, note string) (*Project, error)

type ProjectCluster

type ProjectCluster struct {
	Id         int       `json:"id"`
	Pid        int       `json:"pid"`
	Cid        int       `json:"cid"`
	CustomNode string    `json:"customNode"`
	Bshell     string    `json:"bshell"`
	Eshell     string    `json:"eshell"`
	Note       string    `json:"note"`
	Created    time.Time `json:"created"`
	Modified   time.Time `json:"modified"`
	Cluster    *Cluster  `orm:"-" json:"cluster"`
}

func (ProjectCluster) Add

func (m ProjectCluster) Add(pid, cid int, customNode, bshell, eshell, note string) (*ProjectCluster, error)

func (ProjectCluster) Del

func (m ProjectCluster) Del(id int) error

func (ProjectCluster) DelProject

func (m ProjectCluster) DelProject(pid int) error

func (ProjectCluster) GetAll

func (m ProjectCluster) GetAll(pid int) ([]*ProjectCluster, error)

func (ProjectCluster) TableName

func (m ProjectCluster) TableName() string

func (ProjectCluster) TableUnique

func (m ProjectCluster) TableUnique() [][]string

func (ProjectCluster) Update

func (m ProjectCluster) Update(id, pid, cid int, customNode, bshell, eshell, note string) (*ProjectCluster, error)

type User

type User struct {
	Id            int       `json:"id"`
	Username      string    `json:"username"`
	Password      string    `json:"-"`
	Name          string    `json:"name"`
	Administrator int       `json:"administrator"`
	Created       time.Time `json:"created"`
	LastLogin     time.Time `json:"last_login"`
	LastLoginIp   string    `json:"last_login_ip"`
}

func (User) Add

func (m User) Add(username, name, password string, administrator int) (*User, error)

func (User) CheckCreateAdministor

func (m User) CheckCreateAdministor() error

func (User) CheckPassword

func (m User) CheckPassword(username, password string) (*User, error)

func (User) Del

func (m User) Del(id int) error

func (User) GetAll

func (m User) GetAll() ([]*User, error)

func (User) GetOne

func (m User) GetOne(id int) (*User, error)

func (User) GetViaUsername

func (m User) GetViaUsername(username string) (*User, error)

func (User) TableName

func (m User) TableName() string

func (User) TableUnique

func (m User) TableUnique() [][]string

func (User) Update

func (m User) Update(id int, username, name string, administrator int) (*User, error)

func (User) UpdateLastLogin

func (m User) UpdateLastLogin(id int, ip string) error

func (User) UpdatePassword

func (m User) UpdatePassword(id int, password string) error

Jump to

Keyboard shortcuts

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