本文整理匯總了Golang中github.com/tsuru/tsuru/provision.App.GetTeamsName方法的典型用法代碼示例。如果您正苦於以下問題:Golang App.GetTeamsName方法的具體用法?Golang App.GetTeamsName怎麽用?Golang App.GetTeamsName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/tsuru/provision.App
的用法示例。
在下文中一共展示了App.GetTeamsName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Nodes
func (p *dockerProvisioner) Nodes(app provision.App) ([]cluster.Node, error) {
pool := app.GetPool()
var (
pools []provision.Pool
err error
)
if pool == "" {
pools, err = provision.ListPools(bson.M{"$or": []bson.M{{"teams": app.GetTeamOwner()}, {"teams": bson.M{"$in": app.GetTeamsName()}}}})
} else {
pools, err = provision.ListPools(bson.M{"_id": pool})
}
if err != nil {
return nil, err
}
if len(pools) == 0 {
query := bson.M{"default": true}
pools, err = provision.ListPools(query)
if err != nil {
return nil, err
}
}
if len(pools) == 0 {
return nil, errNoDefaultPool
}
for _, pool := range pools {
nodes, err := p.Cluster().NodesForMetadata(map[string]string{"pool": pool.Name})
if err != nil {
return nil, errNoDefaultPool
}
if len(nodes) > 0 {
return nodes, nil
}
}
var nameList []string
for _, pool := range pools {
nameList = append(nameList, pool.Name)
}
poolsStr := strings.Join(nameList, ", pool=")
return nil, fmt.Errorf("No nodes found with one of the following metadata: pool=%s", poolsStr)
}