@@ -75,6 +75,8 @@ func GetObjectMeta(name, namespace string, labels, annotations map[string]string
75
75
}
76
76
77
77
// GetContainers iterates through all container components, filters out init containers and returns corresponding containers
78
+ //
79
+ // Deprecated in favor of GetPodTemplateSpec
78
80
func GetContainers (devfileObj parser.DevfileObj , options common.DevfileOptions ) ([]corev1.Container , error ) {
79
81
allContainers , err := getAllContainers (devfileObj , options )
80
82
if err != nil {
@@ -121,6 +123,8 @@ func GetContainers(devfileObj parser.DevfileObj, options common.DevfileOptions)
121
123
}
122
124
123
125
// GetInitContainers gets the init container for every preStart devfile event
126
+ //
127
+ // Deprecated in favor of GetPodTemplateSpec
124
128
func GetInitContainers (devfileObj parser.DevfileObj ) ([]corev1.Container , error ) {
125
129
containers , err := getAllContainers (devfileObj , common.DevfileOptions {})
126
130
if err != nil {
@@ -171,10 +175,14 @@ func GetInitContainers(devfileObj parser.DevfileObj) ([]corev1.Container, error)
171
175
172
176
// DeploymentParams is a struct that contains the required data to create a deployment object
173
177
type DeploymentParams struct {
174
- TypeMeta metav1.TypeMeta
175
- ObjectMeta metav1.ObjectMeta
176
- InitContainers []corev1.Container
177
- Containers []corev1.Container
178
+ TypeMeta metav1.TypeMeta
179
+ ObjectMeta metav1.ObjectMeta
180
+ // Deprecated. InitContainers, Containers and Volumes are deprecated and are replaced by PodTemplateSpec.
181
+ // A PodTemplateSpec value can be obtained calling GetPodTemplateSpec function, instead of calling GetContainers and GetInitContainers
182
+ InitContainers []corev1.Container
183
+ // Deprecated, see InitContainers
184
+ Containers []corev1.Container
185
+ // Deprecated, see InitContainers
178
186
Volumes []corev1.Volume
179
187
PodTemplateSpec * corev1.PodTemplateSpec
180
188
PodSelectorLabels map [string ]string
@@ -233,6 +241,12 @@ type PodTemplateParams struct {
233
241
PodSecurityAdmissionPolicy psaapi.Policy
234
242
}
235
243
244
+ // GetPodTemplateSpec returns a pod template
245
+ // The function:
246
+ // - iterates through all container components, filters out init containers and gets corresponding containers
247
+ // - gets the init container for every preStart devfile event
248
+ // - patches the pod template and containers to satisfy PodSecurityAdmissionPolicy
249
+ // - patches the pod template and containers to apply pod and container overrides
236
250
func GetPodTemplateSpec (devfileObj parser.DevfileObj , podTemplateParams PodTemplateParams ) (* corev1.PodTemplateSpec , error ) {
237
251
containers , err := GetContainers (devfileObj , common.DevfileOptions {})
238
252
if err != nil {
0 commit comments