本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/ecs.ECS.DescribeTaskDefinition方法的典型用法代碼示例。如果您正苦於以下問題:Golang ECS.DescribeTaskDefinition方法的具體用法?Golang ECS.DescribeTaskDefinition怎麽用?Golang ECS.DescribeTaskDefinition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aws/aws-sdk-go/service/ecs.ECS
的用法示例。
在下文中一共展示了ECS.DescribeTaskDefinition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PrintTaskDefinition
//
// Function to print the details of a service's task definition, since it's got a lot of fiddly details.
//
func PrintTaskDefinition(awsConn *ecs.ECS, taskDefinition *string, verboseFlag bool) {
// Fetch the details of the task definition.
taskDef, err := awsConn.DescribeTaskDefinition(&ecs.DescribeTaskDefinitionInput{
TaskDefinition: taskDefinition,
})
CheckError(fmt.Sprintf("fetching Task Definition for %s", *taskDefinition), err)
fmt.Println(" - Task Definition:", *taskDefinition)
fmt.Println(" - Family:", *taskDef.TaskDefinition.Family)
for _, containerDef := range taskDef.TaskDefinition.ContainerDefinitions {
fmt.Println(" - Container Definition:")
fmt.Println(" - Image:", *containerDef.Image)
if verboseFlag {
fmt.Println(" - CPU:", *containerDef.Cpu)
fmt.Println(" - Memory:", *containerDef.Memory)
}
for _, portMap := range containerDef.PortMappings {
fmt.Println(" - Container Port", *portMap.ContainerPort, ": Host Port", *portMap.HostPort)
}
if len(containerDef.Command) > 0 {
fmt.Printf(" - Command: %v\n", containerDef.Command)
}
if len(containerDef.EntryPoint) > 0 {
fmt.Printf(" - Entry Point: %v\n", containerDef.EntryPoint)
}
if (len(containerDef.Environment) > 0) && (verboseFlag) {
fmt.Println(" - Environment:")
for _, envVariable := range containerDef.Environment {
fmt.Println(" ", *envVariable.Name, "=", *envVariable.Value)
}
}
}
}
示例2: setImage
// setImage
// Create a new Task Definition based on an existing
// ARN, and a new image.
//
// Returns new task's ARN
//
func setImage(svc *ecs.ECS, taskArn string, image string) (string, error) {
params := &ecs.DescribeTaskDefinitionInput{TaskDefinition: aws.String(taskArn)}
resp, err := svc.DescribeTaskDefinition(params)
if err != nil {
return "", err
}
task := resp.TaskDefinition
task.ContainerDefinitions[0].Image = &image
regResp, err := svc.RegisterTaskDefinition(&ecs.RegisterTaskDefinitionInput{
Family: task.Family,
ContainerDefinitions: task.ContainerDefinitions,
Volumes: task.Volumes,
})
return *regResp.TaskDefinition.TaskDefinitionArn, nil
}