本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/ecs.ECS.ListClusters方法的典型用法代码示例。如果您正苦于以下问题:Golang ECS.ListClusters方法的具体用法?Golang ECS.ListClusters怎么用?Golang ECS.ListClusters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/aws-sdk-go/service/ecs.ECS
的用法示例。
在下文中一共展示了ECS.ListClusters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ListClusters
// ListClusters will return a slice of ECS Clusters
func ListClusters(svc *ecs.ECS) ([]*string, error) {
var clusters []*string
// List clusters
reqParams := &ecs.ListClustersInput{
MaxResults: aws.Int64(100),
NextToken: aws.String(""),
}
for {
resp, err := svc.ListClusters(reqParams)
// Error check
if err != nil {
return nil, fmt.Errorf("ecs.ListClusters: %s", err.Error())
}
// Expand slice of clusters and append to our comprehensive list
clusters = append(clusters, resp.ClusterArns...)
// Cycle token
if resp.NextToken != nil {
reqParams.NextToken = resp.NextToken
} else {
// Kill loop ... out of clusters
break
}
}
return clusters, nil
}
示例2: ListClusters
// ListClusters List ECS clusters
func ListClusters(svc *ecs.ECS, maxResults *int64) (*ecs.ListClustersOutput, error) {
params := &ecs.ListClustersInput{
MaxResults: maxResults,
}
resp, err := svc.ListClusters(params)
if err != nil {
return nil, err
}
return resp, nil
}
示例3: findClusterArn
// findClusterArn finds a cluster's arn from a more human
// readable name
func findClusterArn(svc *ecs.ECS, clusterName string) (string, error) {
params := &ecs.ListClustersInput{}
clusters, err := svc.ListClusters(params)
if err != nil {
return "", err
}
for _, clusterId := range clusters.ClusterArns {
var pattern string = `/` + clusterName + `$`
matched, _ := regexp.MatchString(pattern, *clusterId)
if matched {
return *clusterId, nil
}
}
return "", errors.New("Could not find cluster with name: " + clusterName)
}