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


Golang ContainerDefinition.Name方法代碼示例

本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/ecs.ContainerDefinition.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang ContainerDefinition.Name方法的具體用法?Golang ContainerDefinition.Name怎麽用?Golang ContainerDefinition.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/aws/aws-sdk-go/service/ecs.ContainerDefinition的用法示例。


在下文中一共展示了ContainerDefinition.Name方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: containerDef

func containerDef(family *string, containerPort *int64, hostPort *int64, image *string, cpu *int64, memory *int64, essential bool, links []*string) *ecs.ContainerDefinition {
	portMapping := &ecs.PortMapping{
		ContainerPort: containerPort,
		HostPort:      hostPort,
		Protocol:      aws.String("tcp"),
	}
	mountPoint := &ecs.MountPoint{
		ContainerPath: aws.String("/var/www/" + (*family) + "-vol"),
		SourceVolume:  aws.String(*family + "-vol"),
		ReadOnly:      aws.Bool(false),
	}
	c := ecs.ContainerDefinition{}

	c.Name = aws.String(*family + "-app")
	c.Image = image
	c.Cpu = cpu
	c.Memory = memory
	c.Essential = aws.Bool(essential)
	c.Links = links
	if *hostPort != 0 {
		c.PortMappings = []*ecs.PortMapping{portMapping}
	}
	c.MountPoints = []*ecs.MountPoint{mountPoint}
	return &c
}
開發者ID:gawkermedia,項目名稱:ecs,代碼行數:25,代碼來源:task.go

示例2: makeTaskDefinition

//
// Called by createTask() above. Given a filename, parse the JSON file and create a ContainerDefinition
// struct that can be passed to the SDK to create the task definition.
//
func makeTaskDefinition(taskFile string) (ecs.ContainerDefinition, string) {
	var taskJSON TaskDefn
	// Do it the easy way and read in the whole file. A JSON file's not going to be very large.
	fileBytes, err := ioutil.ReadFile(taskFile)
	CheckError(fmt.Sprintf("Error reading task file %s", taskFile), err)
	err = json.Unmarshal(fileBytes, &taskJSON)
	CheckError(fmt.Sprintf("Error reading task file %s", taskFile), err)
	// TODO: Support more than one if it's ever needed.
	if len(taskJSON.ContainerDefinitions) > 1 {
		fmt.Println("Right now I only support a single ContainerDefinition, sorry. Please edit and try again.")
		os.Exit(1)
	}

	// Now let's construct our Container Definition object, which is a lot of boring copying of fields.
	var defn ecs.ContainerDefinition
	defn.Cpu = &taskJSON.ContainerDefinitions[0].CPU
	var commands = make([]*string, 0)
	for i := 0; i < len(taskJSON.ContainerDefinitions[0].Command); i++ {
		commands = append(commands, &taskJSON.ContainerDefinitions[0].Command[i])
	}
	defn.Command = commands
	var entrypoints = make([]*string, 0)
	for i := 0; i < len(taskJSON.ContainerDefinitions[0].EntryPoint); i++ {
		entrypoints = append(entrypoints, &taskJSON.ContainerDefinitions[0].EntryPoint[i])
	}
	defn.EntryPoint = entrypoints
	var environments = make([]*ecs.KeyValuePair, 0)
	for i := 0; i < len(taskJSON.ContainerDefinitions[0].Environment); i++ {
		var keyval ecs.KeyValuePair
		keyval.Name = taskJSON.ContainerDefinitions[0].Environment[i].Name
		keyval.Value = taskJSON.ContainerDefinitions[0].Environment[i].Value
		environments = append(environments, &keyval)
	}
	defn.Environment = environments
	defn.Essential = &taskJSON.ContainerDefinitions[0].Essential
	defn.Image = &taskJSON.ContainerDefinitions[0].Image
	defn.Memory = &taskJSON.ContainerDefinitions[0].Memory
	defn.Name = &taskJSON.ContainerDefinitions[0].Name
	var ports = make([]*ecs.PortMapping, 0)
	for i := 0; i < len(taskJSON.ContainerDefinitions[0].PortMappings); i++ {
		var portmap ecs.PortMapping
		portmap.ContainerPort = taskJSON.ContainerDefinitions[0].PortMappings[i].ContainerPort
		portmap.HostPort = taskJSON.ContainerDefinitions[0].PortMappings[i].HostPort
		ports = append(ports, &portmap)
	}
	defn.PortMappings = ports
	return defn, taskJSON.Family
}
開發者ID:masonoise,項目名稱:ecsman,代碼行數:52,代碼來源:tasks.go

示例3: registratorDefinition

func registratorDefinition(hostname *string, advertiseIP *string) *ecs.ContainerDefinition {
	c := ecs.ContainerDefinition{}
	c.Name = aws.String("kinja-consul-registrator")
	c.Hostname = hostname
	c.Image = aws.String("gliderlabs/registrator:latest")
	c.Cpu = aws.Int64(100)
	c.Memory = aws.Int64(64)
	c.Essential = aws.Bool(true)
	c.MountPoints = []*ecs.MountPoint{
		&ecs.MountPoint{
			ContainerPath: aws.String("/tmp/docker.sock"),
			SourceVolume:  aws.String("consul-socket"),
			ReadOnly:      aws.Bool(false),
		},
	}

	c.Command = []*string{
		//aws.String("-ip  $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"),
		aws.String("-ip=" + *advertiseIP),
		aws.String("consul://" + *advertiseIP + ":8500"),
	}
	return &c
}
開發者ID:gawkermedia,項目名稱:ecs,代碼行數:23,代碼來源:task.go

示例4: consulDefinition

func consulDefinition(hostname *string, serverIP *string, advertiseIP *string) *ecs.ContainerDefinition {
	c := ecs.ContainerDefinition{}
	c.Name = aws.String("kinja-consul-agent")
	c.Hostname = hostname
	c.Image = aws.String("progrium/consul")
	c.Cpu = aws.Int64(156)
	c.Memory = aws.Int64(256)
	c.Essential = aws.Bool(true)
	c.PortMappings = []*ecs.PortMapping{
		&ecs.PortMapping{
			ContainerPort: aws.Int64(8301),
			HostPort:      aws.Int64(8301),
			Protocol:      aws.String("tcp"),
		},
		&ecs.PortMapping{
			ContainerPort: aws.Int64(8301),
			HostPort:      aws.Int64(8301),
			Protocol:      aws.String("udp"),
		},
		&ecs.PortMapping{
			ContainerPort: aws.Int64(8400),
			HostPort:      aws.Int64(8400),
			Protocol:      aws.String("tcp"),
		},
		&ecs.PortMapping{
			ContainerPort: aws.Int64(8500),
			HostPort:      aws.Int64(8500),
			Protocol:      aws.String("tcp"),
		},
		&ecs.PortMapping{
			ContainerPort: aws.Int64(53),
			HostPort:      aws.Int64(53),
			Protocol:      aws.String("udp"),
		},
	}
	c.MountPoints = []*ecs.MountPoint{
		&ecs.MountPoint{
			ContainerPath: aws.String("/data"),
			SourceVolume:  aws.String("consul-vol"),
			ReadOnly:      aws.Bool(false),
		},
		&ecs.MountPoint{
			ContainerPath: aws.String("/var/run/docker.sock"),
			SourceVolume:  aws.String("consul-socket"),
			ReadOnly:      aws.Bool(false),
		},
		&ecs.MountPoint{
			ContainerPath: aws.String("/etc/consul"),
			SourceVolume:  aws.String("consul-config"),
			ReadOnly:      aws.Bool(false),
		},
	}

	session := sess.InitSession()

	c.Command = []*string{
		aws.String("--join " + *serverIP),
		//aws.String("--advertise  $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"),
		aws.String("--advertise " + *advertiseIP),
		aws.String("-dc " + *session.Config.Region),
		aws.String("--config-file /etc/consul/consul.json"),
	}
	return &c
}
開發者ID:gawkermedia,項目名稱:ecs,代碼行數:64,代碼來源:task.go


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