@@ -25,20 +25,31 @@ func MergeDevWorkspaceTemplateSpec(
25
25
parentFlattenedContent * workspaces.DevWorkspaceTemplateSpecContent ,
26
26
pluginFlattenedContents ... * workspaces.DevWorkspaceTemplateSpecContent ) (* workspaces.DevWorkspaceTemplateSpecContent , error ) {
27
27
28
- allContents := []* workspaces.DevWorkspaceTemplateSpecContent {parentFlattenedContent }
29
- allContents = append ( allContents , pluginFlattenedContents ... )
30
- allContents = append (allContents , mainContent )
31
-
32
- if err := ensureNoConflictWithParent ( mainContent , parentFlattenedContent ); err != nil {
33
- return nil , err
28
+ allContents := []* workspaces.DevWorkspaceTemplateSpecContent {}
29
+ if parentFlattenedContent != nil {
30
+ allContents = append (allContents , parentFlattenedContent )
31
+ }
32
+ if len ( pluginFlattenedContents ) > 0 {
33
+ allContents = append ( allContents , pluginFlattenedContents ... )
34
34
}
35
+ allContents = append (allContents , mainContent )
35
36
36
- if err := ensureNoConflictsWithPlugins (mainContent , pluginFlattenedContents ... ); err != nil {
37
- return nil , err
37
+ // Check for conflicts
38
+ if parentFlattenedContent != nil {
39
+ if err := ensureNoConflictWithParent (mainContent , parentFlattenedContent ); err != nil {
40
+ return nil , err
41
+ }
38
42
}
39
- // also need to ensure no conflict between parent and plugins
40
- if err := ensureNoConflictsWithPlugins (parentFlattenedContent , pluginFlattenedContents ... ); err != nil {
41
- return nil , err
43
+ if len (pluginFlattenedContents ) > 0 {
44
+ if err := ensureNoConflictsWithPlugins (mainContent , pluginFlattenedContents ... ); err != nil {
45
+ return nil , err
46
+ }
47
+ if parentFlattenedContent != nil {
48
+ // also need to ensure no conflict between parent and plugins
49
+ if err := ensureNoConflictsWithPlugins (parentFlattenedContent , pluginFlattenedContents ... ); err != nil {
50
+ return nil , err
51
+ }
52
+ }
42
53
}
43
54
44
55
result := workspaces.DevWorkspaceTemplateSpecContent {}
0 commit comments