本文整理汇总了Golang中github.com/crunchydata/crunchy-postgresql-manager/types.Container.ClusterName方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.ClusterName方法的具体用法?Golang Container.ClusterName怎么用?Golang Container.ClusterName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/crunchydata/crunchy-postgresql-manager/types.Container
的用法示例。
在下文中一共展示了Container.ClusterName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetAllContainers
// GetAllContainers returns a list of all containers
func GetAllContainers(dbConn *sql.DB) ([]types.Container, error) {
var rows *sql.Rows
var err error
queryStr := fmt.Sprintf("select c.id, c.name, c.clusterid, c.role, c.image, to_char(c.createdt, 'MM-DD-YYYY HH24:MI:SS'), p.id, p.name from project p, container c where c.projectid = p.id order by c.name")
logit.Info.Println("admindb:GetAllContainers:" + queryStr)
rows, err = dbConn.Query(queryStr)
if err != nil {
return nil, err
}
defer rows.Close()
var clustername string
containers := make([]types.Container, 0)
for rows.Next() {
container := types.Container{}
if err = rows.Scan(&container.ID, &container.Name, &container.ClusterID, &container.Role, &container.Image, &container.CreateDate, &container.ProjectID, &container.ProjectName); err != nil {
return nil, err
}
logit.Info.Println("cluster id is [" + container.ClusterID + "]")
if container.ClusterID != "-1" {
clustername, err = GetClusterName(dbConn, container.ClusterID)
if err != nil {
logit.Info.Println("admindb:GetAllContainers:error " + err.Error())
return nil, err
}
container.ClusterName = clustername
}
containers = append(containers, container)
}
if err = rows.Err(); err != nil {
return nil, err
}
return containers, nil
}
示例2: GetContainerPgpool
// GetContainerPgpool find the pgpool container in a cluster
func GetContainerPgpool(dbConn *sql.DB, clusterid string) (types.Container, error) {
//logit.Info.Println("admindb:GetContainerMaster:called")
container := types.Container{}
queryStr := fmt.Sprintf("select c.id, c.name, c.clusterid, c.role, c.image, to_char(c.createdt, 'MM-DD-YYYY HH24:MI:SS'), p.id, p.name from project p, container c where c.role = 'pgpool' and c.clusterid = %s and c.projectid = p.id", clusterid)
logit.Info.Println("admindb:GetContainerPgpool:" + queryStr)
err := dbConn.QueryRow(queryStr).Scan(&container.ID, &container.Name, &container.ClusterID, &container.Role, &container.Image, &container.CreateDate, &container.ProjectID, &container.ProjectName)
switch {
case err == sql.ErrNoRows:
logit.Info.Println("admindb:GetContainerPgpool: no pgpool container with that clusterid " + clusterid)
return container, err
case err != nil:
return container, err
}
if container.ClusterID != "-1" {
var clustername string
clustername, err = GetClusterName(dbConn, container.ClusterID)
if err != nil {
logit.Info.Println("admindb:GetContainerPgPool:error " + err.Error())
return container, err
}
container.ClusterName = clustername
}
return container, nil
}
示例3: GetAllContainersNotInCluster
// GetAllContainersNotInCluster is used to fetch all nodes that are eligible to be added into a cluster
func GetAllContainersNotInCluster(dbConn *sql.DB) ([]types.Container, error) {
var rows *sql.Rows
var err error
queryStr := fmt.Sprintf("select c.id, c.name, c.clusterid, c.role, c.image, to_char(c.createdt, 'MM-DD-YYYY HH24:MI:SS'), p.id, p.name, l.name from project p, container c left join cluster l on c.clusterid = l.id where c.role != 'standalone' and c.clusterid = -1 and c.projectid = p.id order by c.name")
logit.Info.Println("admindb:GetAllContainersNotInCluster:" + queryStr)
rows, err = dbConn.Query(queryStr)
if err != nil {
return nil, err
}
defer rows.Close()
containers := make([]types.Container, 0)
for rows.Next() {
container := types.Container{}
if err = rows.Scan(&container.ID, &container.Name, &container.ClusterID, &container.Role, &container.Image, &container.CreateDate, &container.ProjectID, &container.ProjectName, &container.ClusterName); err != nil {
return nil, err
}
container.ClusterName = container.ClusterID
containers = append(containers, container)
}
if err = rows.Err(); err != nil {
return nil, err
}
return containers, nil
}