@@ -7,6 +7,10 @@ import (
77 "sync"
88 "time"
99
10+ . "github.com/onsi/ginkgo/v2"
11+ . "github.com/onsi/gomega"
12+
13+ "go.uber.org/mock/gomock"
1014 admv1 "k8s.io/api/admissionregistration/v1"
1115 appsv1 "k8s.io/api/apps/v1"
1216 corev1 "k8s.io/api/core/v1"
@@ -15,24 +19,18 @@ import (
1519 "k8s.io/apimachinery/pkg/api/errors"
1620 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1721 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
22+ uns "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1823 "k8s.io/apimachinery/pkg/runtime/schema"
1924 "k8s.io/apimachinery/pkg/types"
2025 "k8s.io/apimachinery/pkg/util/wait"
2126 "sigs.k8s.io/controller-runtime/pkg/client"
2227
23- . "github.com/onsi/ginkgo/v2"
24- . "github.com/onsi/gomega"
25- "go.uber.org/mock/gomock"
26-
2728 sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
2829 "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts"
2930 "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/featuregate"
30- mock_platforms "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/platforms/mock"
31- "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/platforms/openshift"
31+ orchestratorMock "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/orchestrator/mock"
3232 "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
3333 "github.com/k8snetworkplumbingwg/sriov-network-operator/test/util"
34-
35- uns "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3634)
3735
3836var _ = Describe ("SriovOperatorConfig controller" , Ordered , func () {
@@ -62,15 +60,27 @@ var _ = Describe("SriovOperatorConfig controller", Ordered, func() {
6260
6361 t := GinkgoT ()
6462 mockCtrl := gomock .NewController (t )
65- platformHelper := mock_platforms .NewMockInterface (mockCtrl )
66- platformHelper .EXPECT ().GetFlavor ().Return (openshift .OpenshiftFlavorDefault ).AnyTimes ()
67- platformHelper .EXPECT ().IsOpenshiftCluster ().Return (false ).AnyTimes ()
68- platformHelper .EXPECT ().IsHypershift ().Return (false ).AnyTimes ()
63+ orchestrator := orchestratorMock .NewMockInterface (mockCtrl )
64+
65+ orchestrator .EXPECT ().ClusterType ().DoAndReturn (func () consts.ClusterType {
66+ if vars .ClusterType == consts .ClusterTypeOpenshift {
67+ return consts .ClusterTypeOpenshift
68+ }
69+ return consts .ClusterTypeKubernetes
70+ }).AnyTimes ()
71+
72+ // TODO: Change this to add tests for hypershift
73+ orchestrator .EXPECT ().Flavor ().DoAndReturn (func () consts.ClusterFlavor {
74+ if vars .ClusterType == consts .ClusterTypeOpenshift {
75+ return consts .DefaultConfigName
76+ }
77+ return consts .ClusterFlavorVanillaK8s
78+ }).AnyTimes ()
6979
7080 err = (& SriovOperatorConfigReconciler {
7181 Client : k8sManager .GetClient (),
7282 Scheme : k8sManager .GetScheme (),
73- PlatformHelper : platformHelper ,
83+ Orchestrator : orchestrator ,
7484 FeatureGate : featuregate .New (),
7585 UncachedAPIReader : k8sManager .GetAPIReader (),
7686 }).SetupWithManager (k8sManager )
@@ -597,7 +607,7 @@ var _ = Describe("SriovOperatorConfig controller", Ordered, func() {
597607 // echo "ca-bundle-2" | base64 -w 0
598608 os .Setenv ("ADMISSION_CONTROLLERS_CERTIFICATES_INJECTOR_CA_CRT" , "Y2EtYnVuZGxlLTIK" )
599609
600- DeferCleanup (func (old string ) { vars .ClusterType = old }, vars .ClusterType )
610+ DeferCleanup (func (old consts. ClusterType ) { vars .ClusterType = old }, vars .ClusterType )
601611 vars .ClusterType = consts .ClusterTypeKubernetes
602612
603613 err := util .TriggerSriovOperatorConfigReconcile (k8sClient , testNamespace )
0 commit comments