Skip to content
Closed
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: 2 additions & 2 deletions pkg/compose/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (s *composeService) createLayers(ctx context.Context, project *types.Projec
for _, file := range project.ComposeFiles {
data, err := processFile(ctx, file, project, extFiles, envFiles)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to process compose file %s: %w", file, err)
}

layerDescriptor := oci.DescriptorForComposeFile(file, data)
Expand Down Expand Up @@ -235,7 +235,7 @@ func processExtends(ctx context.Context, project *types.Project, extFiles map[st
for xf, hash := range extFiles {
data, err := processFile(ctx, xf, project, moreExtFiles, envFiles)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to process compose file %s: %w", xf, err)
}

layerDescriptor := oci.DescriptorForComposeFile(hash, data)
Expand Down
20 changes: 20 additions & 0 deletions pkg/compose/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ services:
}, cmp.Ignore()))
}

// a processFile failure must say which file it came from: a project can
// carry many compose files and its extends references add more, so an
// unattributed error leaves the user guessing which one to fix
func Test_createLayers_error_includes_file_name(t *testing.T) {
project := &types.Project{Name: "test", WorkingDir: t.TempDir()}
project.ComposeFiles = []string{filepath.Join(t.TempDir(), "missing.yaml")}

service := &composeService{}
_, err := service.createLayers(t.Context(), project, api.PublishOptions{})
assert.ErrorContains(t, err, "failed to process compose file")
assert.ErrorContains(t, err, "missing.yaml")
}

func Test_processExtends_error_includes_file_name(t *testing.T) {
extFile := filepath.Join(t.TempDir(), "missing.yaml")
_, err := processExtends(t.Context(), &types.Project{Name: "test"}, map[string]string{extFile: "deadbeef"})
assert.ErrorContains(t, err, "failed to process compose file")
assert.ErrorContains(t, err, "missing.yaml")
}

func Test_preChecks_sensitive_data_detected_decline(t *testing.T) {
dir := t.TempDir()
envPath := dir + "/secrets.env"
Expand Down