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

Function InferWorkspaceImage

pkg/library/home/util.go:27–38  ·  view source on GitHub ↗

InferWorkspaceImage finds the first non-imported container component image in the flattened devfile template. This mirrors the selection rule used by the built-in persistent-home initializer to pick a "primary" workspace image. If no such component exists, it returns an empty string.

(dwTemplate *v1alpha2.DevWorkspaceTemplateSpec)

Source from the content-addressed store, hash-verified

25// persistent-home initializer to pick a "primary" workspace image.
26// If no such component exists, it returns an empty string.
27func InferWorkspaceImage(dwTemplate *v1alpha2.DevWorkspaceTemplateSpec) string {
28 for _, component := range dwTemplate.Components {
29 if component.Container == nil {
30 continue
31 }
32 pluginSource := component.Attributes.GetString(constants.PluginSourceAttribute, nil)
33 if pluginSource == "" || pluginSource == "parent" {
34 return component.Container.Image
35 }
36 }
37 return ""
38}

Callers 2

inferInitContainerFunction · 0.85
TestInferWorkspaceImageFunction · 0.85

Calls 1

GetStringMethod · 0.80

Tested by 1

TestInferWorkspaceImageFunction · 0.68