Skip to content

Commit

Permalink
chore: remove suspend and schedule fields from plugin reference in cl…
Browse files Browse the repository at this point in the history
…uster scan spec
  • Loading branch information
matheusfm committed Sep 1, 2023
1 parent bfd55a4 commit 706bbe0
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 45 deletions.
7 changes: 0 additions & 7 deletions api/zora/v1alpha1/clusterscan_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ type PluginReference struct {
// Namespace defines the space within which the Plugin name must be unique.
Namespace string `json:"namespace,omitempty"`

// This flag tells the controller to suspend subsequent executions, it does
// not apply to already started executions. Defaults to false.
Suspend *bool `json:"suspend,omitempty"`

// The schedule in Cron format for this Plugin, see https://en.wikipedia.org/wiki/Cron.
Schedule string `json:"schedule,omitempty"`

// List of environment variables to set in the Plugin container.
Env []corev1.EnvVar `json:"env,omitempty"`
}
Expand Down
5 changes: 0 additions & 5 deletions api/zora/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions charts/zora/crds/zora.undistro.io_clusterscans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,6 @@ spec:
description: Namespace defines the space within which the Plugin
name must be unique.
type: string
schedule:
description: The schedule in Cron format for this Plugin, see
https://en.wikipedia.org/wiki/Cron.
type: string
suspend:
description: This flag tells the controller to suspend subsequent
executions, it does not apply to already started executions. Defaults
to false.
type: boolean
required:
- name
type: object
Expand Down
9 changes: 0 additions & 9 deletions config/crd/bases/zora.undistro.io_clusterscans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,6 @@ spec:
description: Namespace defines the space within which the Plugin
name must be unique.
type: string
schedule:
description: The schedule in Cron format for this Plugin, see
https://en.wikipedia.org/wiki/Cron.
type: string
suspend:
description: This flag tells the controller to suspend subsequent
executions, it does not apply to already started executions. Defaults
to false.
type: boolean
required:
- name
type: object
Expand Down
17 changes: 2 additions & 15 deletions pkg/plugins/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,14 @@ func (r *CronJobMutator) Mutate() error {
}
r.Existing.ObjectMeta.Labels[LabelClusterScan] = r.ClusterScan.Name
r.Existing.ObjectMeta.Labels[LabelPlugin] = r.Plugin.Name
schedule := r.PluginRef.Schedule
if schedule == "" {
schedule = r.ClusterScan.Spec.Schedule
}
r.Existing.Spec.Schedule = schedule
r.Existing.Spec.Schedule = r.ClusterScan.Spec.Schedule
r.Existing.Spec.ConcurrencyPolicy = batchv1.ForbidConcurrent
r.Existing.Spec.SuccessfulJobsHistoryLimit = r.ClusterScan.Spec.SuccessfulScansHistoryLimit
r.Existing.Spec.FailedJobsHistoryLimit = r.ClusterScan.Spec.FailedScansHistoryLimit

r.Existing.Spec.Suspend = &r.Suspend
if !r.Suspend {
r.Existing.Spec.Suspend = firstNonNilBoolPointer(r.PluginRef.Suspend, r.ClusterScan.Spec.Suspend)
r.Existing.Spec.Suspend = r.ClusterScan.Spec.Suspend
}
r.Existing.Spec.JobTemplate.Spec.Template.Spec.RestartPolicy = corev1.RestartPolicyNever
r.Existing.Spec.JobTemplate.Spec.BackoffLimit = pointer.Int32(0)
Expand Down Expand Up @@ -313,12 +309,3 @@ func (r *CronJobMutator) workerEnv() []corev1.EnvVar {
},
)
}

func firstNonNilBoolPointer(pointers ...*bool) *bool {
for _, b := range pointers {
if b != nil {
return b
}
}
return pointer.Bool(false)
}

0 comments on commit 706bbe0

Please sign in to comment.