本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}