本文整理汇总了Golang中github.com/docker/libcompose/project.APIProject类的典型用法代码示例。如果您正苦于以下问题:Golang APIProject类的具体用法?Golang APIProject怎么用?Golang APIProject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了APIProject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: ProjectEvents
// ProjectEvents listen for real-time events of containers.
func ProjectEvents(p project.APIProject, c *cli.Context) error {
evts, err := p.Events(context.Background(), c.Args()...)
if err != nil {
return err
}
var printfn func(events.ContainerEvent)
if c.Bool("json") {
printfn = printJSON
} else {
printfn = printStd
}
for event := range evts {
printfn(event)
}
return nil
}
开发者ID:vdemeester,项目名称:rancher-compose,代码行数:18,代码来源:events.go
示例17: ProjectRun
// ProjectRun runs a given command within a service's container.
func ProjectRun(p project.APIProject, c *cli.Context) error {
if len(c.Args()) == 0 {
logrus.Fatal("No service specified")
}
serviceName := c.Args()[0]
commandParts := c.Args()[1:]
options := options.Run{
Detached: c.Bool("d"),
}
exitCode, err := p.Run(context.Background(), serviceName, commandParts, options)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return cli.NewExitError("", exitCode)
}
开发者ID:vdemeester,项目名称:rancher-compose,代码行数:19,代码来源:app.go
示例18: ProjectUp
// ProjectUp brings all services up.
func ProjectUp(p project.APIProject, c *cli.Context) error {
options := options.Up{
Create: options.Create{
NoRecreate: c.Bool("no-recreate"),
ForceRecreate: c.Bool("force-recreate"),
NoBuild: c.Bool("no-build"),
ForceBuild: c.Bool("build"),
},
}
ctx, cancelFun := context.WithCancel(context.Background())
err := p.Up(ctx, options, c.Args()...)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
if !c.Bool("d") {
signalChan := make(chan os.Signal, 1)
cleanupDone := make(chan bool)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
errChan := make(chan error)
go func() {
errChan <- p.Log(ctx, true, c.Args()...)
}()
go func() {
select {
case <-signalChan:
fmt.Printf("\nGracefully stopping...\n")
cancelFun()
ProjectStop(p, c)
cleanupDone <- true
case err := <-errChan:
if err != nil {
logrus.Fatal(err)
}
cleanupDone <- true
}
}()
<-cleanupDone
return nil
}
return nil
}
开发者ID:vdemeester,项目名称:rancher-compose,代码行数:42,代码来源:app.go
示例19: upgradeInfo
func upgradeInfo(up bool, p project.APIProject, from, to string, opts UpgradeOpts) (*client.Service, *client.Service, *client.RancherClient, error) {
fromService, err := p.CreateService(from)
if err != nil {
return nil, nil, nil, err
}
toService, err := p.CreateService(to)
if err != nil {
return nil, nil, nil, err
}
rFromService, ok := fromService.(*rancher.RancherService)
if !ok {
return nil, nil, nil, fmt.Errorf("%s is not a Rancher service", from)
}
rToService, ok := toService.(*rancher.RancherService)
if !ok {
return nil, nil, nil, fmt.Errorf("%s is not a Rancher service", to)
}
if up {
if err := rToService.Up(context.Background(), options.Up{}); err != nil {
return nil, nil, nil, err
}
}
source, err := rFromService.RancherService()
if err != nil {
return nil, nil, nil, err
}
dest, err := rToService.RancherService()
if err != nil {
return nil, nil, nil, err
}
return source, dest, rFromService.Client(), nil
}
开发者ID:vdemeester,项目名称:rancher-compose,代码行数:39,代码来源:upgrade.go
示例20: ProjectScale
// ProjectScale scales services.
func ProjectScale(p project.APIProject, c *cli.Context) error {
servicesScale := map[string]int{}
for _, arg := range c.Args() {
kv := strings.SplitN(arg, "=", 2)
if len(kv) != 2 {
return cli.NewExitError(fmt.Sprintf("Invalid scale parameter: %s", arg), 2)
}
name := kv[0]
count, err := strconv.Atoi(kv[1])
if err != nil {
return cli.NewExitError(fmt.Sprintf("Invalid scale parameter: %v", err), 2)
}
servicesScale[name] = count
}
err := p.Scale(context.Background(), c.Int("timeout"), servicesScale)
if err != nil {
return cli.NewExitError(err.Error(), 0)
}
return nil
}
开发者ID:vdemeester,项目名称:rancher-compose,代码行数:25,代码来源:app.go
注:本文中的github.com/docker/libcompose/project.APIProject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论