Skip to content

Commit c67f08e

Browse files
committed
Add ttlSecondsAfterFinished field to hook and parser crd
1 parent ab76a2d commit c67f08e

9 files changed

Lines changed: 38 additions & 4 deletions

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ 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+
// TTLSecondsAfterFinished configures the ttlSecondsAfterFinished field for the created parse job
37+
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`
3638
}
3739

3840
// ParseDefinitionStatus defines the observed state of ParseDefinition

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ type ScanCompletionHookSpec struct {
4646
Type HookType `json:"type"`
4747
// ServiceAccountName Name of the serviceAccount Name used. Should only be used if your hook needs specifc RBAC Access. Otherwise the hook is run using a "scan-completion-hook" service account. The service account should have at least "get" rights on scans.execution.securecodebox.io, and "get" & "patch" scans.execution.securecodebox.io/status
4848
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
49+
// TTLSecondsAfterFinished configures the ttlSecondsAfterFinished field for the created hook job
50+
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`
4951
}
5052

5153
// ScanCompletionHookStatus defines the observed state of ScanCompletionHook

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

Lines changed: 10 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/execution.securecodebox.io_parsedefinitions.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ spec:
5656
type: string
5757
type: object
5858
type: array
59+
ttlSecondsAfterFinished:
60+
description: TTLSecondsAfterFinished configures the ttlSecondsAfterFinished
61+
field for the created parse job
62+
format: int32
63+
type: integer
5964
type: object
6065
status:
6166
description: ParseDefinitionStatus defines the observed state of ParseDefinition

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ spec:
163163
service account should have at least "get" rights on scans.execution.securecodebox.io,
164164
and "get" & "patch" scans.execution.securecodebox.io/status
165165
type: string
166+
ttlSecondsAfterFinished:
167+
description: TTLSecondsAfterFinished configures the ttlSecondsAfterFinished
168+
field for the created hook job
169+
format: int32
170+
type: integer
166171
type:
167172
description: HookType Defines weather the hook should be able to change
168173
the findings or is run in a read only mode.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ func (r *ScanReconciler) createJobForHook(hook *executionv1.ScanCompletionHook,
372372
Labels: labels,
373373
},
374374
Spec: batch.JobSpec{
375-
BackoffLimit: &backOffLimit,
375+
TTLSecondsAfterFinished: hook.Spec.TTLSecondsAfterFinished,
376+
BackoffLimit: &backOffLimit,
376377
Template: corev1.PodTemplateSpec{
377378
ObjectMeta: metav1.ObjectMeta{
378379
Annotations: map[string]string{
@@ -414,7 +415,6 @@ func (r *ScanReconciler) createJobForHook(hook *executionv1.ScanCompletionHook,
414415
},
415416
},
416417
},
417-
TTLSecondsAfterFinished: nil,
418418
},
419419
}
420420
if err := ctrl.SetControllerReference(scan, job, r.Scheme); err != nil {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
9595
Labels: labels,
9696
},
9797
Spec: batch.JobSpec{
98-
BackoffLimit: &backOffLimit,
98+
TTLSecondsAfterFinished: parseDefinition.Spec.TTLSecondsAfterFinished,
99+
BackoffLimit: &backOffLimit,
99100
Template: corev1.PodTemplateSpec{
100101
ObjectMeta: metav1.ObjectMeta{
101102
Annotations: map[string]string{
@@ -154,7 +155,6 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
154155
AutomountServiceAccountToken: &automountServiceAccountToken,
155156
},
156157
},
157-
TTLSecondsAfterFinished: nil,
158158
},
159159
}
160160

‎operator/crds/execution.securecodebox.io_parsedefinitions.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ spec:
5656
type: string
5757
type: object
5858
type: array
59+
ttlSecondsAfterFinished:
60+
description: TTLSecondsAfterFinished configures the ttlSecondsAfterFinished
61+
field for the created parse job
62+
format: int32
63+
type: integer
5964
type: object
6065
status:
6166
description: ParseDefinitionStatus defines the observed state of ParseDefinition

‎operator/crds/execution.securecodebox.io_scancompletionhooks.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ spec:
163163
service account should have at least "get" rights on scans.execution.securecodebox.io,
164164
and "get" & "patch" scans.execution.securecodebox.io/status
165165
type: string
166+
ttlSecondsAfterFinished:
167+
description: TTLSecondsAfterFinished configures the ttlSecondsAfterFinished
168+
field for the created hook job
169+
format: int32
170+
type: integer
166171
type:
167172
description: HookType Defines weather the hook should be able to change
168173
the findings or is run in a read only mode.

0 commit comments

Comments
 (0)