@@ -226,35 +226,35 @@ func mergeContainerContributions(flattenedSpec *dw.DevWorkspaceTemplateSpec) err
226
226
//
227
227
// If no suitable merge target is found, an error is returned.
228
228
func findMergeTarget (flattenedSpec * dw.DevWorkspaceTemplateSpec ) (mergeTargetComponentName string , err error ) {
229
- // First check for explicit merge contributtion attribute
229
+ firstComponent := ""
230
230
for _ , component := range flattenedSpec .Components {
231
231
if component .Container == nil {
232
232
continue
233
233
}
234
234
235
235
if component .Attributes .Exists (constants .MergeContributionAttribute ) {
236
+ // Check for explicit merge contributtion attribute
236
237
if component .Attributes .GetBoolean (constants .MergeContributionAttribute , nil ) {
237
238
return component .Name , nil
238
239
}
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
250
241
continue
251
242
}
252
243
253
244
// The target must not have been imported by a plugin or parent.
254
245
if component .Attributes .Exists (constants .PluginSourceAttribute ) {
255
246
continue
256
247
}
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
258
258
}
259
259
260
260
return "" , fmt .Errorf ("couldn't find any merge contribution target component" )
0 commit comments