Skip to content

Commit 066a9af

Browse files
committed
fixup! feat: implicit container contributions
1 parent ca623f9 commit 066a9af

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

pkg/library/flatten/merge.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,35 +226,35 @@ func mergeContainerContributions(flattenedSpec *dw.DevWorkspaceTemplateSpec) err
226226
//
227227
// If no suitable merge target is found, an error is returned.
228228
func findMergeTarget(flattenedSpec *dw.DevWorkspaceTemplateSpec) (mergeTargetComponentName string, err error) {
229-
// First check for explicit merge contributtion attribute
229+
firstComponent := ""
230230
for _, component := range flattenedSpec.Components {
231231
if component.Container == nil {
232232
continue
233233
}
234234

235235
if component.Attributes.Exists(constants.MergeContributionAttribute) {
236+
// Check for explicit merge contributtion attribute
236237
if component.Attributes.GetBoolean(constants.MergeContributionAttribute, nil) {
237238
return component.Name, nil
238239
}
239-
}
240-
}
241-
242-
// Then see if there's a container that can implicitly be selected as a merge target
243-
for _, component := range flattenedSpec.Components {
244-
if component.Container == nil {
245-
continue
246-
}
247-
248-
// Don't select components that opt out as a merge contribution target
249-
if component.Attributes.Exists(constants.MergeContributionAttribute) && !component.Attributes.GetBoolean(constants.MergeContributionAttribute, nil) {
240+
// Don't select components that opt out as a merge contribution target
250241
continue
251242
}
252243

253244
// The target must not have been imported by a plugin or parent.
254245
if component.Attributes.Exists(constants.PluginSourceAttribute) {
255246
continue
256247
}
257-
return component.Name, nil
248+
249+
// There might be other components that explicitly opt in as a merge target,
250+
// so don't return immediately
251+
if firstComponent == "" {
252+
firstComponent = component.Name
253+
}
254+
}
255+
256+
if firstComponent != "" {
257+
return firstComponent, nil
258258
}
259259

260260
return "", fmt.Errorf("couldn't find any merge contribution target component")

0 commit comments

Comments
 (0)