MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / getSourceForComponent

Function getSourceForComponent

pkg/library/env/workspaceenv.go:221–230  ·  view source on GitHub ↗

getSourceForComponent returns the 'original' name for a component in a flattened DevWorkspace. Given a component, it returns the name of the plugin component that imported it if the component came via a plugin, and the actual component name otherwise. Returned name is prefixed with "component " -- e

(component dw.Component)

Source from the content-addressed store, hash-verified

219// The purpose of this function is mainly to enable providing better messages to end-users, as a component name may
220// not match the name of the plugin in the original DevWorkspace.
221func getSourceForComponent(component dw.Component) string {
222 if component.Attributes.Exists(constants.PluginSourceAttribute) {
223 var err error
224 componentName := component.Attributes.GetString(constants.PluginSourceAttribute, &err)
225 if err == nil {
226 return fmt.Sprintf("component %s", componentName)
227 }
228 }
229 return fmt.Sprintf("component %s", component.Name)
230}

Callers 1

collectWorkspaceEnvFunction · 0.85

Calls 2

ExistsMethod · 0.80
GetStringMethod · 0.80

Tested by

no test coverage detected