Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 57babac

Browse files
Merge pull request #140 from secureCodeBox/crd-cleanup
Cleanup Unused / Badly named CRD Attributes
2 parents 8e80e91 + 7646d7f commit 57babac

10 files changed

+47
-48
lines changed

operator/apis/execution/v1/parsedefinition_types.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ type ParseDefinitionSpec struct {
2929
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
3030
// Important: Run "make" to regenerate code after modifying this file
3131

32-
// Foo is an example field of ParseDefinition. Edit ParseDefinition_types.go to remove/update
33-
HandlesResultsType string `json:"handlesResultsType,omitempty"`
34-
Image string `json:"image,omitempty"`
35-
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
32+
// Image is the reference to the parser container image which ca transform the raw scan report into findings
33+
Image string `json:"image,omitempty"`
34+
// ImagePullSecrets used to access private parser images
35+
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
3636
}
3737

3838
// ParseDefinitionStatus defines the observed state of ParseDefinition
@@ -42,7 +42,6 @@ type ParseDefinitionStatus struct {
4242
}
4343

4444
// +kubebuilder:object:root=true
45-
// +kubebuilder:printcolumn:name="Handles Type",type=string,JSONPath=`.spec.handlesResultsType`,description="Which result file type the parser is able to handle"
4645
// +kubebuilder:printcolumn:name="Image",type=string,JSONPath=`.spec.image`,description="Scanner Container Image"
4746

4847
// ParseDefinition is the Schema for the parsedefinitions API

operator/apis/execution/v1/scheduledscan_types.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ type ScheduledScanSpec struct {
2929
// Important: Run "make" to regenerate code after modifying this file
3030

3131
// Interval describes how often the scan should be repeated
32-
// Examples: '12h', '7d', '30m' (only days, hours and minutes supported, specified as integers)
32+
// Examples: '12h', '30m'
3333
Interval metav1.Duration `json:"interval"`
3434

35-
// HistoryLimit determines how many past Scans will be kept until the oldest one will be delted, defaults to 3. When set to 0 Scans will be deleted directly after completion
36-
HistoryLimit int64 `json:"historyLimit,omitempty"`
35+
// +kubebuilder:validation:Optional
36+
// +kubebuilder:validation:Minimum=0
3737

38-
// Foo is an example field of ScheduledScan. Edit ScheduledScan_types.go to remove/update
38+
// SuccessfulJobsHistoryLimit determines how many past Scans will be kept until the oldest one will be deleted, defaults to 3. When set to 0, Scans will be deleted directly after completion
39+
SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"`
40+
41+
// ScanSpec describes the scan which should be started regularly
3942
ScanSpec *ScanSpec `json:"scanSpec"`
4043
}
4144

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

Lines changed: 5 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: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ metadata:
99
name: parsedefinitions.execution.securecodebox.io
1010
spec:
1111
additionalPrinterColumns:
12-
- JSONPath: .spec.handlesResultsType
13-
description: Which result file type the parser is able to handle
14-
name: Handles Type
15-
type: string
1612
- JSONPath: .spec.image
1713
description: Scanner Container Image
1814
name: Image
@@ -44,13 +40,12 @@ spec:
4440
spec:
4541
description: ParseDefinitionSpec defines the desired state of ParseDefinition
4642
properties:
47-
handlesResultsType:
48-
description: Foo is an example field of ParseDefinition. Edit ParseDefinition_types.go
49-
to remove/update
50-
type: string
5143
image:
44+
description: Image is the reference to the parser container image which
45+
ca transform the raw scan report into findings
5246
type: string
5347
imagePullSecrets:
48+
description: ImagePullSecrets used to access private parser images
5449
items:
5550
description: LocalObjectReference contains enough information to let
5651
you locate the referenced object inside the same namespace.

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,12 @@ spec:
5959
spec:
6060
description: ScheduledScanSpec defines the desired state of ScheduledScan
6161
properties:
62-
historyLimit:
63-
description: HistoryLimit determines how many past Scans will be kept
64-
until the oldest one will be delted, defaults to 3. When set to 0
65-
Scans will be deleted directly after completion
66-
format: int64
67-
type: integer
6862
interval:
6963
description: 'Interval describes how often the scan should be repeated
70-
Examples: ''12h'', ''7d'', ''30m'' (only days, hours and minutes supported,
71-
specified as integers)'
64+
Examples: ''12h'', ''30m'''
7265
type: string
7366
scanSpec:
74-
description: Foo is an example field of ScheduledScan. Edit ScheduledScan_types.go
75-
to remove/update
67+
description: ScanSpec describes the scan which should be started regularly
7668
properties:
7769
cascades:
7870
description: A label selector is a label query over a set of resources.
@@ -232,6 +224,13 @@ spec:
232224
scanType:
233225
type: string
234226
type: object
227+
successfulJobsHistoryLimit:
228+
description: SuccessfulJobsHistoryLimit determines how many past Scans
229+
will be kept until the oldest one will be deleted, defaults to 3.
230+
When set to 0, Scans will be deleted directly after completion
231+
format: int32
232+
minimum: 0
233+
type: integer
235234
required:
236235
- interval
237236
- scanSpec

operator/config/samples/execution_v1_parsedefinition.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ kind: ParseDefinition
33
metadata:
44
name: "nmap-xml"
55
spec:
6-
handlesResultsType: nmap-xml
76
image: securecodebox/nmap-parser

operator/config/samples/execution_v1_scheduledscan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: scheduled-nmap-localhost
55
spec:
66
interval: 1m
7-
historyLimit: 2
7+
successfulJobsHistoryLimit: 2
88
scanSpec:
99
scanType: "nmap"
1010
parameters:

operator/controllers/execution/scheduledscan_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,13 @@ func (r *ScheduledScanReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
9696
}
9797

9898
// Delete Old Scans when exceeding the history limit
99+
var historyLimit int32 = 3
100+
if scheduledScan.Spec.SuccessfulJobsHistoryLimit != nil {
101+
historyLimit = *scheduledScan.Spec.SuccessfulJobsHistoryLimit
102+
}
103+
99104
for i, scan := range completedScans {
100-
if int64(i) >= int64(len(completedScans))-scheduledScan.Spec.HistoryLimit {
105+
if int32(i) >= int32(len(completedScans))-historyLimit {
101106
break
102107
}
103108
if err := r.Delete(ctx, &scan, client.PropagationPolicy(metav1.DeletePropagationBackground)); (err) != nil {

operator/crds/execution.securecodebox.io_parsedefinitions.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ metadata:
99
name: parsedefinitions.execution.securecodebox.io
1010
spec:
1111
additionalPrinterColumns:
12-
- JSONPath: .spec.handlesResultsType
13-
description: Which result file type the parser is able to handle
14-
name: Handles Type
15-
type: string
1612
- JSONPath: .spec.image
1713
description: Scanner Container Image
1814
name: Image
@@ -44,13 +40,12 @@ spec:
4440
spec:
4541
description: ParseDefinitionSpec defines the desired state of ParseDefinition
4642
properties:
47-
handlesResultsType:
48-
description: Foo is an example field of ParseDefinition. Edit ParseDefinition_types.go
49-
to remove/update
50-
type: string
5143
image:
44+
description: Image is the reference to the parser container image which
45+
ca transform the raw scan report into findings
5246
type: string
5347
imagePullSecrets:
48+
description: ImagePullSecrets used to access private parser images
5449
items:
5550
description: LocalObjectReference contains enough information to let
5651
you locate the referenced object inside the same namespace.

operator/crds/execution.securecodebox.io_scheduledscans.yaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,12 @@ spec:
5959
spec:
6060
description: ScheduledScanSpec defines the desired state of ScheduledScan
6161
properties:
62-
historyLimit:
63-
description: HistoryLimit determines how many past Scans will be kept
64-
until the oldest one will be delted, defaults to 3. When set to 0
65-
Scans will be deleted directly after completion
66-
format: int64
67-
type: integer
6862
interval:
6963
description: 'Interval describes how often the scan should be repeated
70-
Examples: ''12h'', ''7d'', ''30m'' (only days, hours and minutes supported,
71-
specified as integers)'
64+
Examples: ''12h'', ''30m'''
7265
type: string
7366
scanSpec:
74-
description: Foo is an example field of ScheduledScan. Edit ScheduledScan_types.go
75-
to remove/update
67+
description: ScanSpec describes the scan which should be started regularly
7668
properties:
7769
cascades:
7870
description: A label selector is a label query over a set of resources.
@@ -232,6 +224,13 @@ spec:
232224
scanType:
233225
type: string
234226
type: object
227+
successfulJobsHistoryLimit:
228+
description: SuccessfulJobsHistoryLimit determines how many past Scans
229+
will be kept until the oldest one will be deleted, defaults to 3.
230+
When set to 0, Scans will be deleted directly after completion
231+
format: int32
232+
minimum: 0
233+
type: integer
235234
required:
236235
- interval
237236
- scanSpec

0 commit comments

Comments
 (0)