本文整理汇总了Golang中github.com/tsuru/tsuru/provision/docker/container.Container.Create方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.Create方法的具体用法?Golang Container.Create怎么用?Golang Container.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/provision/docker/container.Container
的用法示例。
在下文中一共展示了Container.Create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestFollowLogsAndCommitForward
func (s *S) TestFollowLogsAndCommitForward(c *check.C) {
err := s.newFakeImage(s.p, "tsuru/python", nil)
c.Assert(err, check.IsNil)
app := provisiontest.NewFakeApp("mightyapp", "python", 1)
nextImgName, err := appNewImageName(app.GetName())
c.Assert(err, check.IsNil)
cont := container.Container{AppName: "mightyapp", ID: "myid123", BuildingImage: nextImgName}
err = cont.Create(&container.CreateArgs{
App: app,
ImageID: "tsuru/python",
Commands: []string{"foo"},
Provisioner: s.p,
})
c.Assert(err, check.IsNil)
buf := safe.NewBuffer(nil)
args := runContainerActionsArgs{writer: buf, provisioner: s.p}
context := action.FWContext{Params: []interface{}{args}, Previous: cont}
imageId, err := followLogsAndCommit.Forward(context)
c.Assert(err, check.IsNil)
c.Assert(imageId, check.Equals, "tsuru/app-mightyapp:v1")
c.Assert(buf.String(), check.Not(check.Equals), "")
var dbCont container.Container
coll := s.p.Collection()
defer coll.Close()
err = coll.Find(bson.M{"id": cont.ID}).One(&dbCont)
c.Assert(err, check.NotNil)
c.Assert(err.Error(), check.Equals, "not found")
_, err = s.p.Cluster().InspectContainer(cont.ID)
c.Assert(err, check.NotNil)
c.Assert(err.Error(), check.Matches, "No such container.*")
err = s.p.Cluster().RemoveImage("tsuru/app-mightyapp:v1")
c.Assert(err, check.IsNil)
}
示例2: TestFollowLogsAndCommitForwardWaitFailure
func (s *S) TestFollowLogsAndCommitForwardWaitFailure(c *check.C) {
s.server.PrepareFailure("failed to wait for the container", "/containers/.*/wait")
defer s.server.ResetFailure("failed to wait for the container")
err := s.newFakeImage(s.p, "tsuru/python", nil)
c.Assert(err, check.IsNil)
app := provisiontest.NewFakeApp("myapp", "python", 1)
cont := container.Container{AppName: "mightyapp"}
err = cont.Create(&container.CreateArgs{
App: app,
ImageID: "tsuru/python",
Commands: []string{"foo"},
Provisioner: s.p,
})
c.Assert(err, check.IsNil)
err = cont.Start(&container.StartArgs{
Provisioner: s.p,
App: app,
})
c.Assert(err, check.IsNil)
err = cont.Stop(s.p)
c.Assert(err, check.IsNil)
buf := safe.NewBuffer(nil)
args := runContainerActionsArgs{writer: buf, provisioner: s.p}
context := action.FWContext{Params: []interface{}{args}, Previous: cont}
imageId, err := followLogsAndCommit.Forward(context)
c.Assert(err, check.ErrorMatches, `.*failed to wait for the container\n$`)
c.Assert(imageId, check.IsNil)
}
示例3: TestFollowLogsAndCommitForwardNonZeroStatus
func (s *S) TestFollowLogsAndCommitForwardNonZeroStatus(c *check.C) {
err := s.newFakeImage(s.p, "tsuru/python", nil)
c.Assert(err, check.IsNil)
app := provisiontest.NewFakeApp("myapp", "python", 1)
cont := container.Container{AppName: "mightyapp"}
err = cont.Create(&container.CreateArgs{
App: app,
ImageID: "tsuru/python",
Commands: []string{"foo"},
Provisioner: s.p,
})
c.Assert(err, check.IsNil)
err = s.server.MutateContainer(cont.ID, docker.State{ExitCode: 1})
c.Assert(err, check.IsNil)
buf := safe.NewBuffer(nil)
args := runContainerActionsArgs{writer: buf, provisioner: s.p}
context := action.FWContext{Params: []interface{}{args}, Previous: cont}
imageId, err := followLogsAndCommit.Forward(context)
c.Assert(err, check.NotNil)
c.Assert(err.Error(), check.Equals, "Exit status 1")
c.Assert(imageId, check.IsNil)
}