mirror of
https://github.com/docker/compose.git
synced 2026-08-31 06:49:15 +00:00
Progress functions can return a string, that can be used in the caller of progress.Run to display final result after progress display
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
9c07a7b3ad
commit
267b267201
6 changed files with 31 additions and 24 deletions
|
|
@ -46,11 +46,12 @@ func runDown(ctx context.Context, opts composeOptions) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return progress.Run(ctx, func(ctx context.Context) error {
|
||||
_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||
projectName, err := opts.toProjectName()
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
return c.ComposeService().Down(ctx, projectName)
|
||||
return projectName, c.ComposeService().Down(ctx, projectName)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,16 +49,17 @@ func runUp(ctx context.Context, opts composeOptions) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return progress.Run(ctx, func(ctx context.Context) error {
|
||||
_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||
options, err := opts.toProjectOptions()
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
project, err := cli.ProjectFromOptions(options)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
|
||||
return c.ComposeService().Up(ctx, project)
|
||||
return "", c.ComposeService().Up(ctx, project)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ func runRun(ctx context.Context, image string, opts run.Opts) error {
|
|||
return err
|
||||
}
|
||||
|
||||
err = progress.Run(ctx, func(ctx context.Context) error {
|
||||
return c.ContainerService().Run(ctx, containerConfig)
|
||||
result, err := progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||
return containerConfig.ID, c.ContainerService().Run(ctx, containerConfig)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -94,7 +94,6 @@ func runRun(ctx context.Context, image string, opts run.Opts) error {
|
|||
return c.ContainerService().Logs(ctx, opts.Name, req)
|
||||
}
|
||||
|
||||
fmt.Println(opts.Name)
|
||||
|
||||
fmt.Println(result)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,16 +57,17 @@ func createVolume() *cobra.Command {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = progress.Run(ctx, func(ctx context.Context) error {
|
||||
if _, err := c.VolumeService().Create(ctx, aciOpts); err != nil {
|
||||
return err
|
||||
result, err := progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||
volume, err := c.VolumeService().Create(ctx, aciOpts)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return nil
|
||||
return volume.ID, nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(aci.VolumeID(aciOpts.Account, aciOpts.Fileshare))
|
||||
fmt.Println(result)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue