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)
| 25 | // persistent-home initializer to pick a "primary" workspace image. |
| 26 | // If no such component exists, it returns an empty string. |
| 27 | func 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 | } |