Skip to content

Commit

Permalink
Merge pull request #42 from marun/bump-1.18.2
Browse files Browse the repository at this point in the history
Bug 1826230: Bump to 1.18.2
  • Loading branch information
openshift-merge-robot committed May 11, 2020
2 parents 3539e40 + 08bd700 commit 31279d2
Show file tree
Hide file tree
Showing 960 changed files with 50,132 additions and 99,237 deletions.
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ require (
github.com/gorilla/sessions v0.0.0-20171008214740-a3acf13e802c
github.com/gorilla/websocket v1.4.1 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.10.0 // indirect
github.com/openshift/api v0.0.0-20200127192224-ffde1bfabb9f
github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160
github.com/openshift/client-go v0.0.0-20200116152001-92a2713fa240
github.com/openshift/library-go v0.0.0-20200130090538-26ae77929944
github.com/openshift/api v0.0.0-20200429152225-b98a784d8e6d
github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc
github.com/openshift/client-go v0.0.0-20200422192633-6f6c07fc2a70
github.com/openshift/library-go v0.0.0-20200429122220-9e6c27e916a0
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
go.uber.org/atomic v1.4.0 // indirect
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
gopkg.in/ldap.v2 v2.5.1
k8s.io/api v0.17.4
k8s.io/apimachinery v0.17.4
k8s.io/apiserver v0.17.4
k8s.io/client-go v0.17.4
k8s.io/component-base v0.17.4
k8s.io/api v0.18.2
k8s.io/apimachinery v0.18.2
k8s.io/apiserver v0.18.2
k8s.io/client-go v0.18.2
k8s.io/component-base v0.18.2
k8s.io/klog v1.0.0
)

Expand Down
145 changes: 78 additions & 67 deletions go.sum

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pkg/api/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package api

import (
"context"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/authentication/user"

Expand Down Expand Up @@ -95,5 +97,5 @@ type ProviderInfo struct {
// OAuthClientGetter exposes a way to get a specific client. This is useful for other registries to get scope limitations
// on particular clients. This interface will make its easier to write a future cache on it
type OAuthClientGetter interface {
Get(name string, options metav1.GetOptions) (*oauthapi.OAuthClient, error)
Get(ctx context.Context, name string, options metav1.GetOptions) (*oauthapi.OAuthClient, error)
}
5 changes: 3 additions & 2 deletions pkg/oauth/registry/grantchecker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package registry

import (
"context"
stderrors "errors"

"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -58,7 +59,7 @@ func (c *ClientAuthorizationGrantChecker) HasAuthorizedClient(user kuser.Info, g
// getClientAuthorization gets the OAuthClientAuthorization with the given name and validates that it matches the given user
// it attempts to delete stale client authorizations, and thus must be retried in case of conflicts
func (c *ClientAuthorizationGrantChecker) getClientAuthorization(name string, user kuser.Info) (*oauth.OAuthClientAuthorization, error) {
authorization, err := c.client.Get(name, metav1.GetOptions{})
authorization, err := c.client.Get(context.TODO(), name, metav1.GetOptions{})
if errors.IsNotFound(err) {
// if no such authorization exists, it simply means the user needs to go through the grant flow
return nil, nil
Expand All @@ -72,7 +73,7 @@ func (c *ClientAuthorizationGrantChecker) getClientAuthorization(name string, us
// user.GetUID() and authorization.UserUID are both guaranteed to be non-empty
if user.GetUID() != authorization.UserUID {
klog.Infof("%#v does not match stored client authorization %#v, attempting to delete stale authorization", user, authorization)
if err := c.client.Delete(name, metav1.NewPreconditionDeleteOptions(string(authorization.UID))); err != nil && !errors.IsNotFound(err) {
if err := c.client.Delete(context.TODO(), name, *metav1.NewPreconditionDeleteOptions(string(authorization.UID))); err != nil && !errors.IsNotFound(err) {
// ignore not found since that could be caused by multiple grant flows occurring at once (the other flow deleted the authorization before we did)
// this could be a conflict error, which will cause this whole function to be retried
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion pkg/oauthserver/auth.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package oauthserver

import (
"context"
"crypto/tls"
"crypto/x509"
"errors"
Expand Down Expand Up @@ -161,7 +162,7 @@ func (c *OAuthServerConfig) WithOAuth(handler http.Handler) (http.Handler, error
}

func (c *OAuthServerConfig) getOsinOAuthClient() (*osincli.Client, error) {
browserClient, err := c.ExtraOAuthConfig.OAuthClientClient.Get(openShiftBrowserClientID, metav1.GetOptions{})
browserClient, err := c.ExtraOAuthConfig.OAuthClientClient.Get(context.TODO(), openShiftBrowserClientID, metav1.GetOptions{})
if err != nil {
return nil, err
}
Expand Down
19 changes: 10 additions & 9 deletions pkg/osinserver/registrystorage/storage.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package registrystorage

import (
"context"
"errors"
"fmt"
"strings"
Expand Down Expand Up @@ -103,7 +104,7 @@ func (s *storage) Close() {

// GetClient loads the client by id (client_id)
func (s *storage) GetClient(id string) (osin.Client, error) {
c, err := s.client.Get(id, metav1.GetOptions{})
c, err := s.client.Get(context.TODO(), id, metav1.GetOptions{})
if err != nil {
if kerrors.IsNotFound(err) {
return nil, nil
Expand All @@ -119,15 +120,15 @@ func (s *storage) SaveAuthorize(data *osin.AuthorizeData) error {
if err != nil {
return err
}
_, err = s.authorizetoken.Create(token)
_, err = s.authorizetoken.Create(context.TODO(), token, metav1.CreateOptions{})
return err
}

// LoadAuthorize looks up AuthorizeData by a code.
// Client information MUST be loaded together.
// Optionally can return error if expired.
func (s *storage) LoadAuthorize(code string) (*osin.AuthorizeData, error) {
authorize, err := s.authorizetoken.Get(code, metav1.GetOptions{})
authorize, err := s.authorizetoken.Get(context.TODO(), code, metav1.GetOptions{})
if kerrors.IsNotFound(err) {
klog.V(5).Info("Authorization code not found")
return nil, nil
Expand All @@ -141,7 +142,7 @@ func (s *storage) LoadAuthorize(code string) (*osin.AuthorizeData, error) {
// RemoveAuthorize revokes or deletes the authorization code.
func (s *storage) RemoveAuthorize(code string) error {
// TODO: return no error if registry returns IsNotFound
return s.authorizetoken.Delete(code, nil)
return s.authorizetoken.Delete(context.TODO(), code, metav1.DeleteOptions{})
}

// SaveAccess writes AccessData.
Expand All @@ -151,15 +152,15 @@ func (s *storage) SaveAccess(data *osin.AccessData) error {
if err != nil {
return err
}
_, err = s.accesstoken.Create(token)
_, err = s.accesstoken.Create(context.TODO(), token, metav1.CreateOptions{})
return err
}

// LoadAccess retrieves access data by token. Client information MUST be loaded together.
// AuthorizeData and AccessData DON'T NEED to be loaded if not easily available.
// Optionally can return error if expired.
func (s *storage) LoadAccess(token string) (*osin.AccessData, error) {
access, err := s.accesstoken.Get(token, metav1.GetOptions{})
access, err := s.accesstoken.Get(context.TODO(), token, metav1.GetOptions{})
if err != nil {
return nil, err
}
Expand All @@ -169,7 +170,7 @@ func (s *storage) LoadAccess(token string) (*osin.AccessData, error) {
// RemoveAccess revokes or deletes an AccessData.
func (s *storage) RemoveAccess(token string) error {
// TODO: return no error if registry returns IsNotFound
return s.accesstoken.Delete(token, nil)
return s.accesstoken.Delete(context.TODO(), token, metav1.DeleteOptions{})
}

// LoadRefresh retrieves refresh AccessData. Client information MUST be loaded together.
Expand Down Expand Up @@ -211,7 +212,7 @@ func (s *storage) convertFromAuthorizeToken(authorize *oauthapi.OAuthAuthorizeTo
if err != nil {
return nil, err
}
client, err := s.client.Get(authorize.ClientName, metav1.GetOptions{})
client, err := s.client.Get(context.TODO(), authorize.ClientName, metav1.GetOptions{})
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -270,7 +271,7 @@ func (s *storage) convertFromAccessToken(access *oauthapi.OAuthAccessToken) (*os
if err != nil {
return nil, err
}
client, err := s.client.Get(access.ClientName, metav1.GetOptions{})
client, err := s.client.Get(context.TODO(), access.ClientName, metav1.GetOptions{})
if err != nil {
return nil, err
}
Expand Down
15 changes: 8 additions & 7 deletions pkg/server/grant/grant.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package grant

import (
"context"
"fmt"
"net/http"
"net/url"
Expand All @@ -17,7 +18,7 @@ import (
oapi "github.com/openshift/api/oauth/v1"
oauthclient "github.com/openshift/client-go/oauth/clientset/versioned/typed/oauth/v1"
scopemetadata "github.com/openshift/library-go/pkg/authorization/scopemetadata"
"github.com/openshift/oauth-server/pkg"
oauthserver "github.com/openshift/oauth-server/pkg"
"github.com/openshift/oauth-server/pkg/api"
"github.com/openshift/oauth-server/pkg/scopecovers"
"github.com/openshift/oauth-server/pkg/server/csrf"
Expand Down Expand Up @@ -124,7 +125,7 @@ func (l *Grant) handleForm(user user.Info, w http.ResponseWriter, req *http.Requ
scopes := scopecovers.Split(q.Get(scopeParam))
redirectURI := q.Get(redirectURIParam)

client, err := l.clientregistry.Get(clientID, metav1.GetOptions{})
client, err := l.clientregistry.Get(context.TODO(), clientID, metav1.GetOptions{})
if err != nil || client == nil {
l.failed("Could not find client for client_id", w, req)
return
Expand All @@ -141,7 +142,7 @@ func (l *Grant) handleForm(user user.Info, w http.ResponseWriter, req *http.Requ
requestedScopes := []Scope{}

clientAuthID := user.GetName() + ":" + client.Name
if clientAuth, err := l.authregistry.Get(clientAuthID, metav1.GetOptions{}); err == nil {
if clientAuth, err := l.authregistry.Get(context.TODO(), clientAuthID, metav1.GetOptions{}); err == nil {
grantedScopeNames = clientAuth.Scopes
}

Expand Down Expand Up @@ -221,7 +222,7 @@ func (l *Grant) handleGrant(user user.Info, w http.ResponseWriter, req *http.Req
}

clientID := req.PostFormValue(clientIDParam)
client, err := l.clientregistry.Get(clientID, metav1.GetOptions{})
client, err := l.clientregistry.Get(context.TODO(), clientID, metav1.GetOptions{})
if err != nil || client == nil {
l.failed("Could not find client for client_id", w, req)
return
Expand All @@ -234,11 +235,11 @@ func (l *Grant) handleGrant(user user.Info, w http.ResponseWriter, req *http.Req

clientAuthID := user.GetName() + ":" + client.Name

clientAuth, err := l.authregistry.Get(clientAuthID, metav1.GetOptions{})
clientAuth, err := l.authregistry.Get(context.TODO(), clientAuthID, metav1.GetOptions{})
if err == nil && clientAuth != nil {
// Add new scopes and update
clientAuth.Scopes = scopecovers.Add(clientAuth.Scopes, scopecovers.Split(scopes))
if _, err = l.authregistry.Update(clientAuth); err != nil {
if _, err = l.authregistry.Update(context.TODO(), clientAuth, metav1.UpdateOptions{}); err != nil {
klog.Errorf("Unable to update authorization: %v", err)
l.failed("Could not update client authorization", w, req)
return
Expand All @@ -253,7 +254,7 @@ func (l *Grant) handleGrant(user user.Info, w http.ResponseWriter, req *http.Req
}
clientAuth.Name = clientAuthID

if _, err = l.authregistry.Create(clientAuth); err != nil {
if _, err = l.authregistry.Create(context.TODO(), clientAuth, metav1.CreateOptions{}); err != nil {
klog.Errorf("Unable to create authorization: %v", err)
l.failed("Could not create client authorization", w, req)
return
Expand Down
5 changes: 3 additions & 2 deletions pkg/server/tokenrequest/tokenrequest.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tokenrequest

import (
"context"
"fmt"
"html/template"
"io"
Expand All @@ -17,7 +18,7 @@ import (
"github.com/openshift/client-go/oauth/clientset/versioned/typed/oauth/v1"
bootstrap "github.com/openshift/library-go/pkg/authentication/bootstrapauthenticator"
"github.com/openshift/library-go/pkg/oauth/oauthdiscovery"
"github.com/openshift/oauth-server/pkg"
oauthserver "github.com/openshift/oauth-server/pkg"
"github.com/openshift/oauth-server/pkg/server/csrf"
)

Expand Down Expand Up @@ -127,7 +128,7 @@ func (t *tokenRequest) displayTokenPost(osinOAuthClient *osincli.Client, w http.
return
}

token, err := t.tokens.Get(accessData.AccessToken, metav1.GetOptions{})
token, err := t.tokens.Get(context.TODO(), accessData.AccessToken, metav1.GetOptions{})
if err != nil {
data.Error = "Error checking token" // do not leak error to user, do not log error
w.WriteHeader(http.StatusInternalServerError)
Expand Down
5 changes: 3 additions & 2 deletions pkg/userregistry/identitymapper/lookup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package identitymapper

import (
"context"
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -20,12 +21,12 @@ type lookupIdentityMapper struct {

// UserFor returns info about the user for whom identity info has been provided
func (p *lookupIdentityMapper) UserFor(info authapi.UserIdentityInfo) (kuser.Info, error) {
mapping, err := p.mappings.Get(info.GetIdentityName(), metav1.GetOptions{})
mapping, err := p.mappings.Get(context.TODO(), info.GetIdentityName(), metav1.GetOptions{})
if err != nil {
return nil, NewLookupError(info, err)
}

u, err := p.users.Get(mapping.User.Name, metav1.GetOptions{})
u, err := p.users.Get(context.TODO(), mapping.User.Name, metav1.GetOptions{})
if err != nil {
return nil, NewLookupError(info, err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/userregistry/identitymapper/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (p *provisioningIdentityMapper) UserFor(info authapi.UserIdentityInfo) (kus
func (p *provisioningIdentityMapper) userForWithRetries(info authapi.UserIdentityInfo, allowedRetries int) (kuser.Info, error) {
ctx := apirequest.NewContext()

identity, err := p.identity.Get(info.GetIdentityName(), metav1.GetOptions{})
identity, err := p.identity.Get(context.TODO(), info.GetIdentityName(), metav1.GetOptions{})

if kerrs.IsNotFound(err) {
user, err := p.createIdentityAndMapping(ctx, info)
Expand Down Expand Up @@ -98,7 +98,7 @@ func (p *provisioningIdentityMapper) createIdentityAndMapping(ctx context.Contex
Name: persistedUser.Name,
UID: persistedUser.UID,
}
if _, err := p.identity.Create(identity); err != nil {
if _, err := p.identity.Create(context.TODO(), identity, metav1.CreateOptions{}); err != nil {
return nil, err
}

Expand All @@ -109,7 +109,7 @@ func (p *provisioningIdentityMapper) getMapping(ctx context.Context, identity *u
if len(identity.User.Name) == 0 {
return nil, kerrs.NewNotFound(userapi.Resource("useridentitymapping"), identity.Name)
}
u, err := p.user.Get(identity.User.Name, metav1.GetOptions{})
u, err := p.user.Get(context.TODO(), identity.User.Name, metav1.GetOptions{})
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/userregistry/identitymapper/strategy_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewStrategyAdd(user userclient.UserInterface, initializer Initializer) User

func (s *StrategyAdd) UserForNewIdentity(ctx context.Context, preferredUserName string, identity *userapi.Identity) (*userapi.User, error) {

persistedUser, err := s.user.Get(preferredUserName, metav1.GetOptions{})
persistedUser, err := s.user.Get(context.TODO(), preferredUserName, metav1.GetOptions{})

switch {
case kerrs.IsNotFound(err):
Expand All @@ -34,7 +34,7 @@ func (s *StrategyAdd) UserForNewIdentity(ctx context.Context, preferredUserName
desiredUser.Name = preferredUserName
desiredUser.Identities = []string{identity.Name}
s.initializer.InitializeUser(identity, desiredUser)
return s.user.Create(desiredUser)
return s.user.Create(context.TODO(), desiredUser, metav1.CreateOptions{})

case err == nil:
// If the existing user already references our identity, we're done
Expand All @@ -48,7 +48,7 @@ func (s *StrategyAdd) UserForNewIdentity(ctx context.Context, preferredUserName
if len(persistedUser.Identities) == 1 {
s.initializer.InitializeUser(identity, persistedUser)
}
return s.user.Update(persistedUser)
return s.user.Update(context.TODO(), persistedUser, metav1.UpdateOptions{})

default:
// Fail on errors other than "not found"
Expand Down
6 changes: 3 additions & 3 deletions pkg/userregistry/identitymapper/strategy_claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewStrategyClaim(user userclient.UserInterface, initializer Initializer) Us

func (s *StrategyClaim) UserForNewIdentity(ctx context.Context, preferredUserName string, identity *userapi.Identity) (*userapi.User, error) {

persistedUser, err := s.user.Get(preferredUserName, metav1.GetOptions{})
persistedUser, err := s.user.Get(context.TODO(), preferredUserName, metav1.GetOptions{})

switch {
case kerrs.IsNotFound(err):
Expand All @@ -52,7 +52,7 @@ func (s *StrategyClaim) UserForNewIdentity(ctx context.Context, preferredUserNam
desiredUser.Name = preferredUserName
desiredUser.Identities = []string{identity.Name}
s.initializer.InitializeUser(identity, desiredUser)
return s.user.Create(desiredUser)
return s.user.Create(context.TODO(), desiredUser, metav1.CreateOptions{})

case err == nil:
// If the existing user already references our identity, we're done
Expand All @@ -64,7 +64,7 @@ func (s *StrategyClaim) UserForNewIdentity(ctx context.Context, preferredUserNam
if len(persistedUser.Identities) == 0 {
persistedUser.Identities = []string{identity.Name}
s.initializer.InitializeUser(identity, persistedUser)
return s.user.Update(persistedUser)
return s.user.Update(context.TODO(), persistedUser, metav1.UpdateOptions{})
}

// Otherwise another identity has already claimed this user, return an error
Expand Down
4 changes: 2 additions & 2 deletions pkg/userregistry/identitymapper/strategy_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ UserSearch:
potentialUserName := s.generator(preferredUserName, sequence)

// See if it already exists
persistedUser, err := s.user.Get(potentialUserName, metav1.GetOptions{})
persistedUser, err := s.user.Get(context.TODO(), potentialUserName, metav1.GetOptions{})

switch {
case kerrs.IsNotFound(err):
Expand All @@ -64,7 +64,7 @@ UserSearch:
desiredUser.Name = potentialUserName
desiredUser.Identities = []string{identity.Name}
s.initializer.InitializeUser(identity, desiredUser)
return s.user.Create(desiredUser)
return s.user.Create(context.TODO(), desiredUser, metav1.CreateOptions{})

case err == nil:
// If the existing user already references our identity, we're done
Expand Down

0 comments on commit 31279d2

Please sign in to comment.