Skip to content

Commit

Permalink
Merge pull request openshift#22492 from deads2k/client-signature
Browse files Browse the repository at this point in the history
switch to non-deprecated client
  • Loading branch information
deads2k authored Apr 7, 2019
2 parents d216153 + 1f707e3 commit 2899b45
Show file tree
Hide file tree
Showing 177 changed files with 545 additions and 544 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestAuthenticateTokenExpired(t *testing.T) {
)
fakeUserClient := userfake.NewSimpleClientset(&userapi.User{ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "bar"}})

tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.Oauth().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{}, NewExpirationValidator())
tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.OauthV1().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{}, NewExpirationValidator())

for _, tokenName := range []string{"token1", "token2"} {
userInfo, found, err := tokenAuthenticator.AuthenticateToken(context.TODO(), tokenName)
Expand All @@ -57,7 +57,7 @@ func TestAuthenticateTokenValidated(t *testing.T) {
)
fakeUserClient := userfake.NewSimpleClientset(&userapi.User{ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "bar"}})

tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.Oauth().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{}, NewExpirationValidator(), NewUIDValidator())
tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.OauthV1().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{}, NewExpirationValidator(), NewUIDValidator())

userInfo, found, err := tokenAuthenticator.AuthenticateToken(context.TODO(), "token")
if !found {
Expand Down
10 changes: 5 additions & 5 deletions pkg/apiserver/authentication/oauth/tokenauthenticator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestAuthenticateTokenInvalidUID(t *testing.T) {
)
fakeUserClient := userfake.NewSimpleClientset(&userapi.User{ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "bar2"}})

tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.Oauth().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{}, NewUIDValidator())
tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.OauthV1().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{}, NewUIDValidator())

userInfo, found, err := tokenAuthenticator.AuthenticateToken(context.TODO(), "token")
if found {
Expand All @@ -48,7 +48,7 @@ func TestAuthenticateTokenInvalidUID(t *testing.T) {
func TestAuthenticateTokenNotFoundSuppressed(t *testing.T) {
fakeOAuthClient := oauthfake.NewSimpleClientset()
fakeUserClient := userfake.NewSimpleClientset()
tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.Oauth().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{})
tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.OauthV1().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{})

userInfo, found, err := tokenAuthenticator.AuthenticateToken(context.TODO(), "token")
if found {
Expand All @@ -68,7 +68,7 @@ func TestAuthenticateTokenOtherGetErrorSuppressed(t *testing.T) {
return true, nil, errors.New("get error")
})
fakeUserClient := userfake.NewSimpleClientset()
tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.Oauth().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{})
tokenAuthenticator := NewTokenAuthenticator(fakeOAuthClient.OauthV1().OAuthAccessTokens(), fakeUserClient.UserV1().Users(), NoopGroupMapper{})

userInfo, found, err := tokenAuthenticator.AuthenticateToken(context.TODO(), "token")
if found {
Expand Down Expand Up @@ -137,8 +137,8 @@ func TestAuthenticateTokenTimeout(t *testing.T) {
}
fakeOAuthClient := oauthfake.NewSimpleClientset(&testToken, &quickToken, &slowToken, &emergToken, &testClient, &quickClient, &slowClient)
fakeUserClient := userfake.NewSimpleClientset(&userapi.User{ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "bar"}})
accessTokenGetter := fakeOAuthClient.Oauth().OAuthAccessTokens()
oauthClients := fakeOAuthClient.Oauth().OAuthClients()
accessTokenGetter := fakeOAuthClient.OauthV1().OAuthAccessTokens()
oauthClients := fakeOAuthClient.OauthV1().OAuthClients()
lister := &fakeOAuthClientLister{
clients: oauthClients,
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/apps/apiserver/registry/deploylog/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func mockREST(version, desired int64, status appsv1.DeploymentStatus) *REST {
// Used for testing validation errors prior to getting replication controllers.
if desired > version {
return &REST{
dcClient: fakeDn.Apps(),
dcClient: fakeDn.AppsV1(),
timeout: defaultTimeout,
}
}
Expand Down Expand Up @@ -151,9 +151,9 @@ func mockREST(version, desired int64, status appsv1.DeploymentStatus) *REST {
}

return &REST{
dcClient: fakeDn.Apps(),
rcClient: fakeRn.Core(),
podClient: fakePn.Core(),
dcClient: fakeDn.AppsV1(),
rcClient: fakeRn.CoreV1(),
podClient: fakePn.CoreV1(),
timeout: defaultTimeout,
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apps/apiserver/registry/deploylog/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestWaitForRunningDeploymentSuccess(t *testing.T) {

go func() {
defer close(stopChan)
rc, ok, err := WaitForRunningDeployment(kubeclient.Core(), fakeController, 10*time.Second)
rc, ok, err := WaitForRunningDeployment(kubeclient.CoreV1(), fakeController, 10*time.Second)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestWaitForRunningDeploymentRestartWatch(t *testing.T) {
stopChan := make(chan struct{})
go func() {
defer close(stopChan)
rc, ok, err := WaitForRunningDeployment(kubeclient.Core(), fakeController, 10*time.Second)
rc, ok, err := WaitForRunningDeployment(kubeclient.CoreV1(), fakeController, 10*time.Second)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apps/apiserver/registry/instantiate/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
// NewREST provides new REST storage for the apps API group.
func NewREST(store registry.Store, imagesclient imageclientinternal.Interface, kc kubernetes.Interface, admission admission.Interface) *REST {
store.UpdateStrategy = Strategy
return &REST{store: &store, is: imagesclient.Image(), rn: kc.Core(), admit: admission}
return &REST{store: &store, is: imagesclient.Image(), rn: kc.CoreV1(), admit: admission}
}

// REST implements the Creater interface.
Expand Down
2 changes: 1 addition & 1 deletion pkg/apps/apiserver/registry/instantiate/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func TestCanTrigger(t *testing.T) {

test.config = appstest.RoundTripConfig(t, test.config)

got, gotCauses, err := canTrigger(test.config, client.Core(), test.force)
got, gotCauses, err := canTrigger(test.config, client.CoreV1(), test.force)
if err != nil && !test.expectedErr {
t.Errorf("unexpected error: %v", err)
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/apps/apiserver/registry/rollback/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewREST(appsclient appsclient.Interface, kc kubernetes.Interface) *REST {
return &REST{
generator: NewRollbackGenerator(),
dn: appsclient.AppsV1(),
rn: kc.Core(),
rn: kc.CoreV1(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/apps/apiserver/registry/rollback/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ func TestCreateGeneratorError(t *testing.T) {

rest := REST{
generator: &terribleGenerator{},
dn: oc.Apps(),
rn: kc.Core(),
dn: oc.AppsV1(),
rn: kc.CoreV1(),
}

_, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ func TestHandleScenarios(t *testing.T) {
informer: cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return oc.Apps().DeploymentConfigs(metav1.NamespaceAll).List(options)
return oc.AppsV1().DeploymentConfigs(metav1.NamespaceAll).List(options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return oc.Apps().DeploymentConfigs(metav1.NamespaceAll).Watch(options)
return oc.AppsV1().DeploymentConfigs(metav1.NamespaceAll).Watch(options)
},
},
&appsv1.DeploymentConfig{},
Expand Down
18 changes: 9 additions & 9 deletions pkg/apps/strategy/recreate/recreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type fakeControllerClient struct {
}

func (c *fakeControllerClient) ReplicationControllers(ns string) kcoreclient.ReplicationControllerInterface {
return c.fakeClient.Core().ReplicationControllers(ns)
return c.fakeClient.CoreV1().ReplicationControllers(ns)
}

func (c *fakeControllerClient) scaledOnce() bool {
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestRecreate_initialDeployment(t *testing.T) {
out: &bytes.Buffer{},
errOut: &bytes.Buffer{},
getUpdateAcceptor: getUpdateAcceptor,
eventClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().CoreV1(),
}

config := appstest.OkDeploymentConfig(1)
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestRecreate_deploymentPreHookSuccess(t *testing.T) {
out: &bytes.Buffer{},
errOut: &bytes.Buffer{},
getUpdateAcceptor: getUpdateAcceptor,
eventClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().CoreV1(),
rcClient: controllerClient,
scaleClient: controllerClient.fakeScaleClient(),
hookExecutor: &hookExecutorImpl{
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestRecreate_deploymentPreHookFail(t *testing.T) {
out: &bytes.Buffer{},
errOut: &bytes.Buffer{},
getUpdateAcceptor: getUpdateAcceptor,
eventClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().CoreV1(),
rcClient: controllerClient,
scaleClient: controllerClient.fakeScaleClient(),
hookExecutor: &hookExecutorImpl{
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestRecreate_deploymentMidHookSuccess(t *testing.T) {
errOut: &bytes.Buffer{},
rcClient: controllerClient,
scaleClient: controllerClient.fakeScaleClient(),
eventClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().CoreV1(),
getUpdateAcceptor: getUpdateAcceptor,
hookExecutor: &hookExecutorImpl{
executeFunc: func(hook *appsv1.LifecycleHook, deployment *corev1.ReplicationController, suffix, label string) error {
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestRecreate_deploymentPostHookSuccess(t *testing.T) {
errOut: &bytes.Buffer{},
rcClient: controllerClient,
scaleClient: controllerClient.fakeScaleClient(),
eventClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().CoreV1(),
getUpdateAcceptor: getUpdateAcceptor,
hookExecutor: &hookExecutorImpl{
executeFunc: func(hook *appsv1.LifecycleHook, deployment *corev1.ReplicationController, suffix, label string) error {
Expand Down Expand Up @@ -292,7 +292,7 @@ func TestRecreate_deploymentPostHookFail(t *testing.T) {
errOut: &bytes.Buffer{},
rcClient: controllerClient,
scaleClient: controllerClient.fakeScaleClient(),
eventClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().CoreV1(),
getUpdateAcceptor: getUpdateAcceptor,
hookExecutor: &hookExecutorImpl{
executeFunc: func(hook *appsv1.LifecycleHook, deployment *corev1.ReplicationController, suffix, label string) error {
Expand Down Expand Up @@ -361,7 +361,7 @@ func TestRecreate_acceptorSuccessWithColdCaches(t *testing.T) {
strategy := &RecreateDeploymentStrategy{
out: &bytes.Buffer{},
errOut: &bytes.Buffer{},
eventClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().CoreV1(),
}

acceptorCalled := false
Expand Down Expand Up @@ -406,7 +406,7 @@ func TestRecreate_acceptorFail(t *testing.T) {
strategy := &RecreateDeploymentStrategy{
out: &bytes.Buffer{},
errOut: &bytes.Buffer{},
eventClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().CoreV1(),
}

acceptor := &testAcceptor{
Expand Down
16 changes: 8 additions & 8 deletions pkg/apps/strategy/rolling/rolling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TestRolling_deployInitial(t *testing.T) {
initialStrategyInvoked := false

strategy := &RollingDeploymentStrategy{
rcClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().Core(),
rcClient: fake.NewSimpleClientset().CoreV1(),
eventClient: fake.NewSimpleClientset().CoreV1(),
initialStrategy: &testStrategy{
deployFn: func(from *corev1.ReplicationController, to *corev1.ReplicationController, desiredReplicas int, updateAcceptor strat.UpdateAcceptor) error {
initialStrategyInvoked = true
Expand Down Expand Up @@ -80,8 +80,8 @@ func TestRolling_deployRolling(t *testing.T) {

var rollingConfig *RollingUpdaterConfig
strategy := &RollingDeploymentStrategy{
rcClient: client.Core(),
eventClient: fake.NewSimpleClientset().Core(),
rcClient: client.CoreV1(),
eventClient: fake.NewSimpleClientset().CoreV1(),
initialStrategy: &testStrategy{
deployFn: func(from *corev1.ReplicationController, to *corev1.ReplicationController, desiredReplicas int, updateAcceptor strat.UpdateAcceptor) error {
t.Fatalf("unexpected call to initial strategy")
Expand Down Expand Up @@ -169,8 +169,8 @@ func TestRolling_deployRollingHooks(t *testing.T) {
})

strategy := &RollingDeploymentStrategy{
rcClient: client.Core(),
eventClient: fake.NewSimpleClientset().Core(),
rcClient: client.CoreV1(),
eventClient: fake.NewSimpleClientset().CoreV1(),
initialStrategy: &testStrategy{
deployFn: func(from *corev1.ReplicationController, to *corev1.ReplicationController, desiredReplicas int, updateAcceptor strat.UpdateAcceptor) error {
t.Fatalf("unexpected call to initial strategy")
Expand Down Expand Up @@ -230,8 +230,8 @@ func TestRolling_deployInitialHooks(t *testing.T) {
var hookError error

strategy := &RollingDeploymentStrategy{
rcClient: fake.NewSimpleClientset().Core(),
eventClient: fake.NewSimpleClientset().Core(),
rcClient: fake.NewSimpleClientset().CoreV1(),
eventClient: fake.NewSimpleClientset().CoreV1(),
initialStrategy: &testStrategy{
deployFn: func(from *corev1.ReplicationController, to *corev1.ReplicationController, desiredReplicas int,
updateAcceptor strat.UpdateAcceptor) error {
Expand Down
6 changes: 3 additions & 3 deletions pkg/apps/strategy/support/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestHookExecutor_executeExecNewCreatePodFailure(t *testing.T) {
return true, nil, errors.New("could not create the pod")
})
executor := &hookExecutor{
pods: client.Core(),
pods: client.CoreV1(),
}

if err := executor.executeExecNewPod(hook, deployment, "hook", "test"); err == nil {
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestHookExecutor_executeExecNewPodSucceeded(t *testing.T) {
}()

executor := &hookExecutor{
pods: client.Core(),
pods: client.CoreV1(),
out: podLogs,
getPodLogs: func(*corev1.Pod) (io.ReadCloser, error) {
return ioutil.NopCloser(strings.NewReader("test")), nil
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestHookExecutor_executeExecNewPodFailed(t *testing.T) {
}()

executor := &hookExecutor{
pods: client.Core(),
pods: client.CoreV1(),
out: ioutil.Discard,
getPodLogs: func(*corev1.Pod) (io.ReadCloser, error) {
return ioutil.NopCloser(strings.NewReader("test")), nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (q *restrictUsersAdmission) Validate(a admission.Attributes) (err error) {
}

roleBindingRestrictionContext, err := newRoleBindingRestrictionContext(ns,
q.kubeClient, q.userClient.User(), q.groupCache)
q.kubeClient, q.userClient.UserV1(), q.groupCache)
if err != nil {
return admission.NewForbidden(a, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func TestSubjectCheckers(t *testing.T) {
}

ctx, err := newRoleBindingRestrictionContext("namespace",
kclient, fakeUserClient.User(), groupCache)
kclient, fakeUserClient.UserV1(), groupCache)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/build/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ func (c *completedConfig) newV1RESTStorage() (map[string]rest.Storage, error) {
Client: buildgenerator.Client{
Builds: buildClient.BuildV1(),
BuildConfigs: buildClient.BuildV1(),
ImageStreams: imageClient.Image(),
ImageStreamImages: imageClient.Image(),
ImageStreamTags: imageClient.Image(),
ImageStreams: imageClient.ImageV1(),
ImageStreamImages: imageClient.ImageV1(),
ImageStreamTags: imageClient.ImageV1(),
},
ServiceAccounts: kubeClient.CoreV1(),
Secrets: kubeClient.CoreV1(),
Expand Down
Loading

0 comments on commit 2899b45

Please sign in to comment.