当前位置: 首页>>代码示例>>Golang>>正文


Golang core.Context类代码示例

本文整理汇总了Golang中github.com/opentable/sous/core.Context的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Context类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: DockerRun

func (t *AppTarget) DockerRun(c *core.Context) *docker.Run {
	dr := docker.NewRun(c.DockerTag())
	port0, err := ports.GetFreePort()
	if err != nil {
		cli.Fatalf("Unable to get free port: %s", err)
	}
	dr.AddEnv("PORT0", strconv.Itoa(port0))
	dr.AddEnv("TASK_HOST", core.DivineTaskHost())
	return dr
}
开发者ID:liamjbennett,项目名称:sous,代码行数:10,代码来源:app_target.go

示例2: DockerRun

// DockerRun returns a configured *docker.Run, which is used to create a new
// container when the old one is stale or does not exist.
func (t *CompileTarget) DockerRun(c *core.Context) *docker.Run {
	containerName := t.ContainerName(c)
	run := docker.NewRun(c.DockerTag())
	run.Name = containerName
	run.AddEnv("ARTIFACT_NAME", t.artifactName(c))
	uid := cmd.Stdout("id", "-u")
	gid := cmd.Stdout("id", "-g")
	artifactOwner := fmt.Sprintf("%s:%s", uid, gid)
	run.AddEnv("ARTIFACT_OWNER", artifactOwner)
	artDir := t.artifactDir(c)
	dir.EnsureExists(artDir)
	run.AddVolume(artDir, "/artifacts")
	run.AddVolume(c.WorkDir, "/wd")
	run.Command = "npm install"
	return run
}
开发者ID:liamjbennett,项目名称:sous,代码行数:18,代码来源:compile_target.go

示例3: DockerRun

func (t *TestTarget) DockerRun(c *core.Context) *docker.Run {
	containerName := t.ContainerName(c)
	run := docker.NewRun(c.DockerTag())
	run.Name = containerName
	//run.AddEnv("ARTIFACT_NAME", t.artifactName(c))
	uid := cmd.Stdout("id", "-u")
	gid := cmd.Stdout("id", "-g")
	artifactOwner := fmt.Sprintf("%s:%s", uid, gid)
	run.AddEnv("ARTIFACT_OWNER", artifactOwner)
	artDir := t.artifactDir(c)
	dir.EnsureExists(artDir)
	run.AddVolume(artDir, "/artifacts")
	run.AddVolume(c.WorkDir, "/wd")
	run.Command = fmt.Sprintf("go generate && { [ -d Godeps ] && godep go test ./... || go test ./...; }")
	return run
}
开发者ID:liamjbennett,项目名称:sous,代码行数:16,代码来源:test_target.go

示例4: Dockerfile

func (t *AppTarget) Dockerfile(c *core.Context) *docker.Dockerfile {
	if t.artifactPath == "" {
		// Actually, it is first set by compile target, then the PreDockerBuild
		// step links it into the WD and resets artifactPath to a local, relative
		// path.
		t.artifactPath = "<¡ artifact path set by compile target !>"
	}
	df := &docker.Dockerfile{}
	df.From = t.pack.baseImageTag("app")

	// Since the artifact is tar.gz, and the dest is a directory, docker automatically unpacks it.
	df.AddAdd(t.artifactPath, "/srv/app/")
	// Pick out the contents of NPM start to invoke directly (using npm start in
	// production shields the app from signals, which are required to be handled by
	// the app itself to do graceful shutdown.
	df.Entrypoint = []string{
		fmt.Sprintf("/srv/app/%s-%s", c.CanonicalPackageName(), c.BuildVersion),
	}
	return df
}
开发者ID:liamjbennett,项目名称:sous,代码行数:20,代码来源:app_target.go

示例5: Dockerfile

func (t *TestTarget) Dockerfile(c *core.Context) *docker.Dockerfile {
	df := &docker.Dockerfile{}
	df.From = t.pack.baseImageTag("test")
	c.TemporaryLinkResource("build-prep.bash")
	buildPrepContainerPath := "/build-prep.bash"
	df.AddAdd("build-prep.bash", buildPrepContainerPath)
	df.AddRun(fmt.Sprintf("chmod +x %s", buildPrepContainerPath))
	uid := cmd.Stdout("id", "-u")
	gid := cmd.Stdout("id", "-g")
	username := cmd.Stdout("whoami")
	// Just use the username for group name, it doesn't matter as long as
	// the IDs are right.
	groupAdd := fmt.Sprintf("groupadd -g %s %s", gid, username)
	// Explanation of some of the below useradd flags:
	//   -M means do not create home directory, which we do not need
	//   --no-log-init means do not create a 32G sparse file (which Docker commit
	//       cannot handle properly, and tries to create a non-sparse 32G file.)
	userAdd := fmt.Sprintf("useradd --no-log-init -M --uid %s --gid %s %s", uid, gid, username)
	df.AddRun(fmt.Sprintf("%s && %s", groupAdd, userAdd))
	df.Entrypoint = []string{"/build-prep.bash"}
	return df
}
开发者ID:liamjbennett,项目名称:sous,代码行数:22,代码来源:test_target.go

示例6: ContainerName

// ContainerName returns the name that will be given to the next container we
// build. This does not have to change for each build, Sous will automatically
// deleted any pre-existing containers with this name before creating a new one.
func (t *CompileTarget) ContainerName(c *core.Context) string {
	return fmt.Sprintf("%s_reusable-builder", c.CanonicalPackageName())
}
开发者ID:liamjbennett,项目名称:sous,代码行数:6,代码来源:compile_target.go

示例7: ImageTag

// ImageTag return the tag that should be applied to the next image we build.
func (t *CompileTarget) ImageTag(c *core.Context) string {
	return strconv.Itoa(c.BuildNumber())
}
开发者ID:liamjbennett,项目名称:sous,代码行数:4,代码来源:compile_target.go

示例8: artifactName

func (t *CompileTarget) artifactName(c *core.Context) string {
	return fmt.Sprintf("%s-%s-%s-%d", c.CanonicalPackageName(), c.BuildVersion, c.Git.CommitSHA, c.BuildNumber())
}
开发者ID:liamjbennett,项目名称:sous,代码行数:3,代码来源:compile_target.go

示例9: artifactDir

func (t *CompileTarget) artifactDir(c *core.Context) string {
	return c.FilePath("artifacts")
}
开发者ID:liamjbennett,项目名称:sous,代码行数:3,代码来源:compile_target.go

示例10: ContainerName

func (t *TestTarget) ContainerName(c *core.Context) string {
	return c.CanonicalPackageName() + "_test"
}
开发者ID:liamjbennett,项目名称:sous,代码行数:3,代码来源:test_target.go

示例11: ContainerName

func (t *AppTarget) ContainerName(c *core.Context) string {
	return c.CanonicalPackageName()
}
开发者ID:liamjbennett,项目名称:sous,代码行数:3,代码来源:app_target.go


注:本文中的github.com/opentable/sous/core.Context类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。