fix: prompt for input on app cp
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
fc5107865b
commit
82d560a946
|
@ -13,10 +13,10 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetContainer retrieves a container. If prompt is true and the retrievd count
|
// GetContainer retrieves a container. If noInput is false and the retrievd
|
||||||
// of containers does not match 1, then a prompt is presented to let the user
|
// count of containers does not match 1, then a prompt is presented to let the
|
||||||
// choose. A count of 0 is handled gracefully.
|
// user choose. A count of 0 is handled gracefully.
|
||||||
func GetContainer(c context.Context, cl *client.Client, filters filters.Args, prompt bool) (types.Container, error) {
|
func GetContainer(c context.Context, cl *client.Client, filters filters.Args, noInput bool) (types.Container, error) {
|
||||||
containerOpts := types.ContainerListOptions{Filters: filters}
|
containerOpts := types.ContainerListOptions{Filters: filters}
|
||||||
containers, err := cl.ContainerList(c, containerOpts)
|
containers, err := cl.ContainerList(c, containerOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -37,7 +37,7 @@ func GetContainer(c context.Context, cl *client.Client, filters filters.Args, pr
|
||||||
containersRaw = append(containersRaw, fmt.Sprintf("%s (created %v)", trimmed, created))
|
containersRaw = append(containersRaw, fmt.Sprintf("%s (created %v)", trimmed, created))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !prompt {
|
if noInput {
|
||||||
err := fmt.Errorf("expected 1 container but found %v: %s", len(containers), strings.Join(containersRaw, " "))
|
err := fmt.Errorf("expected 1 container but found %v: %s", len(containers), strings.Join(containersRaw, " "))
|
||||||
return types.Container{}, err
|
return types.Container{}, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue