コード例 #1
0
ファイル: task_defs.go プロジェクト: takasing/screwdriver
func generateListTaskDefinitionsInput(prefix string, max int64, token string, desc bool, status string) *ecs.ListTaskDefinitionsInput {
	var input *ecs.ListTaskDefinitionsInput
	sort := "ASC"
	if desc {
		sort = "DESC"
	}
	input = &ecs.ListTaskDefinitionsInput{
		MaxResults: &max,
		NextToken:  &token,
		Sort:       &sort,
		Status:     &status,
	}
	// if set empty string to FamilyPrefix, return empty list
	if prefix != "" {
		input.FamilyPrefix = &prefix
	}
	return input
}
コード例 #2
0
ファイル: tasks.go プロジェクト: masonoise/ecsman
//
// Print the task definitions
//
func PrintTasks(session *session.Session, taskFamily string, taskRevision string) {
	var wantedRevision string
	if taskRevision == "latest" {
		wantedRevision = "latest"
	} else {
		wantedRevision = fmt.Sprintf("%s:%s", taskFamily, taskRevision)
	}
	awsConn := GetEcsConnection(session)
	listInput := ecs.ListTaskDefinitionsInput{}
	if taskFamily != "" {
		listInput.FamilyPrefix = &taskFamily
	}
	taskDefList, err := awsConn.ListTaskDefinitions(&listInput)
	CheckError("fetching task definitions list", err)

	families := map[string]string{}
	for taskIndex, taskdef := range taskDefList.TaskDefinitionArns {
		revision := getRevisionFromTaskDefinition(*taskdef)
		if taskFamily == "" { // Print a list of the families
			splitRevision := str.Split(revision, ":")
			families[splitRevision[0]] = splitRevision[1]
		} else {
			if wantedRevision == "latest" {
				if taskIndex+1 == len(taskDefList.TaskDefinitionArns) {
					PrintTaskDefinition(awsConn, taskdef, true)
				}
			} else {
				if (taskRevision == "") || (wantedRevision == revision) {
					PrintTaskDefinition(awsConn, taskdef, true)
				}
			}
		}
	}
	if taskFamily == "" {
		fmt.Println("Task Definition families:")
		for family, rev := range families {
			fmt.Printf("  %s (latest revision: %s)\n", family, rev)
		}
	}
}