Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
76ce7bcb
Commit
76ce7bcb
authored
Jan 25, 2017
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stop hardcoding api registry and codecs in webhook
parent
d76295b5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
15 deletions
+13
-15
BUILD
plugin/pkg/admission/imagepolicy/BUILD
+1
-2
admission.go
plugin/pkg/admission/imagepolicy/admission.go
+2
-3
webhook.go
staging/src/k8s.io/apiserver/pkg/util/webhook/webhook.go
+5
-6
webhook.go
...iserver/plugin/pkg/authenticator/token/webhook/webhook.go
+2
-1
webhook.go
...k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go
+3
-3
BUILD
vendor/BUILD
+0
-0
No files found.
plugin/pkg/admission/imagepolicy/BUILD
View file @
76ce7bcb
...
@@ -19,6 +19,7 @@ go_library(
...
@@ -19,6 +19,7 @@ go_library(
deps = [
deps = [
"//pkg/api:go_default_library",
"//pkg/api:go_default_library",
"//pkg/apis/imagepolicy/install:go_default_library",
"//pkg/apis/imagepolicy/install:go_default_library",
"//pkg/apis/imagepolicy/v1alpha1:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:github.com/golang/glog",
"//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/api/errors",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
...
@@ -26,8 +27,6 @@ go_library(
...
@@ -26,8 +27,6 @@ go_library(
"//vendor:k8s.io/apiserver/pkg/admission",
"//vendor:k8s.io/apiserver/pkg/admission",
"//vendor:k8s.io/apiserver/pkg/util/cache",
"//vendor:k8s.io/apiserver/pkg/util/cache",
"//vendor:k8s.io/apiserver/pkg/util/webhook",
"//vendor:k8s.io/apiserver/pkg/util/webhook",
"//vendor:k8s.io/client-go/pkg/apis/imagepolicy/install",
"//vendor:k8s.io/client-go/pkg/apis/imagepolicy/v1alpha1",
"//vendor:k8s.io/client-go/rest",
"//vendor:k8s.io/client-go/rest",
],
],
)
)
...
...
plugin/pkg/admission/imagepolicy/admission.go
View file @
76ce7bcb
...
@@ -35,13 +35,12 @@ import (
...
@@ -35,13 +35,12 @@ import (
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/util/cache"
"k8s.io/apiserver/pkg/util/cache"
"k8s.io/apiserver/pkg/util/webhook"
"k8s.io/apiserver/pkg/util/webhook"
"k8s.io/client-go/pkg/apis/imagepolicy/v1alpha1"
"k8s.io/client-go/rest"
"k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/imagepolicy/v1alpha1"
// install the clientgo image policy API for use with api registry
// install the clientgo image policy API for use with api registry
_
"k8s.io/client-go/pkg/apis/imagepolicy/install"
_
"k8s.io/kubernetes/pkg/apis/imagepolicy/install"
_
"k8s.io/kubernetes/pkg/apis/imagepolicy/install"
)
)
...
@@ -228,7 +227,7 @@ func NewImagePolicyWebhook(configFile io.Reader) (admission.Interface, error) {
...
@@ -228,7 +227,7 @@ func NewImagePolicyWebhook(configFile io.Reader) (admission.Interface, error) {
return
nil
,
err
return
nil
,
err
}
}
gw
,
err
:=
webhook
.
NewGenericWebhook
(
whConfig
.
KubeConfigFile
,
groupVersions
,
whConfig
.
RetryBackoff
)
gw
,
err
:=
webhook
.
NewGenericWebhook
(
api
.
Registry
,
api
.
Codecs
,
whConfig
.
KubeConfigFile
,
groupVersions
,
whConfig
.
RetryBackoff
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
staging/src/k8s.io/apiserver/pkg/util/webhook/webhook.go
View file @
76ce7bcb
...
@@ -22,15 +22,14 @@ import (
...
@@ -22,15 +22,14 @@ import (
"time"
"time"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
runtimeserializer
"k8s.io/apimachinery/pkg/runtime/serializer"
runtimeserializer
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/rest"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd"
_
"k8s.io/client-go/pkg/apis/authorization/install"
)
)
type
GenericWebhook
struct
{
type
GenericWebhook
struct
{
...
@@ -39,9 +38,9 @@ type GenericWebhook struct {
...
@@ -39,9 +38,9 @@ type GenericWebhook struct {
}
}
// NewGenericWebhook creates a new GenericWebhook from the provided kubeconfig file.
// NewGenericWebhook creates a new GenericWebhook from the provided kubeconfig file.
func
NewGenericWebhook
(
kubeConfigFile
string
,
groupVersions
[]
schema
.
GroupVersion
,
initialBackoff
time
.
Duration
)
(
*
GenericWebhook
,
error
)
{
func
NewGenericWebhook
(
registry
*
registered
.
APIRegistrationManager
,
codecFactory
serializer
.
CodecFactory
,
kubeConfigFile
string
,
groupVersions
[]
schema
.
GroupVersion
,
initialBackoff
time
.
Duration
)
(
*
GenericWebhook
,
error
)
{
for
_
,
groupVersion
:=
range
groupVersions
{
for
_
,
groupVersion
:=
range
groupVersions
{
if
!
api
.
R
egistry
.
IsEnabledVersion
(
groupVersion
)
{
if
!
r
egistry
.
IsEnabledVersion
(
groupVersion
)
{
return
nil
,
fmt
.
Errorf
(
"webhook plugin requires enabling extension resource: %s"
,
groupVersion
)
return
nil
,
fmt
.
Errorf
(
"webhook plugin requires enabling extension resource: %s"
,
groupVersion
)
}
}
}
}
...
@@ -54,7 +53,7 @@ func NewGenericWebhook(kubeConfigFile string, groupVersions []schema.GroupVersio
...
@@ -54,7 +53,7 @@ func NewGenericWebhook(kubeConfigFile string, groupVersions []schema.GroupVersio
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
codec
:=
api
.
Codecs
.
LegacyCodec
(
groupVersions
...
)
codec
:=
codecFactory
.
LegacyCodec
(
groupVersions
...
)
clientConfig
.
ContentConfig
.
NegotiatedSerializer
=
runtimeserializer
.
NegotiatedSerializerWrapper
(
runtime
.
SerializerInfo
{
Serializer
:
codec
})
clientConfig
.
ContentConfig
.
NegotiatedSerializer
=
runtimeserializer
.
NegotiatedSerializerWrapper
(
runtime
.
SerializerInfo
{
Serializer
:
codec
})
restClient
,
err
:=
rest
.
UnversionedRESTClientFor
(
clientConfig
)
restClient
,
err
:=
rest
.
UnversionedRESTClientFor
(
clientConfig
)
...
...
staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go
View file @
76ce7bcb
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"k8s.io/apiserver/pkg/util/cache"
"k8s.io/apiserver/pkg/util/cache"
"k8s.io/apiserver/pkg/util/webhook"
"k8s.io/apiserver/pkg/util/webhook"
authenticationclient
"k8s.io/client-go/kubernetes/typed/authentication/v1beta1"
authenticationclient
"k8s.io/client-go/kubernetes/typed/authentication/v1beta1"
"k8s.io/client-go/pkg/api"
authentication
"k8s.io/client-go/pkg/apis/authentication/v1beta1"
authentication
"k8s.io/client-go/pkg/apis/authentication/v1beta1"
_
"k8s.io/client-go/pkg/apis/authentication/install"
_
"k8s.io/client-go/pkg/apis/authentication/install"
...
@@ -112,7 +113,7 @@ func (w *WebhookTokenAuthenticator) AuthenticateToken(token string) (user.Info,
...
@@ -112,7 +113,7 @@ func (w *WebhookTokenAuthenticator) AuthenticateToken(token string) (user.Info,
// and returns a TokenReviewInterface that uses that client. Note that the client submits TokenReview
// and returns a TokenReviewInterface that uses that client. Note that the client submits TokenReview
// requests to the exact path specified in the kubeconfig file, so arbitrary non-API servers can be targeted.
// requests to the exact path specified in the kubeconfig file, so arbitrary non-API servers can be targeted.
func
tokenReviewInterfaceFromKubeconfig
(
kubeConfigFile
string
)
(
authenticationclient
.
TokenReviewInterface
,
error
)
{
func
tokenReviewInterfaceFromKubeconfig
(
kubeConfigFile
string
)
(
authenticationclient
.
TokenReviewInterface
,
error
)
{
gw
,
err
:=
webhook
.
NewGenericWebhook
(
kubeConfigFile
,
groupVersions
,
0
)
gw
,
err
:=
webhook
.
NewGenericWebhook
(
api
.
Registry
,
api
.
Codecs
,
kubeConfigFile
,
groupVersions
,
0
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook/webhook.go
View file @
76ce7bcb
...
@@ -26,11 +26,11 @@ import (
...
@@ -26,11 +26,11 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/apiserver/pkg/util/cache"
"k8s.io/apiserver/pkg/util/cache"
"k8s.io/apiserver/pkg/util/webhook"
authorizationclient
"k8s.io/client-go/kubernetes/typed/authorization/v1beta1"
authorizationclient
"k8s.io/client-go/kubernetes/typed/authorization/v1beta1"
"k8s.io/client-go/pkg/api"
authorization
"k8s.io/client-go/pkg/apis/authorization/v1beta1"
authorization
"k8s.io/client-go/pkg/apis/authorization/v1beta1"
"k8s.io/apiserver/pkg/util/webhook"
_
"k8s.io/client-go/pkg/apis/authorization/install"
_
"k8s.io/client-go/pkg/apis/authorization/install"
)
)
...
@@ -211,7 +211,7 @@ func convertToSARExtra(extra map[string][]string) map[string]authorization.Extra
...
@@ -211,7 +211,7 @@ func convertToSARExtra(extra map[string][]string) map[string]authorization.Extra
// and returns a SubjectAccessReviewInterface that uses that client. Note that the client submits SubjectAccessReview
// and returns a SubjectAccessReviewInterface that uses that client. Note that the client submits SubjectAccessReview
// requests to the exact path specified in the kubeconfig file, so arbitrary non-API servers can be targeted.
// requests to the exact path specified in the kubeconfig file, so arbitrary non-API servers can be targeted.
func
subjectAccessReviewInterfaceFromKubeconfig
(
kubeConfigFile
string
)
(
authorizationclient
.
SubjectAccessReviewInterface
,
error
)
{
func
subjectAccessReviewInterfaceFromKubeconfig
(
kubeConfigFile
string
)
(
authorizationclient
.
SubjectAccessReviewInterface
,
error
)
{
gw
,
err
:=
webhook
.
NewGenericWebhook
(
kubeConfigFile
,
groupVersions
,
0
)
gw
,
err
:=
webhook
.
NewGenericWebhook
(
api
.
Registry
,
api
.
Codecs
,
kubeConfigFile
,
groupVersions
,
0
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
vendor/BUILD
View file @
76ce7bcb
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment