Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
26 changes: 26 additions & 0 deletions pkg/compose/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down