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


Golang project.APIProject類代碼示例

本文整理匯總了Golang中github.com/docker/libcompose/project.APIProject的典型用法代碼示例。如果您正苦於以下問題:Golang APIProject類的具體用法?Golang APIProject怎麽用?Golang APIProject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: ProjectPull

// ProjectPull pulls images for services.
func ProjectPull(p project.APIProject, c *cli.Context) error {
	err := p.Pull(context.Background(), c.Args()...)
	if err != nil && !c.Bool("ignore-pull-failures") {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:8,代碼來源:app.go

示例2: ProjectDelete

// ProjectDelete deletes services.
func ProjectDelete(p project.APIProject, c *cli.Context) error {
	options := options.Delete{
		RemoveVolume: c.Bool("v"),
	}
	if !c.Bool("force") {
		stoppedContainers, err := p.Containers(context.Background(), project.Filter{
			State: project.Stopped,
		}, c.Args()...)
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}
		if len(stoppedContainers) == 0 {
			fmt.Println("No stopped containers")
			return nil
		}
		fmt.Printf("Going to remove %v\nAre you sure? [yN]\n", strings.Join(stoppedContainers, ", "))
		var answer string
		_, err = fmt.Scanln(&answer)
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}
		if answer != "y" && answer != "Y" {
			return nil
		}
	}
	err := p.Delete(context.Background(), options, c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:libcompose,代碼行數:32,代碼來源:app.go

示例3: ProjectUnpause

// ProjectUnpause unpauses service containers.
func ProjectUnpause(p project.APIProject, c *cli.Context) error {
	err := p.Unpause(context.Background(), c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:8,代碼來源:app.go

示例4: ProjectStop

// ProjectStop stops all services.
func ProjectStop(p project.APIProject, c *cli.Context) error {
	err := p.Stop(context.Background(), c.Int("timeout"), c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:8,代碼來源:app.go

示例5: ProjectLog

// ProjectLog gets services logs.
func ProjectLog(p project.APIProject, c *cli.Context) error {
	err := p.Log(context.Background(), c.Bool("follow"), c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:8,代碼來源:app.go

示例6: ProjectKill

// ProjectKill forces stop service containers.
func ProjectKill(p project.APIProject, c *cli.Context) error {
	err := p.Kill(context.Background(), c.String("signal"), c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:8,代碼來源:app.go

示例7: ProjectPs

// ProjectPs lists the containers.
func ProjectPs(p project.APIProject, c *cli.Context) error {
	qFlag := c.Bool("q")
	allInfo, err := p.Ps(context.Background(), qFlag, c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	os.Stdout.WriteString(allInfo.String(!qFlag))
	return nil
}
開發者ID:jainvipin,項目名稱:libcompose,代碼行數:10,代碼來源:app.go

示例8: ProjectDelete

// ProjectDelete deletes services.
func ProjectDelete(p project.APIProject, c *cli.Context) error {
	options := options.Delete{
		RemoveVolume: c.Bool("v"),
	}
	err := p.Delete(context.Background(), options, c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:11,代碼來源:app.go

示例9: ProjectConfig

// ProjectConfig validates and print the compose file.
func ProjectConfig(p project.APIProject, c *cli.Context) error {
	yaml, err := p.Config()
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	if !c.Bool("quiet") {
		fmt.Println(yaml)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:11,代碼來源:app.go

示例10: ProjectCreate

func ProjectCreate(p project.APIProject, c *cli.Context) error {
	if err := p.Create(context.Background(), options.Create{}, c.Args()...); err != nil {
		return err
	}

	// This is to fix circular links... What!? It works.
	if err := p.Create(context.Background(), options.Create{}, c.Args()...); err != nil {
		return err
	}

	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:12,代碼來源:app.go

示例11: ProjectBuild

// ProjectBuild builds or rebuilds services.
func ProjectBuild(p project.APIProject, c *cli.Context) error {
	config := options.Build{
		NoCache:     c.Bool("no-cache"),
		ForceRemove: c.Bool("force-rm"),
		Pull:        c.Bool("pull"),
	}
	err := p.Build(context.Background(), config, c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:13,代碼來源:app.go

示例12: ProjectCreate

// ProjectCreate creates all services but do not start them.
func ProjectCreate(p project.APIProject, c *cli.Context) error {
	options := options.Create{
		NoRecreate:    c.Bool("no-recreate"),
		ForceRecreate: c.Bool("force-recreate"),
		NoBuild:       c.Bool("no-build"),
	}
	err := p.Create(context.Background(), options, c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:13,代碼來源:app.go

示例13: ProjectDown

// ProjectDown brings all services down (stops and clean containers).
func ProjectDown(p project.APIProject, c *cli.Context) error {
	options := options.Down{
		RemoveVolume:  c.Bool("volumes"),
		RemoveImages:  options.ImageType(c.String("rmi")),
		RemoveOrphans: c.Bool("remove-orphans"),
	}
	err := p.Down(context.Background(), options, c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:13,代碼來源:app.go

示例14: ProjectPs

// ProjectPs lists the containers.
func ProjectPs(p project.APIProject, c *cli.Context) error {
	qFlag := c.Bool("q")
	allInfo, err := p.Ps(context.Background(), c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	columns := []string{"Name", "Command", "State", "Ports"}
	if qFlag {
		columns = []string{"Id"}
	}
	os.Stdout.WriteString(allInfo.String(columns, !qFlag))
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:14,代碼來源:app.go

示例15: ProjectPort

// ProjectPort prints the public port for a port binding.
func ProjectPort(p project.APIProject, c *cli.Context) error {
	if len(c.Args()) != 2 {
		return cli.NewExitError("Please pass arguments in the form: SERVICE PORT", 1)
	}

	index := c.Int("index")
	protocol := c.String("protocol")
	serviceName := c.Args()[0]
	privatePort := c.Args()[1]

	port, err := p.Port(context.Background(), index, protocol, serviceName, privatePort)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	fmt.Println(port)
	return nil
}
開發者ID:vdemeester,項目名稱:rancher-compose,代碼行數:18,代碼來源:app.go


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