diff --git a/cmd/prompt/prompt.go b/cmd/prompt/prompt.go index 87379f5eb61..39011f7c1c7 100644 --- a/cmd/prompt/prompt.go +++ b/cmd/prompt/prompt.go @@ -97,6 +97,8 @@ type Pipe struct { func (u Pipe) Confirm(message string, defaultValue bool) (bool, error) { _, _ = fmt.Fprint(u.stdout, message) var answer string - _, _ = fmt.Fscanln(u.stdin, &answer) + if _, err := fmt.Fscanln(u.stdin, &answer); err != nil { + return defaultValue, nil + } return utils.StringToBool(answer), nil } diff --git a/pkg/compose/publish_test.go b/pkg/compose/publish_test.go index 3b0e5a4389c..fc3321789ed 100644 --- a/pkg/compose/publish_test.go +++ b/pkg/compose/publish_test.go @@ -134,6 +134,32 @@ func Test_preChecks_sensitive_data_detected_decline(t *testing.T) { assert.Equal(t, accept, false) } +func Test_preChecks_bind_mount_skipped_with_assume_yes(t *testing.T) { + project := &types.Project{ + Services: types.Services{ + "web": { + Name: "web", + Image: "nginx", + Volumes: []types.ServiceVolumeConfig{ + { + Type: types.VolumeTypeBind, + Source: "/host/path", + Target: "/container/path", + }, + }, + }, + }, + } + + svc := &composeService{ + prompt: AlwaysOkPrompt(), + } + + accept, err := svc.preChecks(t.Context(), project, api.PublishOptions{}) + assert.NilError(t, err) + assert.Equal(t, accept, true) +} + func Test_publish_decline_returns_ErrCanceled(t *testing.T) { project := &types.Project{ Services: types.Services{