diff --git a/pkg/cmd/operator/cmd.go b/pkg/cmd/operator/cmd.go index b3158dfd8..b8c2d8e41 100644 --- a/pkg/cmd/operator/cmd.go +++ b/pkg/cmd/operator/cmd.go @@ -2,6 +2,7 @@ package operator import ( "github.com/spf13/cobra" + "k8s.io/utils/clock" "github.com/openshift/cluster-authentication-operator/pkg/operator" "github.com/openshift/cluster-authentication-operator/pkg/version" @@ -11,7 +12,7 @@ import ( const componentName = "cluster-authentication-operator" func NewOperator() *cobra.Command { - cmd := controllercmd.NewControllerCommandConfig(componentName, version.Get(), operator.RunOperator).NewCommand() + cmd := controllercmd.NewControllerCommandConfig(componentName, version.Get(), operator.RunOperator, clock.RealClock{}).NewCommand() cmd.Use = "operator" cmd.Short = "Start the Authentication Operator" return cmd diff --git a/pkg/controllers/configobservation/console/observe_consoleurl_test.go b/pkg/controllers/configobservation/console/observe_consoleurl_test.go index 083788b0c..6e23f8e38 100644 --- a/pkg/controllers/configobservation/console/observe_consoleurl_test.go +++ b/pkg/controllers/configobservation/console/observe_consoleurl_test.go @@ -7,6 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" @@ -111,7 +112,7 @@ func TestObserveConsoleURL(t *testing.T) { ClusterVersionLister: configlistersv1.NewClusterVersionLister(clusterVersionIndexer), } - eventRecorder := events.NewInMemoryRecorder(tt.name) + eventRecorder := events.NewInMemoryRecorder(tt.name, clock.RealClock{}) gotConfig, errs := ObserveConsoleURL(listers, eventRecorder, tt.existingConfig) if !reflect.DeepEqual(gotConfig, tt.expectedConfig) { t.Errorf("ObserveConsoleURL() gotConfig = %v, want %v", gotConfig, tt.expectedConfig) diff --git a/pkg/controllers/configobservation/infrastructure/observe_apiserverurl_test.go b/pkg/controllers/configobservation/infrastructure/observe_apiserverurl_test.go index c0d7d166e..25433a8ba 100644 --- a/pkg/controllers/configobservation/infrastructure/observe_apiserverurl_test.go +++ b/pkg/controllers/configobservation/infrastructure/observe_apiserverurl_test.go @@ -7,6 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" @@ -73,7 +74,7 @@ func TestObserveAPIServerURL(t *testing.T) { InfrastructureLister: configlistersv1.NewInfrastructureLister(indexer), } - eventRecorder := events.NewInMemoryRecorder(tt.name) + eventRecorder := events.NewInMemoryRecorder(tt.name, clock.RealClock{}) gotConfig, errs := ObserveAPIServerURL(listers, eventRecorder, tt.existingConfig) if !reflect.DeepEqual(gotConfig, tt.expectedConfig) { t.Errorf("ObserveAPIServerURL() gotConfig = %v, want %v", gotConfig, tt.expectedConfig) diff --git a/pkg/controllers/configobservation/oauth/observe_audit_test.go b/pkg/controllers/configobservation/oauth/observe_audit_test.go index c00d5d70b..1e59dc889 100644 --- a/pkg/controllers/configobservation/oauth/observe_audit_test.go +++ b/pkg/controllers/configobservation/oauth/observe_audit_test.go @@ -8,6 +8,7 @@ import ( "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" @@ -120,7 +121,7 @@ func TestAuditProfile(t *testing.T) { APIServerLister_: configlistersv1.NewAPIServerLister(indexer), } - have, errs := oauth.ObserveAudit(listers, events.NewInMemoryRecorder(t.Name()), tt.previouslyObservedConfig) + have, errs := oauth.ObserveAudit(listers, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tt.previouslyObservedConfig) if len(errs) > 0 { t.Errorf("Expected 0 errors, have %v.", len(errs)) } diff --git a/pkg/controllers/configobservation/oauth/observe_idps_test.go b/pkg/controllers/configobservation/oauth/observe_idps_test.go index 95b163385..d142bcfb0 100644 --- a/pkg/controllers/configobservation/oauth/observe_idps_test.go +++ b/pkg/controllers/configobservation/oauth/observe_idps_test.go @@ -11,6 +11,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" corelistersv1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" @@ -199,7 +200,7 @@ func TestObserveIdentityProviders(t *testing.T) { OAuthLister_: configlistersv1.NewOAuthLister(indexer), ResourceSync: &mockResourceSyncer{t: t, synced: syncerData}, } - eventsRecorder := events.NewInMemoryRecorder(t.Name()) + eventsRecorder := events.NewInMemoryRecorder(t.Name(), clock.RealClock{}) got, errs := ObserveIdentityProviders(listers, eventsRecorder, tt.previouslyObservedConfig) diff --git a/pkg/controllers/configobservation/oauth/observe_templates_test.go b/pkg/controllers/configobservation/oauth/observe_templates_test.go index 1bf15911d..f14117c76 100644 --- a/pkg/controllers/configobservation/oauth/observe_templates_test.go +++ b/pkg/controllers/configobservation/oauth/observe_templates_test.go @@ -9,6 +9,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" corelistersv1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" @@ -88,7 +89,7 @@ func TestObserveTemplates(t *testing.T) { ConfigMapLister: corelistersv1.NewConfigMapLister(indexer), ResourceSync: &mockResourceSyncer{t: t, synced: syncerData}, } - got, errs := ObserveTemplates(listers, events.NewInMemoryRecorder(t.Name()), tt.previouslyObservedConfig) + got, errs := ObserveTemplates(listers, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tt.previouslyObservedConfig) if len(errs) > 0 { t.Errorf("Expected 0 errors, got %v.", len(errs)) } diff --git a/pkg/controllers/configobservation/oauth/observe_tokenconfig_test.go b/pkg/controllers/configobservation/oauth/observe_tokenconfig_test.go index f4a1edc01..812caba47 100644 --- a/pkg/controllers/configobservation/oauth/observe_tokenconfig_test.go +++ b/pkg/controllers/configobservation/oauth/observe_tokenconfig_test.go @@ -8,6 +8,7 @@ import ( "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" @@ -119,7 +120,7 @@ func TestObserveTokenConfig(t *testing.T) { listers := configobservation.Listers{ OAuthLister_: configlistersv1.NewOAuthLister(indexer), } - got, errs := ObserveTokenConfig(listers, events.NewInMemoryRecorder(t.Name()), tt.previouslyObservedConfig) + got, errs := ObserveTokenConfig(listers, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tt.previouslyObservedConfig) if len(errs) > 0 { t.Errorf("Expected 0 errors, got %v.", len(errs)) } diff --git a/pkg/controllers/configobservation/routersecret/observe_router_secret_test.go b/pkg/controllers/configobservation/routersecret/observe_router_secret_test.go index 1c24e8db0..5a67dc8ec 100644 --- a/pkg/controllers/configobservation/routersecret/observe_router_secret_test.go +++ b/pkg/controllers/configobservation/routersecret/observe_router_secret_test.go @@ -10,6 +10,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" corev1listers "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" @@ -180,7 +181,7 @@ func TestObserveRouterSecret(t *testing.T) { IngressLister: configlistersv1.NewIngressLister(indexer), } - eventRecorder := events.NewInMemoryRecorder(tt.name) + eventRecorder := events.NewInMemoryRecorder(tt.name, clock.RealClock{}) gotConfig, errs := ObserveRouterSecret(listers, eventRecorder, tt.existingConfig) if !reflect.DeepEqual(gotConfig, tt.expectedConfig) { t.Errorf("ObserveRouterSecret() gotConfig = %v, want %v", gotConfig, tt.expectedConfig) diff --git a/pkg/controllers/routercerts/controller_test.go b/pkg/controllers/routercerts/controller_test.go index 54aeb4abe..75c9ac9c1 100644 --- a/pkg/controllers/routercerts/controller_test.go +++ b/pkg/controllers/routercerts/controller_test.go @@ -22,6 +22,7 @@ import ( "k8s.io/client-go/kubernetes/fake" corev1listers "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" operatorv1 "github.com/openshift/api/operator/v1" @@ -249,7 +250,7 @@ func TestValidateRouterCertificates(t *testing.T) { systemCertPool: tc.systemCertPool, secretsClient: secretsClient.CoreV1(), } - err = controller.sync(context.TODO(), factory.NewSyncContext("testctx", events.NewInMemoryRecorder("test-recorder"))) + err = controller.sync(context.TODO(), factory.NewSyncContext("testctx", events.NewInMemoryRecorder("test-recorder", clock.RealClock{}))) require.NoError(t, err) _, s, _, _ := operatorClient.GetOperatorState() require.Len(t, s.Conditions, 1) diff --git a/pkg/libs/endpointaccessible/endpoint_accessible_controller_test.go b/pkg/libs/endpointaccessible/endpoint_accessible_controller_test.go index 342e2ee15..1bf04496b 100644 --- a/pkg/libs/endpointaccessible/endpoint_accessible_controller_test.go +++ b/pkg/libs/endpointaccessible/endpoint_accessible_controller_test.go @@ -5,6 +5,8 @@ import ( "fmt" "testing" + "k8s.io/utils/clock" + operatorv1 "github.com/openshift/api/operator/v1" "github.com/openshift/library-go/pkg/operator/v1helpers" @@ -52,7 +54,7 @@ func Test_endpointAccessibleController_sync(t *testing.T) { operatorClient: v1helpers.NewFakeOperatorClient(&operatorv1.OperatorSpec{}, &operatorv1.OperatorStatus{}, nil), endpointListFn: tt.endpointListFn, } - if err := c.sync(context.Background(), factory.NewSyncContext(tt.name, events.NewInMemoryRecorder(tt.name))); (err != nil) != tt.wantErr { + if err := c.sync(context.Background(), factory.NewSyncContext(tt.name, events.NewInMemoryRecorder(tt.name, clock.RealClock{}))); (err != nil) != tt.wantErr { t.Errorf("sync() error = %v, wantErr %v", err, tt.wantErr) } }) diff --git a/pkg/operator/configobservation/authentication/apiaudiences_test.go b/pkg/operator/configobservation/authentication/apiaudiences_test.go index a435aa7db..03dd2d34f 100644 --- a/pkg/operator/configobservation/authentication/apiaudiences_test.go +++ b/pkg/operator/configobservation/authentication/apiaudiences_test.go @@ -7,6 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" @@ -82,7 +83,7 @@ func TestObservedConfig(t *testing.T) { require.NoError(t, err) } - testRecorder := events.NewInMemoryRecorder("APIAudiencesTest") + testRecorder := events.NewInMemoryRecorder("APIAudiencesTest", clock.RealClock{}) listers := configobservation.Listers{ AuthConfigLister_: configlistersv1.NewAuthenticationLister(indexer), } diff --git a/pkg/operator/configobservation/oauth/inactivity_timeout_test.go b/pkg/operator/configobservation/oauth/inactivity_timeout_test.go index 7fe3a977c..6c72c59d0 100644 --- a/pkg/operator/configobservation/oauth/inactivity_timeout_test.go +++ b/pkg/operator/configobservation/oauth/inactivity_timeout_test.go @@ -10,6 +10,7 @@ import ( "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" + "k8s.io/utils/clock" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" @@ -181,7 +182,7 @@ func TestObserveAccessTokenInactivityTimeout(t *testing.T) { lister := testLister{lister: configlistersv1.NewOAuthLister(indexer)} - got, errs := ObserveAccessTokenInactivityTimeout(lister, events.NewInMemoryRecorder(t.Name()), tt.previouslyObservedConfig) + got, errs := ObserveAccessTokenInactivityTimeout(lister, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tt.previouslyObservedConfig) if len(errs) != len(tt.errors) { t.Errorf("Expected %d errors, got %d.", len(tt.errors), errs) } @@ -197,7 +198,7 @@ func TestObserveAccessTokenInactivityTimeout(t *testing.T) { }, } - got, errs := ObserveAccessTokenInactivityTimeout(invalidLister{}, events.NewInMemoryRecorder("fakeRecorder"), existingConfig) + got, errs := ObserveAccessTokenInactivityTimeout(invalidLister{}, events.NewInMemoryRecorder("fakeRecorder", clock.RealClock{}), existingConfig) // There must be only one kind of error asserting the lister type. if len(errs) != 1 { diff --git a/pkg/operator/replacement_starter.go b/pkg/operator/replacement_starter.go index b516c53c1..e1d782820 100644 --- a/pkg/operator/replacement_starter.go +++ b/pkg/operator/replacement_starter.go @@ -118,7 +118,7 @@ func CreateOperatorInputFromMOM(ctx context.Context, momInput libraryapplyconfig Kind: "Deployment", Namespace: "openshift-authentication-operator", Name: "authentication-operator", - }) + }, clock.RealClock{}) return &authenticationOperatorInput{ kubeClient: kubeClient, @@ -187,7 +187,7 @@ func CreateControllerInputFromControllerContext(ctx context.Context, controllerC Namespace: "openshift-authentication-operator", Name: "authentication-operator", }, - ) + clock.RealClock{}) return &authenticationOperatorInput{ kubeClient: kubeClient, diff --git a/pkg/operator/workload/sync_openshift_oauth_apiserver_test.go b/pkg/operator/workload/sync_openshift_oauth_apiserver_test.go index 8c9082f59..aeb92a0e7 100644 --- a/pkg/operator/workload/sync_openshift_oauth_apiserver_test.go +++ b/pkg/operator/workload/sync_openshift_oauth_apiserver_test.go @@ -19,6 +19,7 @@ import ( "k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/kubernetes/scheme" clientgotesting "k8s.io/client-go/testing" + "k8s.io/utils/clock" ) var codec = scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...) @@ -136,7 +137,7 @@ func TestSyncOAuthAPIServerDeployment(t *testing.T) { for _, scenario := range scenarios { t.Run(scenario.name, func(t *testing.T) { - eventRecorder := events.NewInMemoryRecorder("") + eventRecorder := events.NewInMemoryRecorder("", clock.RealClock{}) fakeKubeClient := fake.NewSimpleClientset() target := &OAuthAPIServerWorkload{