當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ECS.ListClusters方法代碼示例

本文整理匯總了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
}
開發者ID:colinmutter,項目名稱:go-ecs,代碼行數:33,代碼來源:ecs.go

示例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
}
開發者ID:gawkermedia,項目名稱:ecs,代碼行數:11,代碼來源:cluster.go

示例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)
}
開發者ID:oberd,項目名稱:aws-rollout,代碼行數:17,代碼來源:aws-rollout.go


注:本文中的github.com/aws/aws-sdk-go/service/ecs.ECS.ListClusters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。