Skip to content

Commit c69c874

Browse files
author
Paul
committed
Supports now Env in parser definition and file mounts in parser definition and scan
1 parent 5ec4d86 commit c69c874

9 files changed

Lines changed: 5105 additions & 0 deletions

‎operator/apis/execution/v1/parsedefinition_types.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,17 @@ type ParseDefinitionSpec struct {
3333
Image string `json:"image,omitempty"`
3434
// ImagePullSecrets used to access private parser images
3535
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
36+
3637
// TTLSecondsAfterFinished configures the ttlSecondsAfterFinished field for the created parse job
3738
// +nullable
3839
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`
40+
41+
// Env allows to specify environment vars for the parser container.
42+
Env []corev1.EnvVar `json:"env,omitempty"`
43+
// Volumes allows to specify volumes for the parser container.
44+
Volumes []corev1.Volume `json:"volumes,omitempty"`
45+
// VolumeMounts allows to specify volume mounts for the parser container.
46+
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
3947
}
4048

4149
// ParseDefinitionStatus defines the observed state of ParseDefinition

‎operator/apis/execution/v1/scan_types.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ type ScanSpec struct {
3535

3636
// Env allows to specify environment vars for the scanner container. These will be merged will the env vars specified for the first container of the pod defined in the ScanType
3737
Env []corev1.EnvVar `json:"env,omitempty"`
38+
// Volumes allows to specify volumes for the scan container.
39+
Volumes []corev1.Volume `json:"volumes,omitempty"`
40+
// VolumeMounts allows to specify volume mounts for the scan container.
41+
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
3842

3943
Cascades *metav1.LabelSelector `json:"cascades,omitempty"`
4044
}

‎operator/apis/execution/v1/zz_generated.deepcopy.go‎

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎operator/config/crd/bases/cascading.securecodebox.io_cascadingrules.yaml‎

Lines changed: 1253 additions & 0 deletions
Large diffs are not rendered by default.

‎operator/config/crd/bases/execution.securecodebox.io_parsedefinitions.yaml‎

Lines changed: 1312 additions & 0 deletions
Large diffs are not rendered by default.

‎operator/config/crd/bases/execution.securecodebox.io_scans.yaml‎

Lines changed: 1214 additions & 0 deletions
Large diffs are not rendered by default.

‎operator/config/crd/bases/execution.securecodebox.io_scheduledscans.yaml‎

Lines changed: 1253 additions & 0 deletions
Large diffs are not rendered by default.

‎operator/controllers/execution/scans/parse_reconciler.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
158158
},
159159
}
160160

161+
// Merge Env from ParserTemplate
162+
job.Spec.Template.Spec.Containers[0].Env = append(
163+
job.Spec.Template.Spec.Containers[0].Env,
164+
parseDefinition.Spec.Env...,
165+
)
166+
// Merge VolumeMounts from ParserTemplate
167+
job.Spec.Template.Spec.Containers[0].VolumeMounts = append(
168+
job.Spec.Template.Spec.Containers[0].VolumeMounts,
169+
parseDefinition.Spec.VolumeMounts...,
170+
)
171+
// Merge Volumes from ParserTemplate
172+
job.Spec.Template.Spec.Volumes = append(
173+
job.Spec.Template.Spec.Volumes,
174+
parseDefinition.Spec.Volumes...,
175+
)
176+
161177
if err := ctrl.SetControllerReference(scan, job, r.Scheme); err != nil {
162178
return err
163179
}

‎operator/controllers/execution/scans/scan_reconciler.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,16 @@ func (r *ScanReconciler) constructJobForScan(scan *executionv1.Scan, scanType *e
292292
job.Spec.Template.Spec.Containers[0].Env,
293293
scan.Spec.Env...,
294294
)
295+
// Merge VolumeMounts from ScanTemplate with VolumeMounts defined in scan
296+
job.Spec.Template.Spec.Containers[0].VolumeMounts = append(
297+
job.Spec.Template.Spec.Containers[0].VolumeMounts,
298+
scan.Spec.VolumeMounts...,
299+
)
300+
// Merge Volumes from ScanTemplate with Volumes defined in scan
301+
job.Spec.Template.Spec.Volumes = append(
302+
job.Spec.Template.Spec.Volumes,
303+
scan.Spec.Volumes...,
304+
)
295305

296306
// Using command over args
297307
job.Spec.Template.Spec.Containers[0].Command = command

0 commit comments

Comments
 (0)