MCPcopy Create free account
hub / github.com/devfile/api / resolveErrorMessageWithImportAttributes

Function resolveErrorMessageWithImportAttributes

pkg/validation/errors.go:231–257  ·  view source on GitHub ↗

resolveErrorMessageWithImportAttributes returns an updated error message with detailed information on the imported and overriden resource. example: "the component is invalid - , imported from Uri: http://example.com/devfile.yaml, in parent overrides from main devfile"

(validationErr error, attributes attributesAPI.Attributes)

Source from the content-addressed store, hash-verified

229// example:
230// "the component <compName> is invalid - <reason>, imported from Uri: http://example.com/devfile.yaml, in parent overrides from main devfile"
231func resolveErrorMessageWithImportAttributes(validationErr error, attributes attributesAPI.Attributes) error {
232 var findKeyErr error
233 importReference := attributes.Get(ImportSourceAttribute, &findKeyErr)
234
235 // overridden element must contain import resource information
236 // an overridden element can be either parentOverride or pluginOverride
237 // example:
238 // if an element is imported from another devfile, but contains no overrides - ImportSourceAttribute
239 // if an element is from parentOverride - ImportSourceAttribute + ParentOverrideAttribute
240 // if an element is from pluginOverride - ImportSourceAttribute + PluginOverrideAttribute
241 if findKeyErr == nil {
242 validationErr = fmt.Errorf("%s, imported from %s", validationErr.Error(), importReference)
243 parentOverrideReference := attributes.Get(ParentOverrideAttribute, &findKeyErr)
244 if findKeyErr == nil {
245 validationErr = fmt.Errorf("%s, in parent overrides from %s", validationErr.Error(), parentOverrideReference)
246 } else {
247 // reset findKeyErr to nil
248 findKeyErr = nil
249 pluginOverrideReference := attributes.Get(PluginOverrideAttribute, &findKeyErr)
250 if findKeyErr == nil {
251 validationErr = fmt.Errorf("%s, in plugin overrides from %s", validationErr.Error(), pluginOverrideReference)
252 }
253 }
254 }
255
256 return validationErr
257}

Callers 5

ValidateCommandsFunction · 0.85
validateGroupFunction · 0.85
ValidateComponentsFunction · 0.85
ValidateStarterProjectsFunction · 0.85
ValidateProjectsFunction · 0.85

Calls 2

GetMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected