Skip to content

Commit

Permalink
Adjust to changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vrutkovs committed Nov 25, 2024
1 parent e811801 commit 5eb43be
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 16 deletions.
3 changes: 2 additions & 1 deletion pkg/cmd/operator/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/controllers/configobservation/oauth/observe_idps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pkg/controllers/routercerts/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/replacement_starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -187,7 +187,7 @@ func CreateControllerInputFromControllerContext(ctx context.Context, controllerC
Namespace: "openshift-authentication-operator",
Name: "authentication-operator",
},
)
clock.RealClock{})

return &authenticationOperatorInput{
kubeClient: kubeClient,
Expand Down
3 changes: 2 additions & 1 deletion pkg/operator/workload/sync_openshift_oauth_apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()...)
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 5eb43be

Please sign in to comment.