From 7e310929df7fb31444e8f696c00eed4d3a4ecffd Mon Sep 17 00:00:00 2001 From: Gabe Alford Date: Tue, 25 Jul 2023 10:56:04 -0600 Subject: [PATCH] fix: consistently use falconv1alpha1 for falcon v1alpha1 imports --- cmd/main.go | 14 +++--- controllers/falcon_container/configmap.go | 12 ++--- .../falconcontainer_controller.go | 50 +++++++++---------- controllers/falcon_container/image_push.go | 44 ++++++++-------- controllers/falcon_container/image_stream.go | 4 +- controllers/falcon_container/injector.go | 8 +-- controllers/falcon_container/k8s_utils.go | 8 +-- controllers/falcon_container/ns.go | 4 +- controllers/falcon_container/rbac.go | 10 ++-- controllers/falcon_container/registry.go | 6 +-- controllers/falcon_container/service.go | 4 +- controllers/falcon_container/webhook.go | 4 +- internal/controller/assets/configmap_test.go | 4 +- internal/controller/assets/daemonset_test.go | 14 +++--- internal/controller/assets/deployment.go | 4 +- internal/controller/assets/deployment_test.go | 6 +-- internal/controller/assets/mutatingwebhook.go | 4 +- pkg/common/common_test.go | 4 +- pkg/common/sensor_environment.go | 4 +- pkg/node/config_cache_test.go | 10 ++-- 20 files changed, 109 insertions(+), 109 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index c1a37bd8..4bcabd04 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -33,7 +33,7 @@ import ( corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" - v1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" containercontroller "github.com/crowdstrike/falcon-operator/controllers/falcon_container" nodecontroller "github.com/crowdstrike/falcon-operator/controllers/falcon_node" "github.com/crowdstrike/falcon-operator/pkg/common" @@ -51,7 +51,7 @@ func init() { utilruntime.Must(imagev1.AddToScheme(scheme)) utilruntime.Must(securityv1.AddToScheme(scheme)) - utilruntime.Must(v1alpha1.AddToScheme(scheme)) + utilruntime.Must(falconv1alpha1.AddToScheme(scheme)) // +kubebuilder:scaffold:scheme } @@ -119,11 +119,11 @@ func main() { Namespace: watchNamespace, // namespaced-scope when the value is not an empty string NewCache: cache.BuilderWithOptions(cache.Options{ SelectorsByObject: cache.SelectorsByObject{ - &v1alpha1.FalconContainer{}: {}, - &corev1.Namespace{}: {}, - &rbacv1.ClusterRoleBinding{}: {}, - &corev1.ServiceAccount{}: {}, - &imagev1.ImageStream{}: {}, + &falconv1alpha1.FalconContainer{}: {}, + &corev1.Namespace{}: {}, + &rbacv1.ClusterRoleBinding{}: {}, + &corev1.ServiceAccount{}: {}, + &imagev1.ImageStream{}: {}, &corev1.Service{}: { Label: labels.SelectorFromSet(labels.Set{common.FalconComponentKey: common.FalconSidecarSensor}), }, diff --git a/controllers/falcon_container/configmap.go b/controllers/falcon_container/configmap.go index ebbf871c..287816b6 100644 --- a/controllers/falcon_container/configmap.go +++ b/controllers/falcon_container/configmap.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/internal/controller/assets" "github.com/crowdstrike/falcon-operator/pkg/common" "github.com/crowdstrike/falcon-operator/pkg/falcon_api" @@ -18,15 +18,15 @@ import ( ctrl "sigs.k8s.io/controller-runtime" ) -func (r *FalconContainerReconciler) reconcileRegistryCABundleConfigMap(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.ConfigMap, error) { +func (r *FalconContainerReconciler) reconcileRegistryCABundleConfigMap(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.ConfigMap, error) { return r.reconcileGenericConfigMap(registryCABundleConfigMapName, r.newCABundleConfigMap, ctx, log, falconContainer) } -func (r *FalconContainerReconciler) reconcileConfigMap(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.ConfigMap, error) { +func (r *FalconContainerReconciler) reconcileConfigMap(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.ConfigMap, error) { return r.reconcileGenericConfigMap(injectorConfigMapName, r.newConfigMap, ctx, log, falconContainer) } -func (r *FalconContainerReconciler) reconcileGenericConfigMap(name string, genFunc func(context.Context, logr.Logger, *v1alpha1.FalconContainer) (*corev1.ConfigMap, error), ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.ConfigMap, error) { +func (r *FalconContainerReconciler) reconcileGenericConfigMap(name string, genFunc func(context.Context, logr.Logger, *falconv1alpha1.FalconContainer) (*corev1.ConfigMap, error), ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.ConfigMap, error) { configMap, err := genFunc(ctx, log, falconContainer) if err != nil { return configMap, fmt.Errorf("unable to render expected configmap: %v", err) @@ -50,7 +50,7 @@ func (r *FalconContainerReconciler) reconcileGenericConfigMap(name string, genFu } -func (r *FalconContainerReconciler) newCABundleConfigMap(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.ConfigMap, error) { +func (r *FalconContainerReconciler) newCABundleConfigMap(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.ConfigMap, error) { data := make(map[string]string) if falconContainer.Spec.Registry.TLS.CACertificate != "" { data["tls.crt"] = string(common.DecodeBase64Interface(falconContainer.Spec.Registry.TLS.CACertificate)) @@ -60,7 +60,7 @@ func (r *FalconContainerReconciler) newCABundleConfigMap(ctx context.Context, lo return &corev1.ConfigMap{}, fmt.Errorf("unable to determine contents of Registry TLS CACertificate attribute") } -func (r *FalconContainerReconciler) newConfigMap(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.ConfigMap, error) { +func (r *FalconContainerReconciler) newConfigMap(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.ConfigMap, error) { data := common.MakeSensorEnvMap(falconContainer.Spec.Falcon) data["CP_NAMESPACE"] = r.Namespace() data["FALCON_INJECTOR_LISTEN_PORT"] = strconv.Itoa(int(*falconContainer.Spec.Injector.ListenPort)) diff --git a/controllers/falcon_container/falconcontainer_controller.go b/controllers/falcon_container/falconcontainer_controller.go index 442bb25c..7e28b12c 100644 --- a/controllers/falcon_container/falconcontainer_controller.go +++ b/controllers/falcon_container/falconcontainer_controller.go @@ -6,7 +6,7 @@ import ( "os" "time" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/version" "github.com/go-logr/logr" arv1 "k8s.io/api/admissionregistration/v1" @@ -34,7 +34,7 @@ type FalconContainerReconciler struct { // SetupWithManager sets up the controller with the Manager. func (r *FalconContainerReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&v1alpha1.FalconContainer{}). + For(&falconv1alpha1.FalconContainer{}). Owns(&appsv1.Deployment{}). Owns(&corev1.Namespace{}). Owns(&corev1.Secret{}). @@ -69,7 +69,7 @@ func (r *FalconContainerReconciler) SetupWithManager(mgr ctrl.Manager) error { // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.7.2/pkg/reconcile func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := log.FromContext(ctx) - falconContainer := &v1alpha1.FalconContainer{} + falconContainer := &falconv1alpha1.FalconContainer{} if err := r.Get(ctx, req.NamespacedName, falconContainer); err != nil { if errors.IsNotFound(err) { @@ -83,9 +83,9 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } if falconContainer.Status.Conditions == nil || len(falconContainer.Status.Conditions) == 0 { - err := r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionPending, + err := r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionPending, metav1.ConditionFalse, - v1alpha1.ReasonReqNotMet, + falconv1alpha1.ReasonReqNotMet, "FalconContainer progressing") if err != nil { return ctrl.Result{}, err @@ -116,18 +116,18 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } } else { switch falconContainer.Spec.Registry.Type { - case v1alpha1.RegistryTypeECR: + case falconv1alpha1.RegistryTypeECR: if _, err := r.UpsertECRRepo(ctx); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile ECR repository: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile ECR repository: %v", err)) if err != nil { return ctrl.Result{}, err } return ctrl.Result{}, fmt.Errorf("failed to reconcile ECR repository: %v", err) } - case v1alpha1.RegistryTypeOpenshift: + case falconv1alpha1.RegistryTypeOpenshift: stream, err := r.reconcileImageStream(ctx, log, falconContainer) if err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Image Stream: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Image Stream: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -141,7 +141,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ // Create a CA Bundle ConfigMap if CACertificate attribute is set; overridden by the presence of a CACertificateConfigMap value if falconContainer.Spec.Registry.TLS.CACertificateConfigMap == "" && falconContainer.Spec.Registry.TLS.CACertificate != "" { if _, err := r.reconcileRegistryCABundleConfigMap(ctx, log, falconContainer); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Registry CA Certificate Bundle ConfigMap: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Registry CA Certificate Bundle ConfigMap: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -151,7 +151,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ if r.imageMirroringEnabled(falconContainer) { if err := r.PushImage(ctx, log, falconContainer); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to refresh Falcon Container image: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to refresh Falcon Container image: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -164,7 +164,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } if err != nil { log.Error(err, "Failed to verify CrowdStrike Container Image Registry access") - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to verify CrowdStrike Container Image Registry access: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to verify CrowdStrike Container Image Registry access: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -173,7 +173,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } if _, err = r.reconcileRegistrySecrets(ctx, log, falconContainer); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Falcon registry pull token Secrets: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Falcon registry pull token Secrets: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -183,7 +183,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } if _, err := r.reconcileServiceAccount(ctx, log, falconContainer); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Service Account: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Service Account: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -191,7 +191,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } if _, err := r.reconcileClusterRoleBinding(ctx, log, falconContainer); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Cluster Role Binding: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile Cluster Role Binding: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -200,7 +200,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ injectorTLS, err := r.reconcileInjectorTLSSecret(ctx, log, falconContainer) if err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector TLS Secret: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector TLS Secret: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -208,7 +208,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } caBundle := injectorTLS.Data["ca.crt"] if caBundle == nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", "CA bundle not present in injector TLS Secret") + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", "CA bundle not present in injector TLS Secret") if err != nil { return ctrl.Result{}, err } @@ -216,7 +216,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } if _, err = r.reconcileConfigMap(ctx, log, falconContainer); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector ConfigMap: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector ConfigMap: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -224,7 +224,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } if _, err = r.reconcileDeployment(ctx, log, falconContainer); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector Deployment: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector Deployment: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -232,7 +232,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } if _, err = r.reconcileService(ctx, log, falconContainer); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector Service: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector Service: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -241,7 +241,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ pod, err := r.injectorPodReady(ctx, falconContainer) if err != nil && err.Error() != "No Injector pod found in a Ready state" { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to find Ready injector pod: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to find Ready injector pod: %v", err)) if err != nil { return ctrl.Result{}, err } @@ -253,16 +253,16 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ } if _, err = r.reconcileWebhook(ctx, log, falconContainer, caBundle); err != nil { - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector MutatingWebhookConfiguration: %v", err)) + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionFailed, metav1.ConditionFalse, "Reconciling", fmt.Sprintf("failed to reconcile injector MutatingWebhookConfiguration: %v", err)) if err != nil { return ctrl.Result{}, err } return ctrl.Result{}, fmt.Errorf("failed to reconcile injector MutatingWebhookConfiguration: %v", err) } - err = r.StatusUpdate(ctx, req, log, falconContainer, v1alpha1.ConditionSuccess, + err = r.StatusUpdate(ctx, req, log, falconContainer, falconv1alpha1.ConditionSuccess, metav1.ConditionTrue, - v1alpha1.ReasonInstallSucceeded, + falconv1alpha1.ReasonInstallSucceeded, "FalconContainer installation completed") if err != nil { return ctrl.Result{}, err @@ -271,7 +271,7 @@ func (r *FalconContainerReconciler) Reconcile(ctx context.Context, req ctrl.Requ return ctrl.Result{}, nil } -func (r *FalconContainerReconciler) StatusUpdate(ctx context.Context, req ctrl.Request, log logr.Logger, falconContainer *v1alpha1.FalconContainer, condType string, status metav1.ConditionStatus, reason string, message string) error { +func (r *FalconContainerReconciler) StatusUpdate(ctx context.Context, req ctrl.Request, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer, condType string, status metav1.ConditionStatus, reason string, message string) error { meta.SetStatusCondition(&falconContainer.Status.Conditions, metav1.Condition{ Status: status, Reason: reason, diff --git a/controllers/falcon_container/image_push.go b/controllers/falcon_container/image_push.go index 7c310c2c..5f2270ce 100644 --- a/controllers/falcon_container/image_push.go +++ b/controllers/falcon_container/image_push.go @@ -8,7 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/pkg/gcp" "github.com/crowdstrike/falcon-operator/pkg/k8s_utils" "github.com/crowdstrike/falcon-operator/pkg/registry/auth" @@ -21,7 +21,7 @@ import ( types "k8s.io/apimachinery/pkg/types" ) -func (r *FalconContainerReconciler) PushImage(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) error { +func (r *FalconContainerReconciler) PushImage(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) error { registryUri, err := r.registryUri(ctx, falconContainer) if err != nil { return err @@ -64,7 +64,7 @@ func (r *FalconContainerReconciler) PushImage(ctx context.Context, log logr.Logg return r.Client.Status().Update(ctx, falconContainer) } -func (r *FalconContainerReconciler) verifyCrowdStrikeRegistry(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (bool, error) { +func (r *FalconContainerReconciler) verifyCrowdStrikeRegistry(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (bool, error) { if _, err := r.setImageTag(ctx, falconContainer); err != nil { return false, fmt.Errorf("Cannot set Falcon Registry Tag: %s", err) } @@ -75,25 +75,25 @@ func (r *FalconContainerReconciler) verifyCrowdStrikeRegistry(ctx context.Contex return false, fmt.Errorf("Cannot find Falcon Registry URI: %s", err) } - condition := meta.IsStatusConditionPresentAndEqual(falconContainer.Status.Conditions, v1alpha1.ConditionImageReady, metav1.ConditionTrue) + condition := meta.IsStatusConditionPresentAndEqual(falconContainer.Status.Conditions, falconv1alpha1.ConditionImageReady, metav1.ConditionTrue) if condition { return false, nil } meta.SetStatusCondition(&falconContainer.Status.Conditions, metav1.Condition{ Status: metav1.ConditionTrue, - Reason: v1alpha1.ReasonDiscovered, + Reason: falconv1alpha1.ReasonDiscovered, Message: imageUri, - Type: v1alpha1.ConditionImageReady, + Type: falconv1alpha1.ConditionImageReady, ObservedGeneration: falconContainer.GetGeneration(), }) return true, r.Client.Status().Update(ctx, falconContainer) } -func (r *FalconContainerReconciler) registryUri(ctx context.Context, falconContainer *v1alpha1.FalconContainer) (string, error) { +func (r *FalconContainerReconciler) registryUri(ctx context.Context, falconContainer *falconv1alpha1.FalconContainer) (string, error) { switch falconContainer.Spec.Registry.Type { - case v1alpha1.RegistryTypeOpenshift: + case falconv1alpha1.RegistryTypeOpenshift: imageStream := &imagev1.ImageStream{} err := r.Client.Get(ctx, types.NamespacedName{Name: imageStreamName, Namespace: r.imageNamespace(falconContainer)}, imageStream) if err != nil { @@ -105,27 +105,27 @@ func (r *FalconContainerReconciler) registryUri(ctx context.Context, falconConta } return imageStream.Status.DockerImageRepository, nil - case v1alpha1.RegistryTypeGCR: + case falconv1alpha1.RegistryTypeGCR: projectId, err := gcp.GetProjectID() if err != nil { return "", fmt.Errorf("Cannot get GCP Project ID: %v", err) } return "gcr.io/" + projectId + "/falcon-container", nil - case v1alpha1.RegistryTypeECR: + case falconv1alpha1.RegistryTypeECR: repo, err := r.UpsertECRRepo(ctx) if err != nil { return "", fmt.Errorf("Cannot get target docker URI for ECR repository: %v", err) } return *repo.RepositoryUri, nil - case v1alpha1.RegistryTypeACR: + case falconv1alpha1.RegistryTypeACR: if falconContainer.Spec.Registry.AcrName == nil { return "", fmt.Errorf("Cannot push Falcon Image locally to ACR. acr_name was not specified") } return fmt.Sprintf("%s.azurecr.io/falcon-container", *falconContainer.Spec.Registry.AcrName), nil - case v1alpha1.RegistryTypeCrowdStrike: + case falconv1alpha1.RegistryTypeCrowdStrike: cloud, err := falconContainer.Spec.FalconAPI.FalconCloud(ctx) if err != nil { return "", err @@ -137,7 +137,7 @@ func (r *FalconContainerReconciler) registryUri(ctx context.Context, falconConta } } -func (r *FalconContainerReconciler) imageUri(ctx context.Context, falconContainer *v1alpha1.FalconContainer) (string, error) { +func (r *FalconContainerReconciler) imageUri(ctx context.Context, falconContainer *falconv1alpha1.FalconContainer) (string, error) { if falconContainer.Spec.Image != nil && *falconContainer.Spec.Image != "" { return *falconContainer.Spec.Image, nil } @@ -160,7 +160,7 @@ func (r *FalconContainerReconciler) imageUri(ctx context.Context, falconContaine return fmt.Sprintf("%s:%s", registryUri, imageTag), nil } -func (r *FalconContainerReconciler) getImageTag(ctx context.Context, falconContainer *v1alpha1.FalconContainer) (string, error) { +func (r *FalconContainerReconciler) getImageTag(ctx context.Context, falconContainer *falconv1alpha1.FalconContainer) (string, error) { if falconContainer.Status.Sensor != nil && *falconContainer.Status.Sensor != "" { return *falconContainer.Status.Sensor, nil } @@ -168,7 +168,7 @@ func (r *FalconContainerReconciler) getImageTag(ctx context.Context, falconConta return "", fmt.Errorf("Unable to get falcon container version") } -func (r *FalconContainerReconciler) setImageTag(ctx context.Context, falconContainer *v1alpha1.FalconContainer) (string, error) { +func (r *FalconContainerReconciler) setImageTag(ctx context.Context, falconContainer *falconv1alpha1.FalconContainer) (string, error) { // If version locking is enabled and a version is already set in status, return the current version if r.versionLock(falconContainer) { if tag, err := r.getImageTag(ctx, falconContainer); err == nil { @@ -204,14 +204,14 @@ func (r *FalconContainerReconciler) setImageTag(ctx context.Context, falconConta return tag, err } -func (r *FalconContainerReconciler) pushAuth(ctx context.Context, falconContainer *v1alpha1.FalconContainer) (auth.Credentials, error) { +func (r *FalconContainerReconciler) pushAuth(ctx context.Context, falconContainer *falconv1alpha1.FalconContainer) (auth.Credentials, error) { return pushtoken.GetCredentials(ctx, falconContainer.Spec.Registry.Type, k8s_utils.QuerySecretsInNamespace(r.Client, r.imageNamespace(falconContainer)), ) } -func (r *FalconContainerReconciler) imageNamespace(falconContainer *v1alpha1.FalconContainer) string { - if falconContainer.Spec.Registry.Type == v1alpha1.RegistryTypeOpenshift { +func (r *FalconContainerReconciler) imageNamespace(falconContainer *falconv1alpha1.FalconContainer) string { + if falconContainer.Spec.Registry.Type == falconv1alpha1.RegistryTypeOpenshift { // Within OpenShift, ImageStreams are separated by namespaces. The "openshift" namespace // is shared and images pushed there can be referenced by deployments in other namespaces return "openshift" @@ -219,17 +219,17 @@ func (r *FalconContainerReconciler) imageNamespace(falconContainer *v1alpha1.Fal return r.Namespace() } -func (r *FalconContainerReconciler) falconApiConfig(ctx context.Context, falconContainer *v1alpha1.FalconContainer) *falcon.ApiConfig { +func (r *FalconContainerReconciler) falconApiConfig(ctx context.Context, falconContainer *falconv1alpha1.FalconContainer) *falcon.ApiConfig { cfg := falconContainer.Spec.FalconAPI.ApiConfig() cfg.Context = ctx return cfg } -func (r *FalconContainerReconciler) imageMirroringEnabled(falconContainer *v1alpha1.FalconContainer) bool { - return falconContainer.Spec.Registry.Type != v1alpha1.RegistryTypeCrowdStrike +func (r *FalconContainerReconciler) imageMirroringEnabled(falconContainer *falconv1alpha1.FalconContainer) bool { + return falconContainer.Spec.Registry.Type != falconv1alpha1.RegistryTypeCrowdStrike } -func (r *FalconContainerReconciler) versionLock(falconContainer *v1alpha1.FalconContainer) bool { +func (r *FalconContainerReconciler) versionLock(falconContainer *falconv1alpha1.FalconContainer) bool { return falconContainer.Spec.Version != nil && falconContainer.Status.Sensor != nil && *falconContainer.Spec.Version == *falconContainer.Status.Sensor } diff --git a/controllers/falcon_container/image_stream.go b/controllers/falcon_container/image_stream.go index 3de420cf..8c505aee 100644 --- a/controllers/falcon_container/image_stream.go +++ b/controllers/falcon_container/image_stream.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/internal/controller/assets" "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/api/errors" @@ -19,7 +19,7 @@ const ( imageStreamName = "falcon-sidecar-container" ) -func (r *FalconContainerReconciler) reconcileImageStream(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*imagev1.ImageStream, error) { +func (r *FalconContainerReconciler) reconcileImageStream(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*imagev1.ImageStream, error) { imageStream := assets.ImageStream(imageStreamName, r.imageNamespace(falconContainer)) existingImageStream := &imagev1.ImageStream{} diff --git a/controllers/falcon_container/injector.go b/controllers/falcon_container/injector.go index 08de6836..cdb91687 100644 --- a/controllers/falcon_container/injector.go +++ b/controllers/falcon_container/injector.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/internal/controller/assets" "github.com/go-logr/logr" "github.com/operator-framework/operator-lib/proxy" @@ -28,7 +28,7 @@ const ( registryCABundleConfigMapName = "falcon-sidecar-registry-certs" ) -func (r *FalconContainerReconciler) reconcileInjectorTLSSecret(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.Secret, error) { +func (r *FalconContainerReconciler) reconcileInjectorTLSSecret(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.Secret, error) { existingInjectorTLSSecret := &corev1.Secret{} err := r.Client.Get(ctx, types.NamespacedName{Name: injectorTLSSecretName, Namespace: r.Namespace()}, existingInjectorTLSSecret) if err != nil { @@ -58,7 +58,7 @@ func (r *FalconContainerReconciler) reconcileInjectorTLSSecret(ctx context.Conte } -func (r *FalconContainerReconciler) reconcileDeployment(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*appsv1.Deployment, error) { +func (r *FalconContainerReconciler) reconcileDeployment(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*appsv1.Deployment, error) { update := false imageUri, err := r.imageUri(ctx, falconContainer) @@ -149,7 +149,7 @@ func (r *FalconContainerReconciler) reconcileDeployment(ctx context.Context, log } -func (r *FalconContainerReconciler) injectorPodReady(ctx context.Context, falconContainer *v1alpha1.FalconContainer) (*corev1.Pod, error) { +func (r *FalconContainerReconciler) injectorPodReady(ctx context.Context, falconContainer *falconv1alpha1.FalconContainer) (*corev1.Pod, error) { podList := &corev1.PodList{} listOpts := []client.ListOption{ client.InNamespace(r.Namespace()), diff --git a/controllers/falcon_container/k8s_utils.go b/controllers/falcon_container/k8s_utils.go index 52a0d5ba..35a8adc8 100644 --- a/controllers/falcon_container/k8s_utils.go +++ b/controllers/falcon_container/k8s_utils.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" @@ -14,7 +14,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -func (r *FalconContainerReconciler) Create(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer, obj runtime.Object) error { +func (r *FalconContainerReconciler) Create(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer, obj runtime.Object) error { switch t := obj.(type) { case client.Object: name := t.GetName() @@ -41,7 +41,7 @@ func (r *FalconContainerReconciler) Create(ctx context.Context, log logr.Logger, } } -func (r *FalconContainerReconciler) Update(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer, obj runtime.Object) error { +func (r *FalconContainerReconciler) Update(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer, obj runtime.Object) error { switch t := obj.(type) { case client.Object: name := t.GetName() @@ -67,7 +67,7 @@ func (r *FalconContainerReconciler) Update(ctx context.Context, log logr.Logger, } } -func (r *FalconContainerReconciler) Delete(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer, obj runtime.Object) error { +func (r *FalconContainerReconciler) Delete(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer, obj runtime.Object) error { switch t := obj.(type) { case client.Object: name := t.GetName() diff --git a/controllers/falcon_container/ns.go b/controllers/falcon_container/ns.go index f9a3f1df..c1a95211 100644 --- a/controllers/falcon_container/ns.go +++ b/controllers/falcon_container/ns.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/pkg/common" "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" @@ -37,7 +37,7 @@ func (r *FalconContainerReconciler) NamespaceLabels() map[string]string { return nsLabels } -func (r *FalconContainerReconciler) reconcileNamespace(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.Namespace, error) { +func (r *FalconContainerReconciler) reconcileNamespace(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.Namespace, error) { namespace := r.newNamespace() existingNamespace := &corev1.Namespace{} err := r.Client.Get(ctx, types.NamespacedName{Name: r.Namespace()}, existingNamespace) diff --git a/controllers/falcon_container/rbac.go b/controllers/falcon_container/rbac.go index 07b06a83..2219f383 100644 --- a/controllers/falcon_container/rbac.go +++ b/controllers/falcon_container/rbac.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/pkg/common" "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" @@ -21,7 +21,7 @@ const ( injectorClusterRoleBindingName = "falcon-operator-container-rolebinding" ) -func (r *FalconContainerReconciler) reconcileServiceAccount(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.ServiceAccount, error) { +func (r *FalconContainerReconciler) reconcileServiceAccount(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.ServiceAccount, error) { update := false serviceAccount := r.newServiceAccount(falconContainer) existingServiceAccount := &corev1.ServiceAccount{} @@ -51,7 +51,7 @@ func (r *FalconContainerReconciler) reconcileServiceAccount(ctx context.Context, } -func (r *FalconContainerReconciler) reconcileClusterRoleBinding(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*rbacv1.ClusterRoleBinding, error) { +func (r *FalconContainerReconciler) reconcileClusterRoleBinding(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*rbacv1.ClusterRoleBinding, error) { clusterRoleBinding := r.newClusterRoleBinding(falconContainer) existingClusterRoleBinding := &rbacv1.ClusterRoleBinding{} err := r.Client.Get(ctx, types.NamespacedName{Name: injectorClusterRoleBindingName}, existingClusterRoleBinding) @@ -82,7 +82,7 @@ func (r *FalconContainerReconciler) reconcileClusterRoleBinding(ctx context.Cont } -func (r *FalconContainerReconciler) newServiceAccount(falconContainer *v1alpha1.FalconContainer) *corev1.ServiceAccount { +func (r *FalconContainerReconciler) newServiceAccount(falconContainer *falconv1alpha1.FalconContainer) *corev1.ServiceAccount { imagePullSecrets := []corev1.LocalObjectReference{{Name: common.FalconPullSecretName}} if common.FalconPullSecretName != falconContainer.Spec.Injector.ImagePullSecretName { imagePullSecrets = append(imagePullSecrets, corev1.LocalObjectReference{Name: falconContainer.Spec.Injector.ImagePullSecretName}) @@ -102,7 +102,7 @@ func (r *FalconContainerReconciler) newServiceAccount(falconContainer *v1alpha1. } } -func (r *FalconContainerReconciler) newClusterRoleBinding(falconContainer *v1alpha1.FalconContainer) *rbacv1.ClusterRoleBinding { +func (r *FalconContainerReconciler) newClusterRoleBinding(falconContainer *falconv1alpha1.FalconContainer) *rbacv1.ClusterRoleBinding { return &rbacv1.ClusterRoleBinding{ TypeMeta: metav1.TypeMeta{ APIVersion: rbacv1.SchemeGroupVersion.String(), diff --git a/controllers/falcon_container/registry.go b/controllers/falcon_container/registry.go index ef59d29f..113ce910 100644 --- a/controllers/falcon_container/registry.go +++ b/controllers/falcon_container/registry.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/internal/controller/assets" "github.com/crowdstrike/falcon-operator/pkg/common" "github.com/crowdstrike/falcon-operator/pkg/registry/pulltoken" @@ -16,7 +16,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" ) -func (r *FalconContainerReconciler) reconcileRegistrySecrets(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.SecretList, error) { +func (r *FalconContainerReconciler) reconcileRegistrySecrets(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.SecretList, error) { injectionEnabledValue := "enabled" injectionDisabledValue := "disabled" disableDefaultNSInjection := false @@ -64,7 +64,7 @@ func (r *FalconContainerReconciler) reconcileRegistrySecrets(ctx context.Context return secretList, nil } -func (r *FalconContainerReconciler) reconcileRegistrySecret(namespace string, pulltoken []byte, ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.Secret, error) { +func (r *FalconContainerReconciler) reconcileRegistrySecret(namespace string, pulltoken []byte, ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.Secret, error) { secretData := map[string][]byte{corev1.DockerConfigJsonKey: common.CleanDecodedBase64(pulltoken)} secret := assets.Secret(common.FalconPullSecretName, namespace, "falcon-operator", secretData, corev1.SecretTypeDockerConfigJson) existingSecret := &corev1.Secret{} diff --git a/controllers/falcon_container/service.go b/controllers/falcon_container/service.go index 80ec49f4..9dfbc887 100644 --- a/controllers/falcon_container/service.go +++ b/controllers/falcon_container/service.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/internal/controller/assets" "github.com/crowdstrike/falcon-operator/pkg/common" "github.com/go-logr/logr" @@ -15,7 +15,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" ) -func (r *FalconContainerReconciler) reconcileService(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer) (*corev1.Service, error) { +func (r *FalconContainerReconciler) reconcileService(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer) (*corev1.Service, error) { selector := map[string]string{common.FalconComponentKey: common.FalconSidecarSensor} service := assets.Service(injectorName, r.Namespace(), common.FalconSidecarSensor, selector, *falconContainer.Spec.Injector.ListenPort) updated := false diff --git a/controllers/falcon_container/webhook.go b/controllers/falcon_container/webhook.go index 2d549f40..c8c041cf 100644 --- a/controllers/falcon_container/webhook.go +++ b/controllers/falcon_container/webhook.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/internal/controller/assets" "github.com/go-logr/logr" arv1 "k8s.io/api/admissionregistration/v1" @@ -18,7 +18,7 @@ const ( webhookName = "mutatingwebhook.sidecar.falcon.crowdstrike.com" ) -func (r *FalconContainerReconciler) reconcileWebhook(ctx context.Context, log logr.Logger, falconContainer *v1alpha1.FalconContainer, caBundle []byte) (*arv1.MutatingWebhookConfiguration, error) { +func (r *FalconContainerReconciler) reconcileWebhook(ctx context.Context, log logr.Logger, falconContainer *falconv1alpha1.FalconContainer, caBundle []byte) (*arv1.MutatingWebhookConfiguration, error) { disableDefaultNSInjection := false if falconContainer.Spec.Injector.DisableDefaultNSInjection { diff --git a/internal/controller/assets/configmap_test.go b/internal/controller/assets/configmap_test.go index 87c08cc2..b068a456 100644 --- a/internal/controller/assets/configmap_test.go +++ b/internal/controller/assets/configmap_test.go @@ -3,7 +3,7 @@ package assets import ( "testing" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/pkg/common" "github.com/crowdstrike/falcon-operator/pkg/node" "github.com/google/go-cmp/cmp" @@ -13,7 +13,7 @@ import ( // TestDaemonsetConfigMap tests the SensorConfigMap function func TestSensorConfigMap(t *testing.T) { - falconNode := v1alpha1.FalconNodeSensor{} + falconNode := falconv1alpha1.FalconNodeSensor{} falconNode.Spec.FalconAPI = nil falconCID := "1234567890ABCDEF1234567890ABCDEF-12" falconImage := "testMyImage" diff --git a/internal/controller/assets/daemonset_test.go b/internal/controller/assets/daemonset_test.go index 6e33e928..ca3ac191 100644 --- a/internal/controller/assets/daemonset_test.go +++ b/internal/controller/assets/daemonset_test.go @@ -3,7 +3,7 @@ package assets import ( "testing" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/pkg/common" "github.com/google/go-cmp/cmp" appsv1 "k8s.io/api/apps/v1" @@ -13,7 +13,7 @@ import ( ) func TestGetTermGracePeriod(t *testing.T) { - falconNode := v1alpha1.FalconNodeSensor{} + falconNode := falconv1alpha1.FalconNodeSensor{} falconNode.Spec.FalconAPI = nil want := int64(10) @@ -30,7 +30,7 @@ func TestGetTermGracePeriod(t *testing.T) { } func TestNodeAffinity(t *testing.T) { - falconNode := v1alpha1.FalconNodeSensor{} + falconNode := falconv1alpha1.FalconNodeSensor{} got := nodeAffinity(&falconNode) want := &corev1.Affinity{} @@ -64,7 +64,7 @@ func TestNodeAffinity(t *testing.T) { } func TestPullSecrets(t *testing.T) { - falconNode := v1alpha1.FalconNodeSensor{} + falconNode := falconv1alpha1.FalconNodeSensor{} want := []corev1.LocalObjectReference{ { @@ -93,7 +93,7 @@ func TestPullSecrets(t *testing.T) { } func TestDsUpdateStrategy(t *testing.T) { - falconNode := v1alpha1.FalconNodeSensor{} + falconNode := falconv1alpha1.FalconNodeSensor{} // Test OnDelete return value falconNode.Spec.Node.DSUpdateStrategy.Type = "OnDelete" @@ -125,7 +125,7 @@ func TestDsUpdateStrategy(t *testing.T) { } func TestDaemonset(t *testing.T) { - falconNode := v1alpha1.FalconNodeSensor{} + falconNode := falconv1alpha1.FalconNodeSensor{} falconNode.Namespace = "falcon-system" falconNode.Name = "test" image := "testImage" @@ -248,7 +248,7 @@ func TestDaemonset(t *testing.T) { } func TestRemoveNodeDirDaemonset(t *testing.T) { - falconNode := v1alpha1.FalconNodeSensor{} + falconNode := falconv1alpha1.FalconNodeSensor{} falconNode.Namespace = "falcon-system" falconNode.Name = "test" image := "testImage" diff --git a/internal/controller/assets/deployment.go b/internal/controller/assets/deployment.go index e7238856..b9801cc3 100644 --- a/internal/controller/assets/deployment.go +++ b/internal/controller/assets/deployment.go @@ -1,7 +1,7 @@ package assets import ( - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/pkg/common" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -10,7 +10,7 @@ import ( ) // SideCarDeployment returns a Deployment object for the CrowdStrike Falcon sidecar -func SideCarDeployment(name string, namespace string, component string, imageUri string, falconContainer *v1alpha1.FalconContainer) *appsv1.Deployment { +func SideCarDeployment(name string, namespace string, component string, imageUri string, falconContainer *falconv1alpha1.FalconContainer) *appsv1.Deployment { imagePullSecrets := []corev1.LocalObjectReference{{Name: common.FalconPullSecretName}} initContainerName := "crowdstrike-falcon-init-container" injectorConfigMapName := "falcon-sidecar-injector-config" diff --git a/internal/controller/assets/deployment_test.go b/internal/controller/assets/deployment_test.go index a615f671..e5f4a3de 100644 --- a/internal/controller/assets/deployment_test.go +++ b/internal/controller/assets/deployment_test.go @@ -3,7 +3,7 @@ package assets import ( "testing" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/pkg/common" "github.com/google/go-cmp/cmp" appsv1 "k8s.io/api/apps/v1" @@ -14,7 +14,7 @@ import ( // TestDeployment tests the Deployment function func TestSideCarDeployment(t *testing.T) { - falconContainer := &v1alpha1.FalconContainer{} + falconContainer := &falconv1alpha1.FalconContainer{} falconContainer.Spec.Injector.Resources = &corev1.ResourceRequirements{} falconContainer.Spec.Injector.AzureConfigPath = "/test" falconContainer.Spec.Registry.TLS.CACertificateConfigMap = "test" @@ -31,7 +31,7 @@ func TestSideCarDeployment(t *testing.T) { } // testSideCarDeployment is a helper function to create a Deployment object for testing -func testSideCarDeployment(name string, namespace string, component string, imageUri string, falconContainer *v1alpha1.FalconContainer) *appsv1.Deployment { +func testSideCarDeployment(name string, namespace string, component string, imageUri string, falconContainer *falconv1alpha1.FalconContainer) *appsv1.Deployment { replicas := int32(123) imagePullSecrets := []corev1.LocalObjectReference{{Name: common.FalconPullSecretName}} initContainerName := "crowdstrike-falcon-init-container" diff --git a/internal/controller/assets/mutatingwebhook.go b/internal/controller/assets/mutatingwebhook.go index 76dbb7b6..efefeb65 100644 --- a/internal/controller/assets/mutatingwebhook.go +++ b/internal/controller/assets/mutatingwebhook.go @@ -1,14 +1,14 @@ package assets import ( - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/crowdstrike/falcon-operator/pkg/common" arv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // MutatingWebhook creates a MutatingWebhookConfiguration object -func MutatingWebhook(name string, namespace string, webhookName string, caBundle []byte, disableNSInjection bool, falconContainer *v1alpha1.FalconContainer) *arv1.MutatingWebhookConfiguration { +func MutatingWebhook(name string, namespace string, webhookName string, caBundle []byte, disableNSInjection bool, falconContainer *falconv1alpha1.FalconContainer) *arv1.MutatingWebhookConfiguration { sideEffects := arv1.SideEffectClassNone reinvocationPolicy := arv1.NeverReinvocationPolicy failurePolicy := arv1.Fail diff --git a/pkg/common/common_test.go b/pkg/common/common_test.go index ead2d5d0..f4849745 100644 --- a/pkg/common/common_test.go +++ b/pkg/common/common_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "k8s.io/apimachinery/pkg/version" ktest "k8s.io/client-go/testing" ) @@ -107,7 +107,7 @@ func TestGetProxyInfo(t *testing.T) { } func TestMakeSensorEnvMap(t *testing.T) { - falconNode := v1alpha1.FalconNodeSensor{} + falconNode := falconv1alpha1.FalconNodeSensor{} falconSensor := falconNode.Spec.Falcon sensorConfig := make(map[string]string) proxy := NewProxyInfo() diff --git a/pkg/common/sensor_environment.go b/pkg/common/sensor_environment.go index a502df3a..9ab18160 100644 --- a/pkg/common/sensor_environment.go +++ b/pkg/common/sensor_environment.go @@ -4,10 +4,10 @@ import ( "strconv" "strings" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" ) -func MakeSensorEnvMap(falconSensor v1alpha1.FalconSensor) map[string]string { +func MakeSensorEnvMap(falconSensor falconv1alpha1.FalconSensor) map[string]string { sensorConfig := make(map[string]string) proxy := NewProxyInfo() diff --git a/pkg/node/config_cache_test.go b/pkg/node/config_cache_test.go index 6cba84b3..0c489f1b 100644 --- a/pkg/node/config_cache_test.go +++ b/pkg/node/config_cache_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" - "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" + falconv1alpha1 "github.com/crowdstrike/falcon-operator/api/falcon/v1alpha1" "github.com/go-logr/logr" "github.com/google/go-cmp/cmp" ) -var falconNode = v1alpha1.FalconNodeSensor{} +var falconNode = falconv1alpha1.FalconNodeSensor{} var falconCID = "1234567890ABCDEF1234567890ABCDEF-12" var falconImage = "testMyImage" var config = ConfigCache{cid: falconCID, imageUri: falconImage, nodesensor: &falconNode} @@ -83,7 +83,7 @@ func TestGetPullToken(t *testing.T) { t.Errorf("GetPullToken() = %s, want %s", got, "not empty") } - config.nodesensor.Spec.FalconAPI = &v1alpha1.FalconAPI{ + config.nodesensor.Spec.FalconAPI = &falconv1alpha1.FalconAPI{ ClientId: "testID", ClientSecret: "testSecret", CloudRegion: "testRegion", @@ -132,7 +132,7 @@ func TestNewConfigCache(t *testing.T) { t.Errorf("NewConfigCache() = %v, want %v", newCache, want) } - config.nodesensor.Spec.FalconAPI = &v1alpha1.FalconAPI{ + config.nodesensor.Spec.FalconAPI = &falconv1alpha1.FalconAPI{ ClientId: "testID", ClientSecret: "testSecret", CloudRegion: "testRegion", @@ -158,7 +158,7 @@ func TestConfigCacheTest(t *testing.T) { } func TestGetFalconImage(t *testing.T) { - falconNode.Spec.FalconAPI = &v1alpha1.FalconAPI{ + falconNode.Spec.FalconAPI = &falconv1alpha1.FalconAPI{ ClientId: "testID", ClientSecret: "testSecret", CloudRegion: "testRegion",