Skip to content

Commit e3d1c45

Browse files
committed
fix error check and function desc
Signed-off-by: Stephanie <[email protected]>
1 parent 86d3c1c commit e3d1c45

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

pkg/devfile/parser/parse.go

+6-15
Original file line numberDiff line numberDiff line change
@@ -193,22 +193,16 @@ func parseParentAndPlugin(d DevfileObj, resolveCtx *resolutionContextTree, tool
193193
switch {
194194
case parent.Uri != "":
195195
parentDevfileObj, err = parseFromURI(parent.ImportReference, d.Ctx, resolveCtx, tool)
196-
if err != nil {
197-
return err
198-
}
199196
case parent.Id != "":
200197
parentDevfileObj, err = parseFromRegistry(parent.ImportReference, resolveCtx, tool)
201-
if err != nil {
202-
return err
203-
}
204198
case parent.Kubernetes != nil:
205199
parentDevfileObj, err = parseFromKubeCRD(parent.ImportReference, resolveCtx, tool)
206-
if err != nil {
207-
return err
208-
}
209200
default:
210201
return fmt.Errorf("devfile parent does not define any resources")
211202
}
203+
if err != nil {
204+
return err
205+
}
212206

213207
parentWorkspaceContent := parentDevfileObj.Data.GetDevfileWorkspaceSpecContent()
214208
// add attribute to parent elements
@@ -247,19 +241,16 @@ func parseParentAndPlugin(d DevfileObj, resolveCtx *resolutionContextTree, tool
247241
switch {
248242
case plugin.Uri != "":
249243
pluginDevfileObj, err = parseFromURI(plugin.ImportReference, d.Ctx, resolveCtx, tool)
250-
if err != nil {
251-
return err
252-
}
253244
case plugin.Id != "":
254245
pluginDevfileObj, err = parseFromRegistry(plugin.ImportReference, resolveCtx, tool)
255-
if err != nil {
256-
return err
257-
}
258246
case plugin.Kubernetes != nil:
259247
pluginDevfileObj, err = parseFromKubeCRD(plugin.ImportReference, resolveCtx, tool)
260248
default:
261249
return fmt.Errorf("plugin %s does not define any resources", component.Name)
262250
}
251+
if err != nil {
252+
return err
253+
}
263254
pluginWorkspaceContent := pluginDevfileObj.Data.GetDevfileWorkspaceSpecContent()
264255
// add attribute to plugin elements
265256
err = addSourceAttributesForOverrideAndMerge(plugin.ImportReference, pluginWorkspaceContent)

pkg/devfile/parser/sourceAttribute.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88

99
const (
1010
importSourceAttribute = "library.devfile.io/imported-from"
11-
pluginOverrideAttribute = "library.devfile.io/plugin-override-from"
1211
parentOverrideAttribute = "library.devfile.io/parent-override-from"
12+
pluginOverrideAttribute = "library.devfile.io/plugin-override-from"
1313
)
1414

15-
// addSourceAttributesForTemplateSpecContent adds an attribute 'library.devfile.io/parent-override-from=<source reference>'
15+
// addSourceAttributesForParentOverride adds an attribute 'library.devfile.io/imported-from=<source reference>'
1616
// to all elements of template spec content that support attributes.
1717
func addSourceAttributesForTemplateSpecContent(sourceImportReference v1.ImportReference, template *v1.DevWorkspaceTemplateSpecContent) {
1818
for idx, component := range template.Components {
@@ -41,7 +41,7 @@ func addSourceAttributesForTemplateSpecContent(sourceImportReference v1.ImportRe
4141
}
4242
}
4343

44-
// addSourceAttributesForParentOverride adds an attribute 'library.devfile.io/imported-from=<source reference>'
44+
// addSourceAttributesForParentOverride adds an attribute 'library.devfile.io/parent-override-from=<source reference>'
4545
// to all elements of parent override that support attributes.
4646
func addSourceAttributesForParentOverride(sourceImportReference v1.ImportReference, parentOverrides *v1.ParentOverrides) {
4747
for idx, component := range parentOverrides.Components {

0 commit comments

Comments
 (0)