diff --git a/cmd/main.go b/cmd/main.go index 380ff53ac0..7e41b7d24b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -596,6 +596,7 @@ admission policy installation; once an Installation exists it is the authority o UseV3CRDs: v3CRDs, APIDiscovery: apiDiscovery, Extensions: extensionRegistry, + Controllers: enterprise.Controllers(variant), } err = controller.AddToManager(mgr, options) diff --git a/docs/principles.md b/docs/principles.md index 28881a941d..96e090c9e8 100644 --- a/docs/principles.md +++ b/docs/principles.md @@ -34,6 +34,7 @@ API design principles and the Go/kubebuilder coding conventions for `api/v1` CRD ## Variants - **Core code is variant-blind.** Controllers and render packages outside `pkg/enterprise` must not name a variant, in code or in comments. Behavior a single variant needs registers through `pkg/extensions`. +- **A controller only one variant runs lives in `pkg/enterprise/controller`, and its render code in `pkg/enterprise/render`.** Both mirror the core tree they came from. The controller is contributed through the controller list on `ControllerOptions` rather than named by `AddToManager`, so it carries no variant check of its own. ## Security diff --git a/internal/controller/applicationlayer_controller.go b/internal/controller/applicationlayer_controller.go deleted file mode 100644 index 3f1f7fdc6e..0000000000 --- a/internal/controller/applicationlayer_controller.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2021-2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - - "github.com/tigera/operator/pkg/controller/applicationlayer" - "github.com/tigera/operator/pkg/controller/options" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -// ApplicationLayerReconciler reconciles a ApplicationLayer object -type ApplicationLayerReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=applicationlayers,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=applicationlayers/status,verbs=get;update;patch - -func (r *ApplicationLayerReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return applicationlayer.Add(mgr, opts) -} diff --git a/internal/controller/authentication_controller.go b/internal/controller/authentication_controller.go deleted file mode 100644 index 83b0046d25..0000000000 --- a/internal/controller/authentication_controller.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2020-2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/tigera/operator/pkg/controller/authentication" - "github.com/tigera/operator/pkg/controller/options" -) - -// AuthenticationReconciler reconciles an Authentication object -type AuthenticationReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=authentications,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=authentications/status,verbs=get;update;patch - -func (r *AuthenticationReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return authentication.Add(mgr, opts) -} diff --git a/internal/controller/controllers.go b/internal/controller/controllers.go index 2318499430..a3f2191e00 100644 --- a/internal/controller/controllers.go +++ b/internal/controller/controllers.go @@ -52,20 +52,6 @@ func AddToManager(mgr ctrl.Manager, options options.ControllerOptions) error { }).SetupWithManager(mgr, options); err != nil { return fmt.Errorf("failed to create controller %s: %v", "LogStorage", err) } - if err := (&IntrusionDetectionReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("IntrusionDetection"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "IntrusionDetection", err) - } - if err := (&LogCollectorReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("LogCollector"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "LogCollector", err) - } if err := (&IstioReconciler{ Client: mgr.GetClient(), Log: ctrl.Log.WithName("controllers").WithName("Istio"), @@ -73,27 +59,6 @@ func AddToManager(mgr ctrl.Manager, options options.ControllerOptions) error { }).SetupWithManager(mgr, options); err != nil { return fmt.Errorf("failed to create controller Istio: %v", err) } - if err := (&ApplicationLayerReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("ApplicationLayer"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "ApplicationLayer", err) - } - if err := (&MonitorReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("Monitor"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "Monitor", err) - } - if err := (&ManagerReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("Manager"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "Manager", err) - } if err := (&ManagementClusterConnectionReconciler{ Client: mgr.GetClient(), Log: ctrl.Log.WithName("controllers").WithName("ManagementClusterConnection"), @@ -101,20 +66,6 @@ func AddToManager(mgr ctrl.Manager, options options.ControllerOptions) error { }).SetupWithManager(mgr, options); err != nil { return fmt.Errorf("failed to create controller %s: %v", "ManagementClusterConnection", err) } - if err := (&NonClusterHostReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("NonClusterHost"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "NonClusterHost", err) - } - if err := (&AuthenticationReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("Authentication"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "Authentication", err) - } if err := (&TiersReconciler{ Client: mgr.GetClient(), Log: ctrl.Log.WithName("controllers").WithName("Tiers"), @@ -122,20 +73,6 @@ func AddToManager(mgr ctrl.Manager, options options.ControllerOptions) error { }).SetupWithManager(mgr, options); err != nil { return fmt.Errorf("failed to create controller %s: %v", "Tiers", err) } - if err := (&PolicyRecommendationReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("PolicyRecommendation"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "PolicyRecommendation", err) - } - if err := (&EgressGatewayReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("EgressGateway"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "EgressGateway", err) - } if err := (&SecretsReconciler{ Client: mgr.GetClient(), Log: ctrl.Log.WithName("controllers").WithName("Secrets"), @@ -157,13 +94,6 @@ func AddToManager(mgr ctrl.Manager, options options.ControllerOptions) error { }).SetupWithManager(mgr, options); err != nil { return fmt.Errorf("failed to create controller %s: %v", "CSR", err) } - if err := (&PacketCaptureReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("PacketCapture"), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "PacketCapture", err) - } if err := (&GatewayAPIReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), @@ -195,12 +125,9 @@ func AddToManager(mgr ctrl.Manager, options options.ControllerOptions) error { }).SetupWithManager(mgr, options); err != nil { return fmt.Errorf("failed to create controller %s: %v", "PodIPRecovery", err) } - if err := (&OpenTelemetryCollectorReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr, options); err != nil { - return fmt.Errorf("failed to create controller %s: %v", "OpenTelemetry", err) - } // +kubebuilder:scaffold:builder - return nil + + // The controllers only the running variant supplies, added last so that a variant + // can watch resources the core controllers own. + return options.AddControllers(mgr) } diff --git a/internal/controller/egressgateway_controller.go b/internal/controller/egressgateway_controller.go deleted file mode 100644 index fc647f17c2..0000000000 --- a/internal/controller/egressgateway_controller.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2023-2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - "github.com/tigera/operator/pkg/controller/egressgateway" - "github.com/tigera/operator/pkg/controller/options" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -// EgressGatewayReconciler reconciles a EgressGateway object -type EgressGatewayReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=egressgateways,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=egressgateways/status,verbs=get;update;patch - -func (r *EgressGatewayReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return egressgateway.Add(mgr, opts) -} diff --git a/internal/controller/intrusiondetection_controller.go b/internal/controller/intrusiondetection_controller.go deleted file mode 100644 index 00e9e7a2b7..0000000000 --- a/internal/controller/intrusiondetection_controller.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2020-2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/tigera/operator/pkg/controller/intrusiondetection" - "github.com/tigera/operator/pkg/controller/options" -) - -// IntrusionDetectionReconciler reconciles a IntrusionDetection object -type IntrusionDetectionReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=intrusiondetections,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=intrusiondetections/status,verbs=get;update;patch - -func (r *IntrusionDetectionReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return intrusiondetection.Add(mgr, opts) -} diff --git a/internal/controller/logcollector_controller.go b/internal/controller/logcollector_controller.go deleted file mode 100644 index 67d579f8d2..0000000000 --- a/internal/controller/logcollector_controller.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2020-2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/tigera/operator/pkg/controller/logcollector" - "github.com/tigera/operator/pkg/controller/options" -) - -// LogCollectorReconciler reconciles a LogCollector object -type LogCollectorReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=logcollectors,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=logcollectors/status,verbs=get;update;patch - -func (r *LogCollectorReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return logcollector.Add(mgr, opts) -} diff --git a/internal/controller/manager_controller.go b/internal/controller/manager_controller.go deleted file mode 100644 index b4040dced2..0000000000 --- a/internal/controller/manager_controller.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2020-2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/tigera/operator/pkg/controller/manager" - "github.com/tigera/operator/pkg/controller/options" -) - -// ManagerReconciler reconciles a Manager object -type ManagerReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=managers,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=managers/status,verbs=get;update;patch - -func (r *ManagerReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return manager.Add(mgr, opts) -} diff --git a/internal/controller/monitor_controller.go b/internal/controller/monitor_controller.go deleted file mode 100644 index 4f7f6458c3..0000000000 --- a/internal/controller/monitor_controller.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2021-2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/tigera/operator/pkg/controller/monitor" - "github.com/tigera/operator/pkg/controller/options" -) - -// MonitorReconciler reconciles a Monitor object -type MonitorReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=monitors,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=monitors/status,verbs=get;update;patch - -func (r *MonitorReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return monitor.Add(mgr, opts) -} diff --git a/internal/controller/nonclusterhost_controller.go b/internal/controller/nonclusterhost_controller.go deleted file mode 100644 index 03c48aab47..0000000000 --- a/internal/controller/nonclusterhost_controller.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2024-2026 Tigera, Inc. All rights reserved. - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package controller - -import ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/tigera/operator/pkg/controller/nonclusterhost" - "github.com/tigera/operator/pkg/controller/options" -) - -// NonClusterHostReconciler reconciles a NonClusterHost object -type NonClusterHostReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=nonclusterhosts,verbs=get;list;watch;create;update;patch;delete -func (r *NonClusterHostReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return nonclusterhost.Add(mgr, opts) -} diff --git a/internal/controller/otelcollector_controller.go b/internal/controller/otelcollector_controller.go deleted file mode 100644 index 218e757ff9..0000000000 --- a/internal/controller/otelcollector_controller.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/tigera/operator/pkg/controller/options" - "github.com/tigera/operator/pkg/controller/otelcollector" -) - -type OpenTelemetryCollectorReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=logcollectors,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=logcollectors/status,verbs=get;update;patch - -func (r *OpenTelemetryCollectorReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return otelcollector.Add(mgr, opts) -} diff --git a/internal/controller/packetcapture_controller.go b/internal/controller/packetcapture_controller.go deleted file mode 100644 index ef561d19db..0000000000 --- a/internal/controller/packetcapture_controller.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2024-2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/tigera/operator/pkg/controller/options" - "github.com/tigera/operator/pkg/controller/packetcapture" -) - -// PacketCaptureReconciler reconciles a PacketCapture object. -type PacketCaptureReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=packetcaptureapi,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=packetcaptureapi/status,verbs=get;update;patch - -func (pc *PacketCaptureReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return packetcapture.Add(mgr, opts) -} diff --git a/internal/controller/policyrecommendation_controller.go b/internal/controller/policyrecommendation_controller.go deleted file mode 100644 index 11f34611f7..0000000000 --- a/internal/controller/policyrecommendation_controller.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2023-2026 Tigera, Inc. All rights reserved. -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/tigera/operator/pkg/controller/options" - "github.com/tigera/operator/pkg/controller/policyrecommendation" -) - -// PolicyRecommendationReconciler reconciles a PolicyRecommendation object. -type PolicyRecommendationReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=operator.tigera.io,resources=policyrecommendations,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.tigera.io,resources=policyrecommendations/status,verbs=get;update;patch - -func (pr *PolicyRecommendationReconciler) SetupWithManager(mgr ctrl.Manager, opts options.ControllerOptions) error { - return policyrecommendation.Add(mgr, opts) -} diff --git a/pkg/controller/installation/core_controller.go b/pkg/controller/installation/core_controller.go index d721b134ae..66f4dd17e1 100644 --- a/pkg/controller/installation/core_controller.go +++ b/pkg/controller/installation/core_controller.go @@ -993,7 +993,7 @@ func (r *ReconcileInstallation) Reconcile(ctx context.Context, request reconcile return reconcile.Result{}, err } - typhaNodeTLS, err := GetOrCreateTyphaNodeTLSConfig(r.client, certificateManager) + typhaNodeTLS, err := utils.GetOrCreateTyphaNodeTLSConfig(r.client, certificateManager) if err != nil { log.Error(err, "Error with Typha/Felix secrets") r.status.SetDegraded(operatorv1.CertificateError, "Error with Typha/Felix secrets", err, reqLogger) @@ -1006,7 +1006,7 @@ func (r *ReconcileInstallation) Reconcile(ctx context.Context, request reconcile return reconcile.Result{}, err } - bgpLayout, err := getConfigMap(r.client, render.BGPLayoutConfigMapName) + bgpLayout, err := utils.GetOperatorConfigMap(r.client, render.BGPLayoutConfigMapName) if err != nil { r.status.SetDegraded(operatorv1.ResourceReadError, "Error retrieving BGP layout ConfigMap", err, reqLogger) return reconcile.Result{}, err @@ -1599,83 +1599,6 @@ func calicoDirectoryExists() bool { return err == nil } -func GetOrCreateTyphaNodeTLSConfig(cli client.Client, certificateManager certificatemanager.CertificateManager) (*render.TyphaNodeTLS, error) { - return getOrCreateTyphaNodeTLSConfig(cli, certificateManager, certificateManager.GetOrCreateKeyPair) -} - -func GetTyphaNodeTLSConfig(cli client.Client, certificateManager certificatemanager.CertificateManager) (*render.TyphaNodeTLS, error) { - return getOrCreateTyphaNodeTLSConfig(cli, certificateManager, certificateManager.GetKeyPair) -} - -// getOrCreateTyphaNodeTLSConfig reads and validates the CA ConfigMap and Secrets for -// Typha and Felix configuration. It returns the validated resources or error -// if there was one. -func getOrCreateTyphaNodeTLSConfig(cli client.Client, certificateManager certificatemanager.CertificateManager, createKeyPairFunc func(cli client.Client, secretName, secretNamespace string, dnsNames []string) (certificatemanagement.KeyPairInterface, error)) (*render.TyphaNodeTLS, error) { - // accumulate all the error messages so all problems with the certs - // and CA are reported. - var errMsgs []string - getOrCreateKeyPair := func(secretName, commonName string, requireCNOrURISAN bool) (keyPair certificatemanagement.KeyPairInterface, cn string, uriSAN string) { - keyPair, err := createKeyPairFunc(cli, secretName, common.OperatorNamespace(), []string{commonName}) - if err != nil { - errMsgs = append(errMsgs, err.Error()) - } else { - - if !keyPair.BYO() { - cn = commonName - } else { - // todo: Integrate this with the new certificate manager or find another alternative for uriSAN and cn. - secret, err := utils.GetSecret(context.Background(), cli, secretName, common.OperatorNamespace()) - if err != nil { - errMsgs = append(errMsgs, err.Error()) - } else if secret != nil { - data := secret.Data - if data != nil { - cn, uriSAN = string(data[render.CommonName]), string(data[render.URISAN]) - } - } - } - if requireCNOrURISAN && cn == "" && uriSAN == "" { - errMsgs = append(errMsgs, "CertPair for Felix does not contain common-name or uri-san") - } - } - return - } - node, nodeCommonName, nodeURISAN := getOrCreateKeyPair(render.NodeTLSSecretName, render.FelixCommonName, true) - typha, typhaCommonName, typhaURISAN := getOrCreateKeyPair(render.TyphaTLSSecretName, render.TyphaCommonName, true) - var trustedBundle certificatemanagement.TrustedBundle - configMap, err := getConfigMap(cli, render.TyphaCAConfigMapName) - if err != nil { - errMsgs = append(errMsgs, fmt.Sprintf("CA for Typha is invalid: %s", err)) - } else if configMap != nil { - if len(configMap.Data[render.TyphaCABundleName]) == 0 { - errMsgs = append(errMsgs, fmt.Sprintf("ConfigMap %q does not have a field named %q", render.TyphaCAConfigMapName, render.TyphaCABundleName)) - } else { - trustedBundle, err = certificateManager.CreateTrustedBundleWithSystemRootCertificates(node, typha, - certificatemanagement.NewCertificate(render.TyphaCAConfigMapName, common.CalicoNamespace, []byte(configMap.Data[render.TyphaCABundleName]), nil)) - if err != nil { - errMsgs = append(errMsgs, fmt.Sprintf("Error creating trusted bundle %s", err)) - } - } - } else { - trustedBundle, err = certificateManager.CreateTrustedBundleWithSystemRootCertificates(node, typha) - if err != nil { - errMsgs = append(errMsgs, fmt.Sprintf("Error creating trusted bundle %s", err)) - } - } - if len(errMsgs) != 0 { - return nil, fmt.Errorf("%s", strings.Join(errMsgs, ";")) - } - return &render.TyphaNodeTLS{ - TrustedBundle: trustedBundle, - TyphaSecret: typha, - TyphaCommonName: typhaCommonName, - TyphaURISAN: typhaURISAN, - NodeSecret: node, - NodeCommonName: nodeCommonName, - NodeURISAN: nodeURISAN, - }, nil -} - func (r *ReconcileInstallation) setNftablesMode(_ context.Context, install *operatorv1.Installation, fc *v3.FelixConfiguration, reqLogger logr.Logger) (bool, error) { updated := false @@ -2174,23 +2097,8 @@ func (r *ReconcileInstallation) syncManagedAdmissionPolicies( return nil } -func getConfigMap(client client.Client, cmName string) (*corev1.ConfigMap, error) { - cm := &corev1.ConfigMap{} - cmNamespacedName := types.NamespacedName{ - Name: cmName, - Namespace: common.OperatorNamespace(), - } - if err := client.Get(context.Background(), cmNamespacedName, cm); err != nil { - if apierrors.IsNotFound(err) { - return nil, nil - } - return nil, fmt.Errorf("failed to read ConfigMap %q: %s", cmName, err) - } - return cm, nil -} - func getBirdTemplates(client client.Client) (map[string]string, error) { - cm, err := getConfigMap(client, render.BirdTemplatesConfigMapName) + cm, err := utils.GetOperatorConfigMap(client, render.BirdTemplatesConfigMapName) if err != nil || cm == nil { return nil, err } diff --git a/pkg/controller/installation/windows_controller.go b/pkg/controller/installation/windows_controller.go index a9d4a9d4bf..cb34accbc9 100644 --- a/pkg/controller/installation/windows_controller.go +++ b/pkg/controller/installation/windows_controller.go @@ -263,7 +263,7 @@ func (r *ReconcileWindows) Reconcile(ctx context.Context, request reconcile.Requ return reconcile.Result{}, err } - typhaNodeTLS, err := GetTyphaNodeTLSConfig(r.client, certificateManager) + typhaNodeTLS, err := utils.GetTyphaNodeTLSConfig(r.client, certificateManager) if err != nil { logw.Error(err, "Error with Typha/Felix secrets") r.status.SetDegraded(operatorv1.CertificateError, "Error with Typha/Felix secrets", err, reqLogger) diff --git a/pkg/controller/options/options.go b/pkg/controller/options/options.go index 5bd003a1e6..55a973e249 100644 --- a/pkg/controller/options/options.go +++ b/pkg/controller/options/options.go @@ -16,6 +16,9 @@ package options import ( "context" + "fmt" + + ctrl "sigs.k8s.io/controller-runtime" v1 "github.com/tigera/operator/api/v1" "github.com/tigera/operator/pkg/common" @@ -77,4 +80,27 @@ type ControllerOptions struct { // Extensions are the variant extensions the operator runs with, for the Variant // above. The core operator leaves them unset and runs the base behavior. Extensions extensions.Extensions + + // Controllers are the reconcilers the running variant adds to the core set. The + // core operator leaves them unset and runs only the controllers every variant runs. + Controllers []Controller +} + +// AddControllers adds the reconcilers the running variant contributes. +func (o ControllerOptions) AddControllers(mgr ctrl.Manager) error { + for _, c := range o.Controllers { + if err := c.Add(mgr, o); err != nil { + return fmt.Errorf("failed to create controller %s: %v", c.Name, err) + } + } + return nil +} + +// Controller is a reconciler a variant contributes, so that the core controller +// manager can add it without naming the type. +type Controller struct { + // Name identifies the controller when its setup fails. + Name string + + Add func(mgr ctrl.Manager, opts ControllerOptions) error } diff --git a/pkg/controller/options/options_test.go b/pkg/controller/options/options_test.go new file mode 100644 index 0000000000..cd9b12d683 --- /dev/null +++ b/pkg/controller/options/options_test.go @@ -0,0 +1,75 @@ +// Copyright (c) 2026 Tigera, Inc. All rights reserved. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package options_test + +import ( + "errors" + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + ctrl "sigs.k8s.io/controller-runtime" + + operatorv1 "github.com/tigera/operator/api/v1" + "github.com/tigera/operator/pkg/controller/options" +) + +func TestOptions(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "pkg/controller/options Suite") +} + +var _ = Describe("AddControllers", func() { + It("adds every contributed controller, in order", func() { + var added []string + add := func(name string) options.Controller { + return options.Controller{Name: name, Add: func(ctrl.Manager, options.ControllerOptions) error { + added = append(added, name) + return nil + }} + } + opts := options.ControllerOptions{Controllers: []options.Controller{add("First"), add("Second")}} + + Expect(opts.AddControllers(nil)).NotTo(HaveOccurred()) + Expect(added).To(Equal([]string{"First", "Second"})) + }) + + It("passes the options through to the controller", func() { + var got options.ControllerOptions + opts := options.ControllerOptions{ + Variant: operatorv1.CalicoEnterprise, + Controllers: []options.Controller{{Name: "Monitor", Add: func(_ ctrl.Manager, o options.ControllerOptions) error { + got = o + return nil + }}}, + } + + Expect(opts.AddControllers(nil)).NotTo(HaveOccurred()) + Expect(got.Variant).To(Equal(operatorv1.CalicoEnterprise)) + }) + + It("names the controller that failed", func() { + opts := options.ControllerOptions{Controllers: []options.Controller{{ + Name: "Monitor", + Add: func(ctrl.Manager, options.ControllerOptions) error { return errors.New("no watch") }, + }}} + + Expect(opts.AddControllers(nil)).To(MatchError(ContainSubstring("controller Monitor: no watch"))) + }) + + It("does nothing when the variant contributes none", func() { + Expect(options.ControllerOptions{}.AddControllers(nil)).NotTo(HaveOccurred()) + }) +}) diff --git a/pkg/controller/utils/typhatls.go b/pkg/controller/utils/typhatls.go new file mode 100644 index 0000000000..376e4a2e2c --- /dev/null +++ b/pkg/controller/utils/typhatls.go @@ -0,0 +1,125 @@ +// Copyright (c) 2019-2026 Tigera, Inc. All rights reserved. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package utils + +import ( + "context" + "fmt" + "strings" + + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/tigera/operator/pkg/common" + "github.com/tigera/operator/pkg/controller/certificatemanager" + "github.com/tigera/operator/pkg/render" + "github.com/tigera/operator/pkg/tls/certificatemanagement" +) + +func GetOrCreateTyphaNodeTLSConfig(cli client.Client, certificateManager certificatemanager.CertificateManager) (*render.TyphaNodeTLS, error) { + return getOrCreateTyphaNodeTLSConfig(cli, certificateManager, certificateManager.GetOrCreateKeyPair) +} + +func GetTyphaNodeTLSConfig(cli client.Client, certificateManager certificatemanager.CertificateManager) (*render.TyphaNodeTLS, error) { + return getOrCreateTyphaNodeTLSConfig(cli, certificateManager, certificateManager.GetKeyPair) +} + +// getOrCreateTyphaNodeTLSConfig reads and validates the CA ConfigMap and Secrets for +// Typha and Felix configuration. It returns the validated resources or error +// if there was one. +func getOrCreateTyphaNodeTLSConfig(cli client.Client, certificateManager certificatemanager.CertificateManager, createKeyPairFunc func(cli client.Client, secretName, secretNamespace string, dnsNames []string) (certificatemanagement.KeyPairInterface, error)) (*render.TyphaNodeTLS, error) { + // accumulate all the error messages so all problems with the certs + // and CA are reported. + var errMsgs []string + getOrCreateKeyPair := func(secretName, commonName string, requireCNOrURISAN bool) (keyPair certificatemanagement.KeyPairInterface, cn string, uriSAN string) { + keyPair, err := createKeyPairFunc(cli, secretName, common.OperatorNamespace(), []string{commonName}) + if err != nil { + errMsgs = append(errMsgs, err.Error()) + } else { + + if !keyPair.BYO() { + cn = commonName + } else { + // todo: Integrate this with the new certificate manager or find another alternative for uriSAN and cn. + secret, err := GetSecret(context.Background(), cli, secretName, common.OperatorNamespace()) + if err != nil { + errMsgs = append(errMsgs, err.Error()) + } else if secret != nil { + data := secret.Data + if data != nil { + cn, uriSAN = string(data[render.CommonName]), string(data[render.URISAN]) + } + } + } + if requireCNOrURISAN && cn == "" && uriSAN == "" { + errMsgs = append(errMsgs, "CertPair for Felix does not contain common-name or uri-san") + } + } + return + } + node, nodeCommonName, nodeURISAN := getOrCreateKeyPair(render.NodeTLSSecretName, render.FelixCommonName, true) + typha, typhaCommonName, typhaURISAN := getOrCreateKeyPair(render.TyphaTLSSecretName, render.TyphaCommonName, true) + var trustedBundle certificatemanagement.TrustedBundle + configMap, err := GetOperatorConfigMap(cli, render.TyphaCAConfigMapName) + if err != nil { + errMsgs = append(errMsgs, fmt.Sprintf("CA for Typha is invalid: %s", err)) + } else if configMap != nil { + if len(configMap.Data[render.TyphaCABundleName]) == 0 { + errMsgs = append(errMsgs, fmt.Sprintf("ConfigMap %q does not have a field named %q", render.TyphaCAConfigMapName, render.TyphaCABundleName)) + } else { + trustedBundle, err = certificateManager.CreateTrustedBundleWithSystemRootCertificates(node, typha, + certificatemanagement.NewCertificate(render.TyphaCAConfigMapName, common.CalicoNamespace, []byte(configMap.Data[render.TyphaCABundleName]), nil)) + if err != nil { + errMsgs = append(errMsgs, fmt.Sprintf("Error creating trusted bundle %s", err)) + } + } + } else { + trustedBundle, err = certificateManager.CreateTrustedBundleWithSystemRootCertificates(node, typha) + if err != nil { + errMsgs = append(errMsgs, fmt.Sprintf("Error creating trusted bundle %s", err)) + } + } + if len(errMsgs) != 0 { + return nil, fmt.Errorf("%s", strings.Join(errMsgs, ";")) + } + return &render.TyphaNodeTLS{ + TrustedBundle: trustedBundle, + TyphaSecret: typha, + TyphaCommonName: typhaCommonName, + TyphaURISAN: typhaURISAN, + NodeSecret: node, + NodeCommonName: nodeCommonName, + NodeURISAN: nodeURISAN, + }, nil +} + +// GetOperatorConfigMap reads a ConfigMap from the operator namespace, returning nil +// when it does not exist. +func GetOperatorConfigMap(client client.Client, cmName string) (*corev1.ConfigMap, error) { + cm := &corev1.ConfigMap{} + cmNamespacedName := types.NamespacedName{ + Name: cmName, + Namespace: common.OperatorNamespace(), + } + if err := client.Get(context.Background(), cmNamespacedName, cm); err != nil { + if apierrors.IsNotFound(err) { + return nil, nil + } + return nil, fmt.Errorf("failed to read ConfigMap %q: %s", cmName, err) + } + return cm, nil +} diff --git a/pkg/controller/applicationlayer/applicationlayer_controller.go b/pkg/enterprise/controller/applicationlayer/applicationlayer_controller.go similarity index 99% rename from pkg/controller/applicationlayer/applicationlayer_controller.go rename to pkg/enterprise/controller/applicationlayer/applicationlayer_controller.go index 055e287394..dc0700010a 100644 --- a/pkg/controller/applicationlayer/applicationlayer_controller.go +++ b/pkg/enterprise/controller/applicationlayer/applicationlayer_controller.go @@ -29,9 +29,9 @@ import ( "github.com/tigera/operator/pkg/controller/utils/imageset" "github.com/tigera/operator/pkg/ctrlruntime" "github.com/tigera/operator/pkg/enterprise/policysync" + "github.com/tigera/operator/pkg/enterprise/render/applicationlayer" + "github.com/tigera/operator/pkg/enterprise/render/applicationlayer/ruleset" "github.com/tigera/operator/pkg/render" - "github.com/tigera/operator/pkg/render/applicationlayer" - "github.com/tigera/operator/pkg/render/applicationlayer/ruleset" rmeta "github.com/tigera/operator/pkg/render/common/meta" admregv1 "k8s.io/api/admissionregistration/v1" @@ -55,10 +55,6 @@ var log = logf.Log.WithName("controller_applicationlayer") // Add creates a new ApplicationLayer Controller and adds it to the Manager. // The Manager will set fields on the Controller and Start it when the Manager is Started. func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - // No need to start this controller. - return nil - } licenseAPIReady := &utils.ReadyFlag{} reconciler := newReconciler(mgr, opts, licenseAPIReady) diff --git a/pkg/controller/applicationlayer/applicationlayer_controller_test.go b/pkg/enterprise/controller/applicationlayer/applicationlayer_controller_test.go similarity index 99% rename from pkg/controller/applicationlayer/applicationlayer_controller_test.go rename to pkg/enterprise/controller/applicationlayer/applicationlayer_controller_test.go index 45792ae1eb..ee93c147ef 100644 --- a/pkg/controller/applicationlayer/applicationlayer_controller_test.go +++ b/pkg/enterprise/controller/applicationlayer/applicationlayer_controller_test.go @@ -40,7 +40,7 @@ import ( "github.com/tigera/operator/pkg/controller/status" "github.com/tigera/operator/pkg/controller/utils" ctrlrfake "github.com/tigera/operator/pkg/ctrlruntime/client/fake" - "github.com/tigera/operator/pkg/render/applicationlayer" + "github.com/tigera/operator/pkg/enterprise/render/applicationlayer" "github.com/tigera/operator/test" ) diff --git a/pkg/controller/applicationlayer/applicationlayer_suit_test.go b/pkg/enterprise/controller/applicationlayer/applicationlayer_suit_test.go similarity index 80% rename from pkg/controller/applicationlayer/applicationlayer_suit_test.go rename to pkg/enterprise/controller/applicationlayer/applicationlayer_suit_test.go index d1dd86b33f..69dc7118c3 100644 --- a/pkg/controller/applicationlayer/applicationlayer_suit_test.go +++ b/pkg/enterprise/controller/applicationlayer/applicationlayer_suit_test.go @@ -24,6 +24,6 @@ import ( func TestStatus(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/applicationlayer_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/applicationlayer Controller Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/applicationlayer_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/applicationlayer Controller Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/authentication/authentication_controller.go b/pkg/enterprise/controller/authentication/authentication_controller.go similarity index 99% rename from pkg/controller/authentication/authentication_controller.go rename to pkg/enterprise/controller/authentication/authentication_controller.go index 5d36bc47b3..f37c6b7310 100644 --- a/pkg/controller/authentication/authentication_controller.go +++ b/pkg/enterprise/controller/authentication/authentication_controller.go @@ -68,11 +68,6 @@ const ( // Add creates a new authentication Controller and adds it to the Manager. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - // No need to start this controller. - return nil - } - // Create the reconciler tierWatchReady := &utils.ReadyFlag{} reconciler := newReconciler(mgr, opts, tierWatchReady) diff --git a/pkg/controller/authentication/authentication_controller_test.go b/pkg/enterprise/controller/authentication/authentication_controller_test.go similarity index 100% rename from pkg/controller/authentication/authentication_controller_test.go rename to pkg/enterprise/controller/authentication/authentication_controller_test.go diff --git a/pkg/controller/authentication/authentication_suite_test.go b/pkg/enterprise/controller/authentication/authentication_suite_test.go similarity index 82% rename from pkg/controller/authentication/authentication_suite_test.go rename to pkg/enterprise/controller/authentication/authentication_suite_test.go index 0f4194644c..f8c2cf4d4a 100644 --- a/pkg/controller/authentication/authentication_suite_test.go +++ b/pkg/enterprise/controller/authentication/authentication_suite_test.go @@ -24,6 +24,6 @@ import ( func TestStatus(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/authentication_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/authentication Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/authentication_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/authentication Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/egressgateway/egressgateway_controller.go b/pkg/enterprise/controller/egressgateway/egressgateway_controller.go similarity index 99% rename from pkg/controller/egressgateway/egressgateway_controller.go rename to pkg/enterprise/controller/egressgateway/egressgateway_controller.go index 19ae2ef6bf..0e5d1e667b 100644 --- a/pkg/controller/egressgateway/egressgateway_controller.go +++ b/pkg/enterprise/controller/egressgateway/egressgateway_controller.go @@ -44,9 +44,9 @@ import ( "github.com/tigera/operator/pkg/controller/utils" "github.com/tigera/operator/pkg/controller/utils/imageset" "github.com/tigera/operator/pkg/ctrlruntime" + "github.com/tigera/operator/pkg/enterprise/render/egressgateway" "github.com/tigera/operator/pkg/render" rmeta "github.com/tigera/operator/pkg/render/common/meta" - "github.com/tigera/operator/pkg/render/egressgateway" ) const ( @@ -58,10 +58,6 @@ var log = logf.Log.WithName("controller_egressgateway") // Add creates a new EgressGateway Controller and adds it to the Manager. // The Manager will set fields on the Controller and Start it when the Manager is Started. func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - // No need to start this controller. - return nil - } licenseAPIReady := &utils.ReadyFlag{} reconciler := newReconciler(mgr, opts, licenseAPIReady) diff --git a/pkg/controller/egressgateway/egressgateway_controller_test.go b/pkg/enterprise/controller/egressgateway/egressgateway_controller_test.go similarity index 100% rename from pkg/controller/egressgateway/egressgateway_controller_test.go rename to pkg/enterprise/controller/egressgateway/egressgateway_controller_test.go diff --git a/pkg/controller/egressgateway/egressgateway_suite_test.go b/pkg/enterprise/controller/egressgateway/egressgateway_suite_test.go similarity index 84% rename from pkg/controller/egressgateway/egressgateway_suite_test.go rename to pkg/enterprise/controller/egressgateway/egressgateway_suite_test.go index 0d64a392d1..524068dde9 100644 --- a/pkg/controller/egressgateway/egressgateway_suite_test.go +++ b/pkg/enterprise/controller/egressgateway/egressgateway_suite_test.go @@ -29,6 +29,6 @@ func TestStatus(t *testing.T) { logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true), zap.Level(uzap.NewAtomicLevelAt(uzap.DebugLevel)))) gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/egressgateway_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/egressgateway Controller Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/egressgateway_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/egressgateway Controller Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/intrusiondetection/intrusiondetection_controller.go b/pkg/enterprise/controller/intrusiondetection/intrusiondetection_controller.go similarity index 98% rename from pkg/controller/intrusiondetection/intrusiondetection_controller.go rename to pkg/enterprise/controller/intrusiondetection/intrusiondetection_controller.go index 099e884fe7..786cda92aa 100644 --- a/pkg/controller/intrusiondetection/intrusiondetection_controller.go +++ b/pkg/enterprise/controller/intrusiondetection/intrusiondetection_controller.go @@ -39,8 +39,6 @@ import ( operatorv1 "github.com/tigera/operator/api/v1" "github.com/tigera/operator/pkg/common" "github.com/tigera/operator/pkg/controller/certificatemanager" - "github.com/tigera/operator/pkg/controller/installation" - "github.com/tigera/operator/pkg/controller/logcollector" "github.com/tigera/operator/pkg/controller/logstorage/esutils" "github.com/tigera/operator/pkg/controller/options" "github.com/tigera/operator/pkg/controller/status" @@ -50,12 +48,13 @@ import ( "github.com/tigera/operator/pkg/ctrlruntime" "github.com/tigera/operator/pkg/dns" entcertificatemanager "github.com/tigera/operator/pkg/enterprise/certificatemanager" + "github.com/tigera/operator/pkg/enterprise/controller/logcollector" + "github.com/tigera/operator/pkg/enterprise/render/intrusiondetection/dpi" eutils "github.com/tigera/operator/pkg/enterprise/utils" "github.com/tigera/operator/pkg/render" rcertificatemanagement "github.com/tigera/operator/pkg/render/certificatemanagement" relasticsearch "github.com/tigera/operator/pkg/render/common/elasticsearch" "github.com/tigera/operator/pkg/render/common/networkpolicy" - "github.com/tigera/operator/pkg/render/intrusiondetection/dpi" "github.com/tigera/operator/pkg/tls/certificatemanagement" ) @@ -66,11 +65,6 @@ var log = logf.Log.WithName("controller_intrusiondetection") // Add creates a new IntrusionDetection Controller and adds it to the Manager. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - // No need to start this controller. - return nil - } - licenseAPIReady := &utils.ReadyFlag{} dpiAPIReady := &utils.ReadyFlag{} tierWatchReady := &utils.ReadyFlag{} @@ -514,7 +508,7 @@ func (r *ReconcileIntrusionDetection) Reconcile(ctx context.Context, request rec // FIXME: core controller creates TyphaNodeTLSConfig, this controller should only get it. // But changing the call from GetOrCreateTyphaNodeTLSConfig() to GetTyphaNodeTLSConfig() // makes tests fail, this needs to be looked at. - typhaNodeTLS, err := installation.GetOrCreateTyphaNodeTLSConfig(r.client, certificateManager) + typhaNodeTLS, err := utils.GetOrCreateTyphaNodeTLSConfig(r.client, certificateManager) if err != nil { r.status.SetDegraded(operatorv1.ResourceReadError, "Error with Typha/Felix secrets", err, reqLogger) return reconcile.Result{}, err diff --git a/pkg/controller/intrusiondetection/intrusiondetection_controller_test.go b/pkg/enterprise/controller/intrusiondetection/intrusiondetection_controller_test.go similarity index 99% rename from pkg/controller/intrusiondetection/intrusiondetection_controller_test.go rename to pkg/enterprise/controller/intrusiondetection/intrusiondetection_controller_test.go index 700b8fd38a..c8eb3af83d 100644 --- a/pkg/controller/intrusiondetection/intrusiondetection_controller_test.go +++ b/pkg/enterprise/controller/intrusiondetection/intrusiondetection_controller_test.go @@ -49,10 +49,10 @@ import ( "github.com/tigera/operator/pkg/controller/utils" ctrlrfake "github.com/tigera/operator/pkg/ctrlruntime/client/fake" entcertificatemanager "github.com/tigera/operator/pkg/enterprise/certificatemanager" + "github.com/tigera/operator/pkg/enterprise/render/intrusiondetection/dpi" "github.com/tigera/operator/pkg/render" relasticsearch "github.com/tigera/operator/pkg/render/common/elasticsearch" rtest "github.com/tigera/operator/pkg/render/common/test" - "github.com/tigera/operator/pkg/render/intrusiondetection/dpi" "github.com/tigera/operator/pkg/render/logstorage/eck" "github.com/tigera/operator/test" ) diff --git a/pkg/controller/intrusiondetection/intrusiondetection_suite_test.go b/pkg/enterprise/controller/intrusiondetection/intrusiondetection_suite_test.go similarity index 80% rename from pkg/controller/intrusiondetection/intrusiondetection_suite_test.go rename to pkg/enterprise/controller/intrusiondetection/intrusiondetection_suite_test.go index 3e056b5fc1..dd25009341 100644 --- a/pkg/controller/intrusiondetection/intrusiondetection_suite_test.go +++ b/pkg/enterprise/controller/intrusiondetection/intrusiondetection_suite_test.go @@ -24,6 +24,6 @@ import ( func TestStatus(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/intrusiondetection_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/intrusiondetection Controller Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/intrusiondetection_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/intrusiondetection Controller Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/logcollector/logcollector_controller.go b/pkg/enterprise/controller/logcollector/logcollector_controller.go similarity index 99% rename from pkg/controller/logcollector/logcollector_controller.go rename to pkg/enterprise/controller/logcollector/logcollector_controller.go index 9d0499afb5..3018548ba1 100644 --- a/pkg/controller/logcollector/logcollector_controller.go +++ b/pkg/enterprise/controller/logcollector/logcollector_controller.go @@ -42,6 +42,7 @@ import ( "github.com/tigera/operator/pkg/controller/utils" "github.com/tigera/operator/pkg/controller/utils/imageset" "github.com/tigera/operator/pkg/ctrlruntime" + "github.com/tigera/operator/pkg/enterprise/render/otelcollector" eutils "github.com/tigera/operator/pkg/enterprise/utils" "github.com/tigera/operator/pkg/render" rcertificatemanagement "github.com/tigera/operator/pkg/render/certificatemanagement" @@ -49,7 +50,6 @@ import ( "github.com/tigera/operator/pkg/render/common/networkpolicy" rlogcollector "github.com/tigera/operator/pkg/render/logcollector" "github.com/tigera/operator/pkg/render/monitor" - "github.com/tigera/operator/pkg/render/otelcollector" "github.com/tigera/operator/pkg/tls/certificatemanagement" "github.com/tigera/operator/pkg/url" ) @@ -61,11 +61,6 @@ var log = logf.Log.WithName("controller_logcollector") // Add creates a new LogCollector Controller and adds it to the Manager. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - // No need to start this controller. - return nil - } - licenseAPIReady := &utils.ReadyFlag{} tierWatchReady := &utils.ReadyFlag{} diff --git a/pkg/controller/logcollector/logcollector_controller_test.go b/pkg/enterprise/controller/logcollector/logcollector_controller_test.go similarity index 99% rename from pkg/controller/logcollector/logcollector_controller_test.go rename to pkg/enterprise/controller/logcollector/logcollector_controller_test.go index d7ebe8f4da..25b1a9ce22 100644 --- a/pkg/controller/logcollector/logcollector_controller_test.go +++ b/pkg/enterprise/controller/logcollector/logcollector_controller_test.go @@ -50,11 +50,11 @@ import ( "github.com/tigera/operator/pkg/controller/status" "github.com/tigera/operator/pkg/controller/utils" ctrlrfake "github.com/tigera/operator/pkg/ctrlruntime/client/fake" + "github.com/tigera/operator/pkg/enterprise/render/otelcollector" "github.com/tigera/operator/pkg/render" rtest "github.com/tigera/operator/pkg/render/common/test" rlogcollector "github.com/tigera/operator/pkg/render/logcollector" "github.com/tigera/operator/pkg/render/monitor" - "github.com/tigera/operator/pkg/render/otelcollector" "github.com/tigera/operator/test" ) diff --git a/pkg/controller/logcollector/logcollector_suite_test.go b/pkg/enterprise/controller/logcollector/logcollector_suite_test.go similarity index 81% rename from pkg/controller/logcollector/logcollector_suite_test.go rename to pkg/enterprise/controller/logcollector/logcollector_suite_test.go index 6913213e24..359b4373e5 100644 --- a/pkg/controller/logcollector/logcollector_suite_test.go +++ b/pkg/enterprise/controller/logcollector/logcollector_suite_test.go @@ -24,6 +24,6 @@ import ( func TestStatus(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/logcollector_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/logcollector Controller Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/logcollector_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/logcollector Controller Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/manager/gateway_status_test.go b/pkg/enterprise/controller/manager/gateway_status_test.go similarity index 100% rename from pkg/controller/manager/gateway_status_test.go rename to pkg/enterprise/controller/manager/gateway_status_test.go diff --git a/pkg/controller/manager/manager_controller.go b/pkg/enterprise/controller/manager/manager_controller.go similarity index 99% rename from pkg/controller/manager/manager_controller.go rename to pkg/enterprise/controller/manager/manager_controller.go index f6a8379836..b07f5abf61 100644 --- a/pkg/controller/manager/manager_controller.go +++ b/pkg/enterprise/controller/manager/manager_controller.go @@ -78,11 +78,6 @@ var log = logf.Log.WithName("controller_manager") // Add creates a new Manager Controller and adds it to the Manager. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - // No need to start this controller. - return nil - } - licenseAPIReady := &utils.ReadyFlag{} tierWatchReady := &utils.ReadyFlag{} diff --git a/pkg/controller/manager/manager_controller_cloud.go b/pkg/enterprise/controller/manager/manager_controller_cloud.go similarity index 100% rename from pkg/controller/manager/manager_controller_cloud.go rename to pkg/enterprise/controller/manager/manager_controller_cloud.go diff --git a/pkg/controller/manager/manager_controller_cloud_test.go b/pkg/enterprise/controller/manager/manager_controller_cloud_test.go similarity index 100% rename from pkg/controller/manager/manager_controller_cloud_test.go rename to pkg/enterprise/controller/manager/manager_controller_cloud_test.go diff --git a/pkg/controller/manager/manager_controller_suite_test.go b/pkg/enterprise/controller/manager/manager_controller_suite_test.go similarity index 86% rename from pkg/controller/manager/manager_controller_suite_test.go rename to pkg/enterprise/controller/manager/manager_controller_suite_test.go index 010f284035..37e2e82548 100644 --- a/pkg/controller/manager/manager_controller_suite_test.go +++ b/pkg/enterprise/controller/manager/manager_controller_suite_test.go @@ -29,6 +29,6 @@ func TestStatus(t *testing.T) { logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true), zap.Level(uzap.NewAtomicLevelAt(uzap.DebugLevel)))) gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/manager_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/manager Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/manager_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/manager Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/manager/manager_controller_test.go b/pkg/enterprise/controller/manager/manager_controller_test.go similarity index 100% rename from pkg/controller/manager/manager_controller_test.go rename to pkg/enterprise/controller/manager/manager_controller_test.go diff --git a/pkg/controller/monitor/alertmanager-config.yaml b/pkg/enterprise/controller/monitor/alertmanager-config.yaml similarity index 100% rename from pkg/controller/monitor/alertmanager-config.yaml rename to pkg/enterprise/controller/monitor/alertmanager-config.yaml diff --git a/pkg/controller/monitor/monitor_controller.go b/pkg/enterprise/controller/monitor/monitor_controller.go similarity index 99% rename from pkg/controller/monitor/monitor_controller.go rename to pkg/enterprise/controller/monitor/monitor_controller.go index 872cac913f..e29ef74e66 100644 --- a/pkg/controller/monitor/monitor_controller.go +++ b/pkg/enterprise/controller/monitor/monitor_controller.go @@ -61,10 +61,6 @@ const ResourceName = "monitor" var log = logf.Log.WithName("controller_monitor") func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - return nil - } - prometheusReady := &utils.ReadyFlag{} tierWatchReady := &utils.ReadyFlag{} licenseAPIReady := &utils.ReadyFlag{} diff --git a/pkg/controller/monitor/monitor_controller_suite_test.go b/pkg/enterprise/controller/monitor/monitor_controller_suite_test.go similarity index 86% rename from pkg/controller/monitor/monitor_controller_suite_test.go rename to pkg/enterprise/controller/monitor/monitor_controller_suite_test.go index 1a3526bf70..ae94b2d5a6 100644 --- a/pkg/controller/monitor/monitor_controller_suite_test.go +++ b/pkg/enterprise/controller/monitor/monitor_controller_suite_test.go @@ -29,6 +29,6 @@ func TestStatus(t *testing.T) { logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true), zap.Level(uzap.NewAtomicLevelAt(uzap.DebugLevel)))) gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/monitor_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/monitor Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/monitor_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/monitor Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/monitor/monitor_controller_test.go b/pkg/enterprise/controller/monitor/monitor_controller_test.go similarity index 100% rename from pkg/controller/monitor/monitor_controller_test.go rename to pkg/enterprise/controller/monitor/monitor_controller_test.go diff --git a/pkg/controller/monitor/prometheus.go b/pkg/enterprise/controller/monitor/prometheus.go similarity index 100% rename from pkg/controller/monitor/prometheus.go rename to pkg/enterprise/controller/monitor/prometheus.go diff --git a/pkg/controller/nonclusterhost/nonclusterhost_controller.go b/pkg/enterprise/controller/nonclusterhost/nonclusterhost_controller.go similarity index 98% rename from pkg/controller/nonclusterhost/nonclusterhost_controller.go rename to pkg/enterprise/controller/nonclusterhost/nonclusterhost_controller.go index b522d2f580..b45b91c6f0 100644 --- a/pkg/controller/nonclusterhost/nonclusterhost_controller.go +++ b/pkg/enterprise/controller/nonclusterhost/nonclusterhost_controller.go @@ -42,10 +42,6 @@ const controllerName = "nonclusterhost-controller" var log = logf.Log.WithName("controller_nonclusterhost") func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - return nil - } - // create the reconciler reconciler := newReconciler(mgr, opts) diff --git a/pkg/controller/nonclusterhost/nonclusterhost_controller_suite_test.go b/pkg/enterprise/controller/nonclusterhost/nonclusterhost_controller_suite_test.go similarity index 85% rename from pkg/controller/nonclusterhost/nonclusterhost_controller_suite_test.go rename to pkg/enterprise/controller/nonclusterhost/nonclusterhost_controller_suite_test.go index 6182138eab..37ec61e9d5 100644 --- a/pkg/controller/nonclusterhost/nonclusterhost_controller_suite_test.go +++ b/pkg/enterprise/controller/nonclusterhost/nonclusterhost_controller_suite_test.go @@ -29,6 +29,6 @@ func TestStatus(t *testing.T) { logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true), zap.Level(uzap.NewAtomicLevelAt(uzap.DebugLevel)))) gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/nonclusterhost_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/nonclusterhost Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/nonclusterhost_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/nonclusterhost Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/nonclusterhost/nonclusterhost_controller_test.go b/pkg/enterprise/controller/nonclusterhost/nonclusterhost_controller_test.go similarity index 100% rename from pkg/controller/nonclusterhost/nonclusterhost_controller_test.go rename to pkg/enterprise/controller/nonclusterhost/nonclusterhost_controller_test.go diff --git a/pkg/controller/otelcollector/controller.go b/pkg/enterprise/controller/otelcollector/controller.go similarity index 99% rename from pkg/controller/otelcollector/controller.go rename to pkg/enterprise/controller/otelcollector/controller.go index ca88abaa5b..005fc53626 100644 --- a/pkg/controller/otelcollector/controller.go +++ b/pkg/enterprise/controller/otelcollector/controller.go @@ -47,11 +47,11 @@ import ( "github.com/tigera/operator/pkg/controller/utils/imageset" "github.com/tigera/operator/pkg/ctrlruntime" "github.com/tigera/operator/pkg/dns" + "github.com/tigera/operator/pkg/enterprise/render/otelcollector" "github.com/tigera/operator/pkg/render" rcertificatemanagement "github.com/tigera/operator/pkg/render/certificatemanagement" "github.com/tigera/operator/pkg/render/common/networkpolicy" "github.com/tigera/operator/pkg/render/monitor" - "github.com/tigera/operator/pkg/render/otelcollector" "github.com/tigera/operator/pkg/tls/certificatemanagement" ) @@ -63,10 +63,6 @@ const ( var log = logf.Log.WithName(controllerName) func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - return nil - } - licenseAPIReady := &utils.ReadyFlag{} tierWatchReady := &utils.ReadyFlag{} diff --git a/pkg/controller/otelcollector/otelcollector_controller_test.go b/pkg/enterprise/controller/otelcollector/otelcollector_controller_test.go similarity index 99% rename from pkg/controller/otelcollector/otelcollector_controller_test.go rename to pkg/enterprise/controller/otelcollector/otelcollector_controller_test.go index 89986cf114..93d99d95d8 100644 --- a/pkg/controller/otelcollector/otelcollector_controller_test.go +++ b/pkg/enterprise/controller/otelcollector/otelcollector_controller_test.go @@ -40,8 +40,8 @@ import ( "github.com/tigera/operator/pkg/controller/utils" ctrlrfake "github.com/tigera/operator/pkg/ctrlruntime/client/fake" "github.com/tigera/operator/pkg/dns" + "github.com/tigera/operator/pkg/enterprise/render/otelcollector" "github.com/tigera/operator/pkg/render/common/networkpolicy" - "github.com/tigera/operator/pkg/render/otelcollector" "github.com/tigera/operator/pkg/tls/certificatemanagement" "github.com/tigera/operator/test" ) diff --git a/pkg/controller/otelcollector/otelcollector_suite_test.go b/pkg/enterprise/controller/otelcollector/otelcollector_suite_test.go similarity index 84% rename from pkg/controller/otelcollector/otelcollector_suite_test.go rename to pkg/enterprise/controller/otelcollector/otelcollector_suite_test.go index 860f89ef35..1ec6349b97 100644 --- a/pkg/controller/otelcollector/otelcollector_suite_test.go +++ b/pkg/enterprise/controller/otelcollector/otelcollector_suite_test.go @@ -28,6 +28,6 @@ func TestController(t *testing.T) { logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true), zap.Level(uzap.NewAtomicLevelAt(uzap.DebugLevel)))) gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/otelcollector_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/otelcollector Controller Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/otelcollector_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/otelcollector Controller Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/packetcapture/packetcapture_controller.go b/pkg/enterprise/controller/packetcapture/packetcapture_controller.go similarity index 99% rename from pkg/controller/packetcapture/packetcapture_controller.go rename to pkg/enterprise/controller/packetcapture/packetcapture_controller.go index 7c77db3609..293479baef 100644 --- a/pkg/controller/packetcapture/packetcapture_controller.go +++ b/pkg/enterprise/controller/packetcapture/packetcapture_controller.go @@ -56,11 +56,6 @@ var log = logf.Log.WithName("controller_packet_capture") // Add creates a new PacketCapture Controller and adds it to the Manager. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - // No need to start this controller - return nil - } - tierWatchReady := &utils.ReadyFlag{} r := newReconciler(mgr, opts, tierWatchReady) diff --git a/pkg/controller/packetcapture/packetcapture_controller_test.go b/pkg/enterprise/controller/packetcapture/packetcapture_controller_test.go similarity index 100% rename from pkg/controller/packetcapture/packetcapture_controller_test.go rename to pkg/enterprise/controller/packetcapture/packetcapture_controller_test.go diff --git a/pkg/controller/packetcapture/packetcapture_suite_test.go b/pkg/enterprise/controller/packetcapture/packetcapture_suite_test.go similarity index 84% rename from pkg/controller/packetcapture/packetcapture_suite_test.go rename to pkg/enterprise/controller/packetcapture/packetcapture_suite_test.go index 9d6141bf67..87243764eb 100644 --- a/pkg/controller/packetcapture/packetcapture_suite_test.go +++ b/pkg/enterprise/controller/packetcapture/packetcapture_suite_test.go @@ -29,6 +29,6 @@ func TestStatus(t *testing.T) { logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true), zap.Level(uzap.NewAtomicLevelAt(uzap.DebugLevel)))) gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/packetcapture_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/packetcapture Controller Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/packetcapture_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/packetcapture Controller Suite", suiteConfig, reporterConfig) } diff --git a/pkg/controller/policyrecommendation/policyrecommendation_controller.go b/pkg/enterprise/controller/policyrecommendation/policyrecommendation_controller.go similarity index 99% rename from pkg/controller/policyrecommendation/policyrecommendation_controller.go rename to pkg/enterprise/controller/policyrecommendation/policyrecommendation_controller.go index e4fc6b2807..472667353d 100644 --- a/pkg/controller/policyrecommendation/policyrecommendation_controller.go +++ b/pkg/enterprise/controller/policyrecommendation/policyrecommendation_controller.go @@ -61,10 +61,6 @@ var log = logf.Log.WithName("controller_policy_recommendation") // Add creates a new PolicyRecommendation Controller and adds it to the Manager. The Manager will // set fields on the Controller and Start it when the Manager is Started. func Add(mgr manager.Manager, opts options.ControllerOptions) error { - if !opts.Variant.IsEnterprise() { - // No need to start this controller - return nil - } licenseAPIReady := &utils.ReadyFlag{} tierWatchReady := &utils.ReadyFlag{} policyRecScopeWatchReady := &utils.ReadyFlag{} diff --git a/pkg/controller/policyrecommendation/policyrecommendation_controller_test.go b/pkg/enterprise/controller/policyrecommendation/policyrecommendation_controller_test.go similarity index 100% rename from pkg/controller/policyrecommendation/policyrecommendation_controller_test.go rename to pkg/enterprise/controller/policyrecommendation/policyrecommendation_controller_test.go diff --git a/pkg/controller/policyrecommendation/policyrecommendation_suite_test.go b/pkg/enterprise/controller/policyrecommendation/policyrecommendation_suite_test.go similarity index 84% rename from pkg/controller/policyrecommendation/policyrecommendation_suite_test.go rename to pkg/enterprise/controller/policyrecommendation/policyrecommendation_suite_test.go index ecfb68c6f5..69eaf24c88 100644 --- a/pkg/controller/policyrecommendation/policyrecommendation_suite_test.go +++ b/pkg/enterprise/controller/policyrecommendation/policyrecommendation_suite_test.go @@ -29,6 +29,6 @@ func TestStatus(t *testing.T) { logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true), zap.Level(uzap.NewAtomicLevelAt(uzap.DebugLevel)))) gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/policyrecommendation_controller_suite.xml" - ginkgo.RunSpecs(t, "pkg/controller/policyrecommendation Controller Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/policyrecommendation_controller_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/controller/policyrecommendation Controller Suite", suiteConfig, reporterConfig) } diff --git a/pkg/enterprise/controllers.go b/pkg/enterprise/controllers.go new file mode 100644 index 0000000000..bbd4af30b4 --- /dev/null +++ b/pkg/enterprise/controllers.go @@ -0,0 +1,53 @@ +// Copyright (c) 2026 Tigera, Inc. All rights reserved. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package enterprise + +import ( + operatorv1 "github.com/tigera/operator/api/v1" + "github.com/tigera/operator/pkg/controller/options" + "github.com/tigera/operator/pkg/enterprise/controller/applicationlayer" + "github.com/tigera/operator/pkg/enterprise/controller/authentication" + "github.com/tigera/operator/pkg/enterprise/controller/egressgateway" + "github.com/tigera/operator/pkg/enterprise/controller/intrusiondetection" + "github.com/tigera/operator/pkg/enterprise/controller/logcollector" + "github.com/tigera/operator/pkg/enterprise/controller/manager" + "github.com/tigera/operator/pkg/enterprise/controller/monitor" + "github.com/tigera/operator/pkg/enterprise/controller/nonclusterhost" + "github.com/tigera/operator/pkg/enterprise/controller/otelcollector" + "github.com/tigera/operator/pkg/enterprise/controller/packetcapture" + "github.com/tigera/operator/pkg/enterprise/controller/policyrecommendation" +) + +// Controllers returns the reconcilers only Calico Enterprise runs, for the caller to +// pass to the controller manager. Registering here is what gates them, so the +// controllers themselves do not check the variant. +func Controllers(variant operatorv1.ProductVariant) []options.Controller { + if !variant.IsEnterprise() { + return nil + } + return []options.Controller{ + {Name: "Monitor", Add: monitor.Add}, + {Name: "ApplicationLayer", Add: applicationlayer.Add}, + {Name: "EgressGateway", Add: egressgateway.Add}, + {Name: "PacketCapture", Add: packetcapture.Add}, + {Name: "OpenTelemetryCollector", Add: otelcollector.Add}, + {Name: "IntrusionDetection", Add: intrusiondetection.Add}, + {Name: "LogCollector", Add: logcollector.Add}, + {Name: "Manager", Add: manager.Add}, + {Name: "NonClusterHost", Add: nonclusterhost.Add}, + {Name: "Authentication", Add: authentication.Add}, + {Name: "PolicyRecommendation", Add: policyrecommendation.Add}, + } +} diff --git a/pkg/enterprise/controllers_test.go b/pkg/enterprise/controllers_test.go new file mode 100644 index 0000000000..4ae7573c3e --- /dev/null +++ b/pkg/enterprise/controllers_test.go @@ -0,0 +1,44 @@ +// Copyright (c) 2026 Tigera, Inc. All rights reserved. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package enterprise_test + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + operatorv1 "github.com/tigera/operator/api/v1" + "github.com/tigera/operator/pkg/enterprise" +) + +var _ = Describe("Controllers", func() { + DescribeTable("contributes the Enterprise-only controllers", + func(variant operatorv1.ProductVariant) { + names := []string{} + for _, c := range enterprise.Controllers(variant) { + Expect(c.Add).NotTo(BeNil()) + names = append(names, c.Name) + } + Expect(names).To(ConsistOf("Monitor", "ApplicationLayer", "EgressGateway", "PacketCapture", "OpenTelemetryCollector", "IntrusionDetection", "LogCollector", + "Manager", "NonClusterHost", "Authentication", "PolicyRecommendation")) + }, + Entry("CalicoEnterprise", operatorv1.CalicoEnterprise), + //nolint:staticcheck // SA1019: the deprecated spelling is what this covers + Entry("TigeraSecureEnterprise", operatorv1.TigeraSecureEnterprise), + ) + + It("contributes nothing for Calico", func() { + Expect(enterprise.Controllers(operatorv1.Calico)).To(BeEmpty()) + }) +}) diff --git a/pkg/enterprise/csr/extension.go b/pkg/enterprise/csr/extension.go index 0b9f4e88f5..7d496a956d 100644 --- a/pkg/enterprise/csr/extension.go +++ b/pkg/enterprise/csr/extension.go @@ -33,9 +33,9 @@ import ( operatorv1 "github.com/tigera/operator/api/v1" "github.com/tigera/operator/pkg/controller" - "github.com/tigera/operator/pkg/controller/monitor" "github.com/tigera/operator/pkg/controller/utils" "github.com/tigera/operator/pkg/ctrlruntime" + "github.com/tigera/operator/pkg/enterprise/controller/monitor" eutils "github.com/tigera/operator/pkg/enterprise/utils" "github.com/tigera/operator/pkg/extensions" "github.com/tigera/operator/pkg/render" diff --git a/pkg/enterprise/csr/extension_test.go b/pkg/enterprise/csr/extension_test.go index 43edb260ac..0d1565e74f 100644 --- a/pkg/enterprise/csr/extension_test.go +++ b/pkg/enterprise/csr/extension_test.go @@ -36,10 +36,10 @@ import ( operatorv1 "github.com/tigera/operator/api/v1" "github.com/tigera/operator/pkg/apis" "github.com/tigera/operator/pkg/controller" - "github.com/tigera/operator/pkg/controller/monitor" "github.com/tigera/operator/pkg/ctrlruntime" ctrlrfake "github.com/tigera/operator/pkg/ctrlruntime/client/fake" "github.com/tigera/operator/pkg/dns" + "github.com/tigera/operator/pkg/enterprise/controller/monitor" "github.com/tigera/operator/pkg/render" rmonitor "github.com/tigera/operator/pkg/render/monitor" ) diff --git a/pkg/enterprise/installation/kubecontrollers.go b/pkg/enterprise/installation/kubecontrollers.go index 6d4d80f3bd..7b7fa6b6ec 100644 --- a/pkg/enterprise/installation/kubecontrollers.go +++ b/pkg/enterprise/installation/kubecontrollers.go @@ -40,9 +40,9 @@ import ( "github.com/tigera/operator/pkg/controller/utils/imageset" "github.com/tigera/operator/pkg/dns" entkubecontrollers "github.com/tigera/operator/pkg/enterprise/kubecontrollers" + "github.com/tigera/operator/pkg/enterprise/render/applicationlayer" "github.com/tigera/operator/pkg/extensions" "github.com/tigera/operator/pkg/render" - "github.com/tigera/operator/pkg/render/applicationlayer" rcomp "github.com/tigera/operator/pkg/render/common/components" rmeta "github.com/tigera/operator/pkg/render/common/meta" "github.com/tigera/operator/pkg/render/common/networkpolicy" diff --git a/pkg/enterprise/installation/kubecontrollers_test.go b/pkg/enterprise/installation/kubecontrollers_test.go index 5753cc48c1..e9f2c52b1a 100644 --- a/pkg/enterprise/installation/kubecontrollers_test.go +++ b/pkg/enterprise/installation/kubecontrollers_test.go @@ -40,10 +40,10 @@ import ( "github.com/tigera/operator/pkg/enterprise" "github.com/tigera/operator/pkg/enterprise/installation" eoptions "github.com/tigera/operator/pkg/enterprise/options" + "github.com/tigera/operator/pkg/enterprise/render/applicationlayer" "github.com/tigera/operator/pkg/extensions" "github.com/tigera/operator/pkg/extensions/extensionstest" "github.com/tigera/operator/pkg/render" - "github.com/tigera/operator/pkg/render/applicationlayer" rmeta "github.com/tigera/operator/pkg/render/common/meta" "github.com/tigera/operator/pkg/render/common/networkpolicy" "github.com/tigera/operator/pkg/render/common/rbacmanagement" diff --git a/pkg/render/applicationlayer/applicationlayer.go b/pkg/enterprise/render/applicationlayer/applicationlayer.go similarity index 100% rename from pkg/render/applicationlayer/applicationlayer.go rename to pkg/enterprise/render/applicationlayer/applicationlayer.go diff --git a/pkg/render/applicationlayer/applicationlayer_suit_test.go b/pkg/enterprise/render/applicationlayer/applicationlayer_suit_test.go similarity index 92% rename from pkg/render/applicationlayer/applicationlayer_suit_test.go rename to pkg/enterprise/render/applicationlayer/applicationlayer_suit_test.go index cbb5cf7ddc..5d7eaef804 100644 --- a/pkg/render/applicationlayer/applicationlayer_suit_test.go +++ b/pkg/enterprise/render/applicationlayer/applicationlayer_suit_test.go @@ -24,6 +24,6 @@ import ( func TestRender(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/applicationlayer_suite.xml" + reporterConfig.JUnitReport = "../../../../report/applicationlayer_suite.xml" ginkgo.RunSpecs(t, "pkg/applicationlayer/applicationlayer Suite", suiteConfig, reporterConfig) } diff --git a/pkg/render/applicationlayer/applicationlayer_test.go b/pkg/enterprise/render/applicationlayer/applicationlayer_test.go similarity index 99% rename from pkg/render/applicationlayer/applicationlayer_test.go rename to pkg/enterprise/render/applicationlayer/applicationlayer_test.go index dcda65b91e..fc4a97645f 100644 --- a/pkg/render/applicationlayer/applicationlayer_test.go +++ b/pkg/enterprise/render/applicationlayer/applicationlayer_test.go @@ -26,8 +26,8 @@ import ( operatorv1 "github.com/tigera/operator/api/v1" "github.com/tigera/operator/pkg/common" - "github.com/tigera/operator/pkg/render/applicationlayer" - "github.com/tigera/operator/pkg/render/applicationlayer/ruleset" + "github.com/tigera/operator/pkg/enterprise/render/applicationlayer" + "github.com/tigera/operator/pkg/enterprise/render/applicationlayer/ruleset" rmeta "github.com/tigera/operator/pkg/render/common/meta" rtest "github.com/tigera/operator/pkg/render/common/test" "github.com/tigera/operator/test" diff --git a/pkg/render/applicationlayer/envoy-config.yaml.template b/pkg/enterprise/render/applicationlayer/envoy-config.yaml.template similarity index 100% rename from pkg/render/applicationlayer/envoy-config.yaml.template rename to pkg/enterprise/render/applicationlayer/envoy-config.yaml.template diff --git a/pkg/render/applicationlayer/gateway_waf.go b/pkg/enterprise/render/applicationlayer/gateway_waf.go similarity index 100% rename from pkg/render/applicationlayer/gateway_waf.go rename to pkg/enterprise/render/applicationlayer/gateway_waf.go diff --git a/pkg/render/applicationlayer/gateway_waf_test.go b/pkg/enterprise/render/applicationlayer/gateway_waf_test.go similarity index 98% rename from pkg/render/applicationlayer/gateway_waf_test.go rename to pkg/enterprise/render/applicationlayer/gateway_waf_test.go index eea74ddf40..8f656d63fe 100644 --- a/pkg/render/applicationlayer/gateway_waf_test.go +++ b/pkg/enterprise/render/applicationlayer/gateway_waf_test.go @@ -21,7 +21,7 @@ import ( admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" - "github.com/tigera/operator/pkg/render/applicationlayer" + "github.com/tigera/operator/pkg/enterprise/render/applicationlayer" ) var fakeCABundle = []byte("fake-ca-bundle") diff --git a/pkg/render/applicationlayer/ruleset/coreruleset/tigera.conf b/pkg/enterprise/render/applicationlayer/ruleset/coreruleset/tigera.conf similarity index 100% rename from pkg/render/applicationlayer/ruleset/coreruleset/tigera.conf rename to pkg/enterprise/render/applicationlayer/ruleset/coreruleset/tigera.conf diff --git a/pkg/render/applicationlayer/ruleset/embed.go b/pkg/enterprise/render/applicationlayer/ruleset/embed.go similarity index 97% rename from pkg/render/applicationlayer/ruleset/embed.go rename to pkg/enterprise/render/applicationlayer/ruleset/embed.go index 0d4e3072d5..1bf01009ab 100644 --- a/pkg/render/applicationlayer/ruleset/embed.go +++ b/pkg/enterprise/render/applicationlayer/ruleset/embed.go @@ -21,7 +21,7 @@ import ( coreruleset "github.com/corazawaf/coraza-coreruleset/v4" "github.com/tigera/operator/pkg/common" - "github.com/tigera/operator/pkg/render/applicationlayer" + "github.com/tigera/operator/pkg/enterprise/render/applicationlayer" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/pkg/render/applicationlayer/ruleset/embed_test.go b/pkg/enterprise/render/applicationlayer/ruleset/embed_test.go similarity index 95% rename from pkg/render/applicationlayer/ruleset/embed_test.go rename to pkg/enterprise/render/applicationlayer/ruleset/embed_test.go index 8917ce5710..eb01c88d18 100644 --- a/pkg/render/applicationlayer/ruleset/embed_test.go +++ b/pkg/enterprise/render/applicationlayer/ruleset/embed_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2023-2024 Tigera, Inc. All rights reserved. +// Copyright (c) 2023-2026 Tigera, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/pkg/render/egressgateway/egressgateway.go b/pkg/enterprise/render/egressgateway/egressgateway.go similarity index 100% rename from pkg/render/egressgateway/egressgateway.go rename to pkg/enterprise/render/egressgateway/egressgateway.go diff --git a/pkg/render/egressgateway/egressgateway_suite_test.go b/pkg/enterprise/render/egressgateway/egressgateway_suite_test.go similarity index 93% rename from pkg/render/egressgateway/egressgateway_suite_test.go rename to pkg/enterprise/render/egressgateway/egressgateway_suite_test.go index 01c40835c8..936d19057d 100644 --- a/pkg/render/egressgateway/egressgateway_suite_test.go +++ b/pkg/enterprise/render/egressgateway/egressgateway_suite_test.go @@ -28,6 +28,6 @@ func TestRender(t *testing.T) { logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true), zap.Level(uzap.NewAtomicLevelAt(uzap.DebugLevel)))) gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/egressgateway_suite.xml" + reporterConfig.JUnitReport = "../../../../report/ut/egressgateway_suite.xml" ginkgo.RunSpecs(t, "pkg/egressgateway/egressgateway Suite", suiteConfig, reporterConfig) } diff --git a/pkg/render/egressgateway/egressgateway_test.go b/pkg/enterprise/render/egressgateway/egressgateway_test.go similarity index 99% rename from pkg/render/egressgateway/egressgateway_test.go rename to pkg/enterprise/render/egressgateway/egressgateway_test.go index a83877eb83..ab42d26222 100644 --- a/pkg/render/egressgateway/egressgateway_test.go +++ b/pkg/enterprise/render/egressgateway/egressgateway_test.go @@ -25,9 +25,9 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" operatorv1 "github.com/tigera/operator/api/v1" + "github.com/tigera/operator/pkg/enterprise/render/egressgateway" rmeta "github.com/tigera/operator/pkg/render/common/meta" rtest "github.com/tigera/operator/pkg/render/common/test" - "github.com/tigera/operator/pkg/render/egressgateway" ) var _ = Describe("Egress Gateway rendering tests", func() { diff --git a/pkg/render/intrusiondetection/dpi/dpi.go b/pkg/enterprise/render/intrusiondetection/dpi/dpi.go similarity index 100% rename from pkg/render/intrusiondetection/dpi/dpi.go rename to pkg/enterprise/render/intrusiondetection/dpi/dpi.go diff --git a/pkg/render/intrusiondetection/dpi/dpi_suite_test.go b/pkg/enterprise/render/intrusiondetection/dpi/dpi_suite_test.go similarity index 83% rename from pkg/render/intrusiondetection/dpi/dpi_suite_test.go rename to pkg/enterprise/render/intrusiondetection/dpi/dpi_suite_test.go index c7cd4ec214..a4538afefa 100644 --- a/pkg/render/intrusiondetection/dpi/dpi_suite_test.go +++ b/pkg/enterprise/render/intrusiondetection/dpi/dpi_suite_test.go @@ -24,6 +24,6 @@ import ( func TestRender(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../../report/ut/dpi_suite.xml" - ginkgo.RunSpecs(t, "pkg/intusiondetection/dpi Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../../report/ut/dpi_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/render/intrusiondetection/dpi Suite", suiteConfig, reporterConfig) } diff --git a/pkg/render/intrusiondetection/dpi/dpi_test.go b/pkg/enterprise/render/intrusiondetection/dpi/dpi_test.go similarity index 99% rename from pkg/render/intrusiondetection/dpi/dpi_test.go rename to pkg/enterprise/render/intrusiondetection/dpi/dpi_test.go index a5b20a9350..683a7f5887 100644 --- a/pkg/render/intrusiondetection/dpi/dpi_test.go +++ b/pkg/enterprise/render/intrusiondetection/dpi/dpi_test.go @@ -35,10 +35,10 @@ import ( "github.com/tigera/operator/pkg/controller/certificatemanager" ctrlrfake "github.com/tigera/operator/pkg/ctrlruntime/client/fake" "github.com/tigera/operator/pkg/dns" + "github.com/tigera/operator/pkg/enterprise/render/intrusiondetection/dpi" "github.com/tigera/operator/pkg/render" relasticsearch "github.com/tigera/operator/pkg/render/common/elasticsearch" rtest "github.com/tigera/operator/pkg/render/common/test" - "github.com/tigera/operator/pkg/render/intrusiondetection/dpi" "github.com/tigera/operator/pkg/render/testutils" "github.com/tigera/operator/pkg/tls/certificatemanagement" ) @@ -191,10 +191,10 @@ var _ = Describe("DPI rendering tests", func() { ) // Fetch expectations from utilities that require Ginkgo context. - expectedUnmanagedPolicy := testutils.GetExpectedPolicyFromFile("../../testutils/expected_policies/dpi_unmanaged.json") - expectedUnmanagedPolicyForOpenshift := testutils.GetExpectedPolicyFromFile("../../testutils/expected_policies/dpi_unmanaged_ocp.json") - expectedManagedPolicy := testutils.GetExpectedPolicyFromFile("../../testutils/expected_policies/dpi_managed.json") - expectedManagedPolicyForOpenshift := testutils.GetExpectedPolicyFromFile("../../testutils/expected_policies/dpi_managed_ocp.json") + expectedUnmanagedPolicy := testutils.GetExpectedPolicyFromFile("../../../../render/testutils/expected_policies/dpi_unmanaged.json") + expectedUnmanagedPolicyForOpenshift := testutils.GetExpectedPolicyFromFile("../../../../render/testutils/expected_policies/dpi_unmanaged_ocp.json") + expectedManagedPolicy := testutils.GetExpectedPolicyFromFile("../../../../render/testutils/expected_policies/dpi_managed.json") + expectedManagedPolicyForOpenshift := testutils.GetExpectedPolicyFromFile("../../../../render/testutils/expected_policies/dpi_managed_ocp.json") BeforeEach(func() { scheme := runtime.NewScheme() diff --git a/pkg/render/otelcollector/collector-config.yaml.template b/pkg/enterprise/render/otelcollector/collector-config.yaml.template similarity index 100% rename from pkg/render/otelcollector/collector-config.yaml.template rename to pkg/enterprise/render/otelcollector/collector-config.yaml.template diff --git a/pkg/render/otelcollector/component.go b/pkg/enterprise/render/otelcollector/component.go similarity index 100% rename from pkg/render/otelcollector/component.go rename to pkg/enterprise/render/otelcollector/component.go diff --git a/pkg/render/otelcollector/component_test.go b/pkg/enterprise/render/otelcollector/component_test.go similarity index 99% rename from pkg/render/otelcollector/component_test.go rename to pkg/enterprise/render/otelcollector/component_test.go index eabdd6f970..1c3cbfeed7 100644 --- a/pkg/render/otelcollector/component_test.go +++ b/pkg/enterprise/render/otelcollector/component_test.go @@ -34,12 +34,12 @@ import ( operatorv1 "github.com/tigera/operator/api/v1" "github.com/tigera/operator/pkg/common" + "github.com/tigera/operator/pkg/enterprise/render/otelcollector" "github.com/tigera/operator/pkg/render" rmeta "github.com/tigera/operator/pkg/render/common/meta" "github.com/tigera/operator/pkg/render/common/networkpolicy" "github.com/tigera/operator/pkg/render/common/securitycontext" rtest "github.com/tigera/operator/pkg/render/common/test" - "github.com/tigera/operator/pkg/render/otelcollector" "github.com/tigera/operator/pkg/tls/certificatemanagement" "github.com/tigera/operator/pkg/tls/certkeyusage" ) diff --git a/pkg/render/otelcollector/suite_test.go b/pkg/enterprise/render/otelcollector/suite_test.go similarity index 82% rename from pkg/render/otelcollector/suite_test.go rename to pkg/enterprise/render/otelcollector/suite_test.go index f2768136b1..82ba13fa6b 100644 --- a/pkg/render/otelcollector/suite_test.go +++ b/pkg/enterprise/render/otelcollector/suite_test.go @@ -24,6 +24,6 @@ import ( func TestRender(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() - reporterConfig.JUnitReport = "../../../report/ut/otelcollector_render_suite.xml" - ginkgo.RunSpecs(t, "pkg/render/otelcollector Suite", suiteConfig, reporterConfig) + reporterConfig.JUnitReport = "../../../../report/ut/otelcollector_render_suite.xml" + ginkgo.RunSpecs(t, "pkg/enterprise/render/otelcollector Suite", suiteConfig, reporterConfig) } diff --git a/pkg/enterprise/startup.go b/pkg/enterprise/startup.go index f8404f8492..692e767213 100644 --- a/pkg/enterprise/startup.go +++ b/pkg/enterprise/startup.go @@ -25,8 +25,8 @@ import ( operatorv1 "github.com/tigera/operator/api/v1" "github.com/tigera/operator/pkg/common/discovery" eoptions "github.com/tigera/operator/pkg/enterprise/options" + "github.com/tigera/operator/pkg/enterprise/render/intrusiondetection/dpi" "github.com/tigera/operator/pkg/render" - "github.com/tigera/operator/pkg/render/intrusiondetection/dpi" "github.com/tigera/operator/pkg/render/istio" "github.com/tigera/operator/pkg/render/logstorage" "github.com/tigera/operator/pkg/render/logstorage/eck" diff --git a/pkg/render/otelcollector.go b/pkg/render/otelcollector.go index 972651ce6d..40d03d2034 100644 --- a/pkg/render/otelcollector.go +++ b/pkg/render/otelcollector.go @@ -14,11 +14,9 @@ package render -// Identity of the OpenTelemetry Collector workload. These live here rather than -// in pkg/render/otelcollector because that package imports pkg/render/monitor -// (for the Prometheus federation target), so the monitor render cannot import it -// back to build the collector's ServiceMonitor. Same arrangement as the -// fluent-bit constants in logcollector.go. +// Identity of the OpenTelemetry Collector workload. They live here because +// pkg/render/monitor builds the collector's ServiceMonitor and cannot import the +// package that renders the collector. const ( OpenTelemetryCollectorName = "otel-collector" OpenTelemetryCollectorNamespace = "calico-system" diff --git a/test/mainline_test.go b/test/mainline_test.go index 5615847902..4b78aca90b 100644 --- a/test/mainline_test.go +++ b/test/mainline_test.go @@ -340,6 +340,7 @@ func setupManager(manageCRDs bool, multiTenant bool, variant operator.ProductVar DetectedProvider: operator.ProviderNone, Variant: variant, Extensions: enterprise.New(variant, eoptions.Options{}), + Controllers: enterprise.Controllers(variant), ManageCRDs: manageCRDs, ShutdownContext: ctx, K8sClientset: clientset,