本文整理汇总了Golang中github.com/tsuru/tsuru/provision.App.SetUpdatePlatform方法的典型用法代码示例。如果您正苦于以下问题:Golang App.SetUpdatePlatform方法的具体用法?Golang App.SetUpdatePlatform怎么用?Golang App.SetUpdatePlatform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/provision.App
的用法示例。
在下文中一共展示了App.SetUpdatePlatform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ImageDeploy
func (p *dockerProvisioner) ImageDeploy(app provision.App, imageId string, w io.Writer) (string, error) {
cluster := p.Cluster()
pullOpts := docker.PullImageOptions{
Repository: imageId,
}
err := cluster.PullImage(pullOpts, docker.AuthConfiguration{})
if err != nil {
return "", err
}
cmd := "cat /home/application/current/Procfile || cat /app/user/Procfile || cat /Procfile"
output, err := p.runCommandInContainer(imageId, cmd, app)
if err != nil {
return "", err
}
procfile := getProcessesFromProcfile(output.String())
if len(procfile) == 0 {
imageInspect, inspectErr := cluster.InspectImage(imageId)
if inspectErr != nil {
return "", inspectErr
}
if len(imageInspect.Config.Entrypoint) == 0 {
return "", ErrEntrypointOrProcfileNotFound
}
procfile["web"] = strings.Join(imageInspect.Config.Entrypoint, " ")
}
newImage, err := appNewImageName(app.GetName())
if err != nil {
return "", err
}
imageInfo := strings.Split(newImage, ":")
err = cluster.TagImage(imageId, docker.TagImageOptions{Repo: strings.Join(imageInfo[:len(imageInfo)-1], ":"), Tag: imageInfo[len(imageInfo)-1], Force: true})
if err != nil {
return "", err
}
registry, err := config.GetString("docker:registry")
if err != nil {
return "", err
}
pushOpts := docker.PushImageOptions{
Name: strings.Join(imageInfo[:len(imageInfo)-1], ":"),
Tag: imageInfo[len(imageInfo)-1],
Registry: registry,
}
err = cluster.PushImage(pushOpts, mainDockerProvisioner.RegistryAuthConfig())
if err != nil {
return "", err
}
imageData := createImageMetadata(newImage, procfile)
err = saveImageCustomData(newImage, imageData.CustomData)
if err != nil {
return "", err
}
app.SetUpdatePlatform(true)
return newImage, p.deploy(app, newImage, w)
}
示例2: ImageDeploy
func (p *swarmProvisioner) ImageDeploy(a provision.App, imgID string, evt *event.Event) (string, error) {
client, err := chooseDBSwarmNode()
if err != nil {
return "", err
}
if !strings.Contains(imgID, ":") {
imgID = fmt.Sprintf("%s:latest", imgID)
}
fmt.Fprintln(evt, "---- Pulling image to tsuru ----")
var buf bytes.Buffer
cmds := []string{"/bin/bash", "-c", "cat /home/application/current/Procfile || cat /app/user/Procfile || cat /Procfile"}
srvID, task, err := runOnceBuildCmds(client, a, cmds, imgID, "", &buf)
if srvID != "" {
defer removeServiceAndLog(client, srvID)
}
if err != nil {
return "", err
}
client, err = clientForNode(client, task.NodeID)
if err != nil {
return "", err
}
newImage, err := dockercommon.PrepareImageForDeploy(dockercommon.PrepareImageArgs{
Client: client,
App: a,
ProcfileRaw: buf.String(),
ImageId: imgID,
Out: evt,
})
if err != nil {
return "", err
}
a.SetUpdatePlatform(true)
err = deployProcesses(client, a, newImage, nil)
if err != nil {
return "", err
}
return newImage, nil
}
示例3: ImageDeploy
func (p *dockerProvisioner) ImageDeploy(app provision.App, imageId string, w io.Writer) (string, error) {
cluster := p.Cluster()
if !strings.Contains(imageId, ":") {
imageId = fmt.Sprintf("%s:latest", imageId)
}
fmt.Fprintln(w, "---- Pulling image to tsuru ----")
pullOpts := docker.PullImageOptions{
Repository: imageId,
OutputStream: w,
}
err := cluster.PullImage(pullOpts, docker.AuthConfiguration{})
if err != nil {
return "", err
}
fmt.Fprintln(w, "---- Getting process from image ----")
cmd := "cat /home/application/current/Procfile || cat /app/user/Procfile || cat /Procfile"
output, _ := p.runCommandInContainer(imageId, cmd, app)
procfile := getProcessesFromProcfile(output.String())
if len(procfile) == 0 {
fmt.Fprintln(w, " ---> Procfile not found, trying to get entrypoint")
imageInspect, inspectErr := cluster.InspectImage(imageId)
if inspectErr != nil {
return "", inspectErr
}
if len(imageInspect.Config.Entrypoint) == 0 {
return "", ErrEntrypointOrProcfileNotFound
}
webProcess := imageInspect.Config.Entrypoint[0]
for _, c := range imageInspect.Config.Entrypoint[1:] {
webProcess += fmt.Sprintf(" %q", c)
}
procfile["web"] = webProcess
}
for k, v := range procfile {
fmt.Fprintf(w, " ---> Process %s found with command: %v\n", k, v)
}
newImage, err := appNewImageName(app.GetName())
if err != nil {
return "", err
}
imageInfo := strings.Split(newImage, ":")
err = cluster.TagImage(imageId, docker.TagImageOptions{Repo: strings.Join(imageInfo[:len(imageInfo)-1], ":"), Tag: imageInfo[len(imageInfo)-1], Force: true})
if err != nil {
return "", err
}
registry, err := config.GetString("docker:registry")
if err != nil {
return "", err
}
fmt.Fprintln(w, "---- Pushing image to tsuru ----")
pushOpts := docker.PushImageOptions{
Name: strings.Join(imageInfo[:len(imageInfo)-1], ":"),
Tag: imageInfo[len(imageInfo)-1],
Registry: registry,
OutputStream: w,
}
err = cluster.PushImage(pushOpts, mainDockerProvisioner.RegistryAuthConfig())
if err != nil {
return "", err
}
imageData := createImageMetadata(newImage, procfile)
err = saveImageCustomData(newImage, imageData.CustomData)
if err != nil {
return "", err
}
app.SetUpdatePlatform(true)
return newImage, p.deploy(app, newImage, w)
}