Skip to content

Commit

Permalink
feat: add cluster visibility to FalconAdmission
Browse files Browse the repository at this point in the history
  • Loading branch information
gpontejos committed Sep 20, 2024
1 parent 6f4d209 commit f6f7be8
Show file tree
Hide file tree
Showing 3 changed files with 369 additions and 191 deletions.
26 changes: 26 additions & 0 deletions api/falcon/v1alpha1/falconadmission_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v1alpha1

import (
"strconv"

arv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -235,3 +237,27 @@ func (watcher FalconAdmissionConfigSpec) DeployWatcherContainer() bool {

return *watcher.DeployWatcher
}

func (watcher FalconAdmissionConfigSpec) GetSnapshotsEnabled() string {
if watcher.SnapshotsEnabled == nil {
return "true"
}

return strconv.FormatBool(*watcher.SnapshotsEnabled)
}

func (watcher FalconAdmissionConfigSpec) GetSnapshotsInterval() string {
if watcher.SnapshotsInterval == nil {
return "22h0m0s"
}

return watcher.SnapshotsInterval.Duration.String()
}

func (watcher FalconAdmissionConfigSpec) GetWatcherEnabled() string {
if watcher.WatcherEnabled == nil {
return "true"
}

return strconv.FormatBool(*watcher.WatcherEnabled)
}
29 changes: 9 additions & 20 deletions internal/controller/assets/deployment.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package assets

import (
"strconv"

falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1"
"github.com/crowdstrike/falcon-operator/pkg/common"
"github.com/go-logr/logr"
Expand Down Expand Up @@ -881,27 +879,18 @@ func admissionDepWatcherEnvVars(admission *falconv1alpha1.FalconAdmission) []cor
},
},
},
}

if admission.Spec.AdmissionConfig.SnapshotsEnabled != nil {
envVars = append(envVars, corev1.EnvVar{
corev1.EnvVar{
Name: "__CS_SNAPSHOTS_ENABLED",
Value: strconv.FormatBool(*admission.Spec.AdmissionConfig.SnapshotsEnabled),
})
}

if admission.Spec.AdmissionConfig.SnapshotsInterval != nil {
envVars = append(envVars, corev1.EnvVar{
Value: admission.Spec.AdmissionConfig.GetSnapshotsEnabled(),
},
corev1.EnvVar{
Name: "__CS_SNAPSHOT_INTERVAL",
Value: admission.Spec.AdmissionConfig.SnapshotsInterval.Duration.String(),
})
}

if admission.Spec.AdmissionConfig.WatcherEnabled != nil {
envVars = append(envVars, corev1.EnvVar{
Value: admission.Spec.AdmissionConfig.GetSnapshotsInterval(),
},
corev1.EnvVar{
Name: "__CS_WATCH_EVENTS_ENABLED",
Value: strconv.FormatBool(*admission.Spec.AdmissionConfig.WatcherEnabled),
})
Value: admission.Spec.AdmissionConfig.GetWatcherEnabled(),
},
}

return envVars
Expand Down
Loading

0 comments on commit f6f7be8

Please sign in to comment.