本文整理匯總了Golang中github.com/tsuru/tsuru/provision/docker/container.Container.AppName方法的典型用法代碼示例。如果您正苦於以下問題:Golang Container.AppName方法的具體用法?Golang Container.AppName怎麽用?Golang Container.AppName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/tsuru/provision/docker/container.Container
的用法示例。
在下文中一共展示了Container.AppName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newContainer
func (s *S) newContainer(opts *newContainerOpts, p *dockerProvisioner) (*container.Container, error) {
container := container.Container{
ID: "id",
IP: "10.10.10.10",
HostPort: "3333",
HostAddr: "127.0.0.1",
ProcessName: "web",
ExposedPort: "8888/tcp",
}
if p == nil {
p = s.p
}
image := "tsuru/python:latest"
var customData map[string]interface{}
if opts != nil {
if opts.Image != "" {
image = opts.Image
}
container.Status = opts.Status
container.AppName = opts.AppName
container.ProcessName = opts.ProcessName
customData = opts.ImageCustomData
if opts.Provisioner != nil {
p = opts.Provisioner
}
}
err := s.newFakeImage(p, image, customData)
if err != nil {
return nil, err
}
if container.AppName == "" {
container.AppName = "container"
}
routertest.FakeRouter.AddBackend(container.AppName)
routertest.FakeRouter.AddRoute(container.AppName, container.Address())
ports := map[docker.Port]struct{}{
docker.Port(s.port + "/tcp"): {},
}
config := docker.Config{
Image: image,
Cmd: []string{"ps"},
ExposedPorts: ports,
}
createOptions := docker.CreateContainerOptions{Config: &config}
createOptions.Name = randomString()
_, c, err := p.Cluster().CreateContainer(createOptions)
if err != nil {
return nil, err
}
container.ID = c.ID
container.Image = image
container.Name = createOptions.Name
conn, err := db.Conn()
if err != nil {
return nil, err
}
defer conn.Close()
err = conn.Collection(s.collName).Insert(&container)
if err != nil {
return nil, err
}
imageId, err := appCurrentImageName(container.AppName)
if err != nil {
return nil, err
}
err = s.newFakeImage(p, imageId, nil)
if err != nil {
return nil, err
}
return &container, nil
}