Merge pull request #85098 from liggitt/admission-config-v1
Promote apiserver.config.k8s.io/v1, kind=AdmissionConfiguration Kubernetes-commit: b49afbfa64b6be72779b6deb424d7f0cddd5ccf1
This commit is contained in:
commit
58a8d30b19
|
@ -576,11 +576,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api",
|
"ImportPath": "k8s.io/api",
|
||||||
"Rev": "37fc98278a4b"
|
"Rev": "40f4bbc2b486"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery",
|
"ImportPath": "k8s.io/apimachinery",
|
||||||
"Rev": "d496f1036126"
|
"Rev": "3db02fd2eea7"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/client-go",
|
"ImportPath": "k8s.io/client-go",
|
||||||
|
@ -588,7 +588,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/component-base",
|
"ImportPath": "k8s.io/component-base",
|
||||||
"Rev": "cca8f4f7ce4d"
|
"Rev": "42a5d5b2565c"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo",
|
"ImportPath": "k8s.io/gengo",
|
||||||
|
|
12
go.mod
12
go.mod
|
@ -42,10 +42,10 @@ require (
|
||||||
gopkg.in/square/go-jose.v2 v2.2.2
|
gopkg.in/square/go-jose.v2 v2.2.2
|
||||||
gopkg.in/yaml.v2 v2.2.4
|
gopkg.in/yaml.v2 v2.2.4
|
||||||
gotest.tools v2.2.0+incompatible // indirect
|
gotest.tools v2.2.0+incompatible // indirect
|
||||||
k8s.io/api v0.0.0-20191114100032-37fc98278a4b
|
k8s.io/api v0.0.0-20191114100036-40f4bbc2b486
|
||||||
k8s.io/apimachinery v0.0.0-20191114095527-d496f1036126
|
k8s.io/apimachinery v0.0.0-20191114095528-3db02fd2eea7
|
||||||
k8s.io/client-go v0.0.0-20191114100700-74d7a2e0ebca
|
k8s.io/client-go v0.0.0-20191114100700-74d7a2e0ebca
|
||||||
k8s.io/component-base v0.0.0-20191111061729-cca8f4f7ce4d
|
k8s.io/component-base v0.0.0-20191114102135-42a5d5b2565c
|
||||||
k8s.io/klog v1.0.0
|
k8s.io/klog v1.0.0
|
||||||
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
|
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
|
||||||
k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d
|
k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d
|
||||||
|
@ -56,8 +56,8 @@ require (
|
||||||
replace (
|
replace (
|
||||||
golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
|
golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
|
||||||
golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7
|
golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7
|
||||||
k8s.io/api => k8s.io/api v0.0.0-20191114100032-37fc98278a4b
|
k8s.io/api => k8s.io/api v0.0.0-20191114100036-40f4bbc2b486
|
||||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20191114095527-d496f1036126
|
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20191114095528-3db02fd2eea7
|
||||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20191114100700-74d7a2e0ebca
|
k8s.io/client-go => k8s.io/client-go v0.0.0-20191114100700-74d7a2e0ebca
|
||||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20191111061729-cca8f4f7ce4d
|
k8s.io/component-base => k8s.io/component-base v0.0.0-20191114102135-42a5d5b2565c
|
||||||
)
|
)
|
||||||
|
|
6
go.sum
6
go.sum
|
@ -346,10 +346,10 @@ gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
k8s.io/api v0.0.0-20191114100032-37fc98278a4b/go.mod h1:8svLRMiLwQReMTycutfjsaQ0ackWIf8HCT4UcixYLjI=
|
k8s.io/api v0.0.0-20191114100036-40f4bbc2b486/go.mod h1:IM5ceavki8HjRhUlaRYP3oGw0J/hbXKiKiSqS5AR728=
|
||||||
k8s.io/apimachinery v0.0.0-20191114095527-d496f1036126/go.mod h1:+6CX7hP4aLfX2sb91JYDMIp0VqDSog2kZu0BHe+lP+s=
|
k8s.io/apimachinery v0.0.0-20191114095528-3db02fd2eea7/go.mod h1:+6CX7hP4aLfX2sb91JYDMIp0VqDSog2kZu0BHe+lP+s=
|
||||||
k8s.io/client-go v0.0.0-20191114100700-74d7a2e0ebca/go.mod h1:NWDcvX+oAkmke5fjHiErMvbgGGoaHcZcxGNYutZ3MtQ=
|
k8s.io/client-go v0.0.0-20191114100700-74d7a2e0ebca/go.mod h1:NWDcvX+oAkmke5fjHiErMvbgGGoaHcZcxGNYutZ3MtQ=
|
||||||
k8s.io/component-base v0.0.0-20191111061729-cca8f4f7ce4d/go.mod h1:hCGnNyhGnZljl2XmSocXO/ySLrgK5bpKAMqSFAFES/E=
|
k8s.io/component-base v0.0.0-20191114102135-42a5d5b2565c/go.mod h1:rwIfg3coOPWGYSmJnTp7yw1QVOB/ncA32pwgawNSR2Q=
|
||||||
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||||
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||||
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||||
|
|
|
@ -32,7 +32,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apiserver/pkg/apis/apiserver"
|
"k8s.io/apiserver/pkg/apis/apiserver"
|
||||||
apiserverv1alpha1 "k8s.io/apiserver/pkg/apis/apiserver/v1alpha1"
|
apiserverv1 "k8s.io/apiserver/pkg/apis/apiserver/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeAbs(path, base string) (string, error) {
|
func makeAbs(path, base string) (string, error) {
|
||||||
|
@ -110,11 +110,11 @@ func ReadAdmissionConfiguration(pluginNames []string, configFilePath string, con
|
||||||
// previously read input from a non-versioned file configuration to the
|
// previously read input from a non-versioned file configuration to the
|
||||||
// current input file.
|
// current input file.
|
||||||
legacyPluginsWithUnversionedConfig := sets.NewString("ImagePolicyWebhook", "PodNodeSelector")
|
legacyPluginsWithUnversionedConfig := sets.NewString("ImagePolicyWebhook", "PodNodeSelector")
|
||||||
externalConfig := &apiserverv1alpha1.AdmissionConfiguration{}
|
externalConfig := &apiserverv1.AdmissionConfiguration{}
|
||||||
for _, pluginName := range pluginNames {
|
for _, pluginName := range pluginNames {
|
||||||
if legacyPluginsWithUnversionedConfig.Has(pluginName) {
|
if legacyPluginsWithUnversionedConfig.Has(pluginName) {
|
||||||
externalConfig.Plugins = append(externalConfig.Plugins,
|
externalConfig.Plugins = append(externalConfig.Plugins,
|
||||||
apiserverv1alpha1.AdmissionPluginConfiguration{
|
apiserverv1.AdmissionPluginConfiguration{
|
||||||
Name: pluginName,
|
Name: pluginName,
|
||||||
Path: configFilePath})
|
Path: configFilePath})
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
"k8s.io/apiserver/pkg/apis/apiserver"
|
"k8s.io/apiserver/pkg/apis/apiserver"
|
||||||
|
apiserverapiv1 "k8s.io/apiserver/pkg/apis/apiserver/v1"
|
||||||
apiserverapiv1alpha1 "k8s.io/apiserver/pkg/apis/apiserver/v1alpha1"
|
apiserverapiv1alpha1 "k8s.io/apiserver/pkg/apis/apiserver/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -76,6 +77,48 @@ func TestReadAdmissionConfiguration(t *testing.T) {
|
||||||
ConfigBody: `{
|
ConfigBody: `{
|
||||||
"apiVersion": "apiserver.k8s.io/v1alpha1",
|
"apiVersion": "apiserver.k8s.io/v1alpha1",
|
||||||
"kind": "AdmissionConfiguration",
|
"kind": "AdmissionConfiguration",
|
||||||
|
"plugins": [
|
||||||
|
{"name": "ImagePolicyWebhook", "path": "/tmp/image-policy-webhook.json"},
|
||||||
|
{"name": "ResourceQuota"}
|
||||||
|
]}`,
|
||||||
|
ExpectedAdmissionConfig: &apiserver.AdmissionConfiguration{
|
||||||
|
Plugins: []apiserver.AdmissionPluginConfiguration{
|
||||||
|
{
|
||||||
|
Name: "ImagePolicyWebhook",
|
||||||
|
Path: "/tmp/image-policy-webhook.json",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "ResourceQuota",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PluginNames: []string{},
|
||||||
|
},
|
||||||
|
"v1 configuration - path fixup": {
|
||||||
|
ConfigBody: `{
|
||||||
|
"apiVersion": "apiserver.config.k8s.io/v1",
|
||||||
|
"kind": "AdmissionConfiguration",
|
||||||
|
"plugins": [
|
||||||
|
{"name": "ImagePolicyWebhook", "path": "image-policy-webhook.json"},
|
||||||
|
{"name": "ResourceQuota"}
|
||||||
|
]}`,
|
||||||
|
ExpectedAdmissionConfig: &apiserver.AdmissionConfiguration{
|
||||||
|
Plugins: []apiserver.AdmissionPluginConfiguration{
|
||||||
|
{
|
||||||
|
Name: "ImagePolicyWebhook",
|
||||||
|
Path: imagePolicyWebhookFile,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "ResourceQuota",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PluginNames: []string{},
|
||||||
|
},
|
||||||
|
"v1 configuration - abspath": {
|
||||||
|
ConfigBody: `{
|
||||||
|
"apiVersion": "apiserver.config.k8s.io/v1",
|
||||||
|
"kind": "AdmissionConfiguration",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{"name": "ImagePolicyWebhook", "path": "/tmp/image-policy-webhook.json"},
|
{"name": "ImagePolicyWebhook", "path": "/tmp/image-policy-webhook.json"},
|
||||||
{"name": "ResourceQuota"}
|
{"name": "ResourceQuota"}
|
||||||
|
@ -141,6 +184,7 @@ func TestReadAdmissionConfiguration(t *testing.T) {
|
||||||
scheme := runtime.NewScheme()
|
scheme := runtime.NewScheme()
|
||||||
require.NoError(t, apiserver.AddToScheme(scheme))
|
require.NoError(t, apiserver.AddToScheme(scheme))
|
||||||
require.NoError(t, apiserverapiv1alpha1.AddToScheme(scheme))
|
require.NoError(t, apiserverapiv1alpha1.AddToScheme(scheme))
|
||||||
|
require.NoError(t, apiserverapiv1.AddToScheme(scheme))
|
||||||
|
|
||||||
for testName, testCase := range testCases {
|
for testName, testCase := range testCases {
|
||||||
if err = ioutil.WriteFile(configFileName, []byte(testCase.ConfigBody), 0644); err != nil {
|
if err = ioutil.WriteFile(configFileName, []byte(testCase.ConfigBody), 0644); err != nil {
|
||||||
|
@ -171,7 +215,7 @@ func TestEmbeddedConfiguration(t *testing.T) {
|
||||||
ConfigBody string
|
ConfigBody string
|
||||||
ExpectedConfig string
|
ExpectedConfig string
|
||||||
}{
|
}{
|
||||||
"versioned configuration": {
|
"v1alpha1 versioned configuration": {
|
||||||
ConfigBody: `{
|
ConfigBody: `{
|
||||||
"apiVersion": "apiserver.k8s.io/v1alpha1",
|
"apiVersion": "apiserver.k8s.io/v1alpha1",
|
||||||
"kind": "AdmissionConfiguration",
|
"kind": "AdmissionConfiguration",
|
||||||
|
@ -191,7 +235,7 @@ func TestEmbeddedConfiguration(t *testing.T) {
|
||||||
"foo": "bar"
|
"foo": "bar"
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
"legacy configuration": {
|
"v1alpha1 legacy configuration": {
|
||||||
ConfigBody: `{
|
ConfigBody: `{
|
||||||
"apiVersion": "apiserver.k8s.io/v1alpha1",
|
"apiVersion": "apiserver.k8s.io/v1alpha1",
|
||||||
"kind": "AdmissionConfiguration",
|
"kind": "AdmissionConfiguration",
|
||||||
|
@ -207,12 +251,49 @@ func TestEmbeddedConfiguration(t *testing.T) {
|
||||||
"foo": "bar"
|
"foo": "bar"
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
|
"v1 versioned configuration": {
|
||||||
|
ConfigBody: `{
|
||||||
|
"apiVersion": "apiserver.config.k8s.io/v1",
|
||||||
|
"kind": "AdmissionConfiguration",
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "Foo",
|
||||||
|
"configuration": {
|
||||||
|
"apiVersion": "foo.admission.k8s.io/v1alpha1",
|
||||||
|
"kind": "Configuration",
|
||||||
|
"foo": "bar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]}`,
|
||||||
|
ExpectedConfig: `{
|
||||||
|
"apiVersion": "foo.admission.k8s.io/v1alpha1",
|
||||||
|
"kind": "Configuration",
|
||||||
|
"foo": "bar"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
"v1 legacy configuration": {
|
||||||
|
ConfigBody: `{
|
||||||
|
"apiVersion": "apiserver.config.k8s.io/v1",
|
||||||
|
"kind": "AdmissionConfiguration",
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "Foo",
|
||||||
|
"configuration": {
|
||||||
|
"foo": "bar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]}`,
|
||||||
|
ExpectedConfig: `{
|
||||||
|
"foo": "bar"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for desc, test := range testCases {
|
for desc, test := range testCases {
|
||||||
scheme := runtime.NewScheme()
|
scheme := runtime.NewScheme()
|
||||||
require.NoError(t, apiserver.AddToScheme(scheme))
|
require.NoError(t, apiserver.AddToScheme(scheme))
|
||||||
require.NoError(t, apiserverapiv1alpha1.AddToScheme(scheme))
|
require.NoError(t, apiserverapiv1alpha1.AddToScheme(scheme))
|
||||||
|
require.NoError(t, apiserverapiv1.AddToScheme(scheme))
|
||||||
|
|
||||||
if err = ioutil.WriteFile(configFileName, []byte(test.ConfigBody), 0644); err != nil {
|
if err = ioutil.WriteFile(configFileName, []byte(test.ConfigBody), 0644); err != nil {
|
||||||
t.Errorf("[%s] unexpected err writing temp file: %v", desc, err)
|
t.Errorf("[%s] unexpected err writing temp file: %v", desc, err)
|
||||||
|
|
|
@ -20,12 +20,19 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
"k8s.io/apiserver/pkg/apis/apiserver"
|
"k8s.io/apiserver/pkg/apis/apiserver"
|
||||||
|
"k8s.io/apiserver/pkg/apis/apiserver/v1"
|
||||||
"k8s.io/apiserver/pkg/apis/apiserver/v1alpha1"
|
"k8s.io/apiserver/pkg/apis/apiserver/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Install registers the API group and adds types to a scheme
|
// Install registers the API group and adds types to a scheme
|
||||||
func Install(scheme *runtime.Scheme) {
|
func Install(scheme *runtime.Scheme) {
|
||||||
utilruntime.Must(apiserver.AddToScheme(scheme))
|
utilruntime.Must(apiserver.AddToScheme(scheme))
|
||||||
|
|
||||||
|
// v1alpha is in the k8s.io-suffixed API group
|
||||||
utilruntime.Must(v1alpha1.AddToScheme(scheme))
|
utilruntime.Must(v1alpha1.AddToScheme(scheme))
|
||||||
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
|
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
|
||||||
|
|
||||||
|
// v1 is in the config.k8s.io-suffixed API group
|
||||||
|
utilruntime.Must(v1.AddToScheme(scheme))
|
||||||
|
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion))
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,21 +21,15 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
const GroupName = "apiserver.k8s.io"
|
const LegacyGroupName = "apiserver.k8s.io"
|
||||||
|
const GroupName = "apiserver.config.k8s.io"
|
||||||
|
|
||||||
|
// LegacySchemeGroupVersion is group version used to register these objects
|
||||||
|
var LegacySchemeGroupVersion = schema.GroupVersion{Group: LegacyGroupName, Version: runtime.APIVersionInternal}
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
||||||
|
|
||||||
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
|
|
||||||
func Kind(kind string) schema.GroupKind {
|
|
||||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resource takes an unqualified resource and returns back a Group qualified GroupResource
|
|
||||||
func Resource(resource string) schema.GroupResource {
|
|
||||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||||
AddToScheme = SchemeBuilder.AddToScheme
|
AddToScheme = SchemeBuilder.AddToScheme
|
||||||
|
@ -43,6 +37,10 @@ var (
|
||||||
|
|
||||||
// Adds the list of known types to the given scheme.
|
// Adds the list of known types to the given scheme.
|
||||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||||
|
scheme.AddKnownTypes(LegacySchemeGroupVersion,
|
||||||
|
&AdmissionConfiguration{},
|
||||||
|
&EgressSelectorConfiguration{},
|
||||||
|
)
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
&AdmissionConfiguration{},
|
&AdmissionConfiguration{},
|
||||||
&EgressSelectorConfiguration{},
|
&EgressSelectorConfiguration{},
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=package
|
||||||
|
// +k8s:conversion-gen=k8s.io/apiserver/pkg/apis/apiserver
|
||||||
|
// +k8s:defaulter-gen=TypeMeta
|
||||||
|
// +groupName=apiserver.config.k8s.io
|
||||||
|
|
||||||
|
// Package v1 is the v1 version of the API.
|
||||||
|
package v1 // import "k8s.io/apiserver/pkg/apis/apiserver/v1"
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
const GroupName = "apiserver.config.k8s.io"
|
||||||
|
|
||||||
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
|
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
|
||||||
|
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
|
||||||
|
SchemeBuilder runtime.SchemeBuilder
|
||||||
|
localSchemeBuilder = &SchemeBuilder
|
||||||
|
AddToScheme = localSchemeBuilder.AddToScheme
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// We only register manually written functions here. The registration of the
|
||||||
|
// generated functions takes place in the generated files. The separation
|
||||||
|
// makes the code compile even when the generated files are missing.
|
||||||
|
localSchemeBuilder.Register(addKnownTypes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds the list of known types to the given scheme.
|
||||||
|
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||||
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
|
&AdmissionConfiguration{},
|
||||||
|
)
|
||||||
|
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
||||||
|
// AdmissionConfiguration provides versioned configuration for admission controllers.
|
||||||
|
type AdmissionConfiguration struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
|
||||||
|
// Plugins allows specifying a configuration per admission control plugin.
|
||||||
|
// +optional
|
||||||
|
Plugins []AdmissionPluginConfiguration `json:"plugins"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdmissionPluginConfiguration provides the configuration for a single plug-in.
|
||||||
|
type AdmissionPluginConfiguration struct {
|
||||||
|
// Name is the name of the admission controller.
|
||||||
|
// It must match the registered admission plugin name.
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Path is the path to a configuration file that contains the plugin's
|
||||||
|
// configuration
|
||||||
|
// +optional
|
||||||
|
Path string `json:"path"`
|
||||||
|
|
||||||
|
// Configuration is an embedded configuration object to be used as the plugin's
|
||||||
|
// configuration. If present, it will be used instead of the path to the configuration file.
|
||||||
|
// +optional
|
||||||
|
Configuration *runtime.Unknown `json:"configuration"`
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by conversion-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
unsafe "unsafe"
|
||||||
|
|
||||||
|
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||||
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
|
apiserver "k8s.io/apiserver/pkg/apis/apiserver"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
localSchemeBuilder.Register(RegisterConversions)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterConversions adds conversion functions to the given scheme.
|
||||||
|
// Public to allow building arbitrary schemes.
|
||||||
|
func RegisterConversions(s *runtime.Scheme) error {
|
||||||
|
if err := s.AddGeneratedConversionFunc((*AdmissionConfiguration)(nil), (*apiserver.AdmissionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||||
|
return Convert_v1_AdmissionConfiguration_To_apiserver_AdmissionConfiguration(a.(*AdmissionConfiguration), b.(*apiserver.AdmissionConfiguration), scope)
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := s.AddGeneratedConversionFunc((*apiserver.AdmissionConfiguration)(nil), (*AdmissionConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||||
|
return Convert_apiserver_AdmissionConfiguration_To_v1_AdmissionConfiguration(a.(*apiserver.AdmissionConfiguration), b.(*AdmissionConfiguration), scope)
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := s.AddGeneratedConversionFunc((*AdmissionPluginConfiguration)(nil), (*apiserver.AdmissionPluginConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||||
|
return Convert_v1_AdmissionPluginConfiguration_To_apiserver_AdmissionPluginConfiguration(a.(*AdmissionPluginConfiguration), b.(*apiserver.AdmissionPluginConfiguration), scope)
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := s.AddGeneratedConversionFunc((*apiserver.AdmissionPluginConfiguration)(nil), (*AdmissionPluginConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||||
|
return Convert_apiserver_AdmissionPluginConfiguration_To_v1_AdmissionPluginConfiguration(a.(*apiserver.AdmissionPluginConfiguration), b.(*AdmissionPluginConfiguration), scope)
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_v1_AdmissionConfiguration_To_apiserver_AdmissionConfiguration(in *AdmissionConfiguration, out *apiserver.AdmissionConfiguration, s conversion.Scope) error {
|
||||||
|
out.Plugins = *(*[]apiserver.AdmissionPluginConfiguration)(unsafe.Pointer(&in.Plugins))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_v1_AdmissionConfiguration_To_apiserver_AdmissionConfiguration is an autogenerated conversion function.
|
||||||
|
func Convert_v1_AdmissionConfiguration_To_apiserver_AdmissionConfiguration(in *AdmissionConfiguration, out *apiserver.AdmissionConfiguration, s conversion.Scope) error {
|
||||||
|
return autoConvert_v1_AdmissionConfiguration_To_apiserver_AdmissionConfiguration(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_apiserver_AdmissionConfiguration_To_v1_AdmissionConfiguration(in *apiserver.AdmissionConfiguration, out *AdmissionConfiguration, s conversion.Scope) error {
|
||||||
|
out.Plugins = *(*[]AdmissionPluginConfiguration)(unsafe.Pointer(&in.Plugins))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_apiserver_AdmissionConfiguration_To_v1_AdmissionConfiguration is an autogenerated conversion function.
|
||||||
|
func Convert_apiserver_AdmissionConfiguration_To_v1_AdmissionConfiguration(in *apiserver.AdmissionConfiguration, out *AdmissionConfiguration, s conversion.Scope) error {
|
||||||
|
return autoConvert_apiserver_AdmissionConfiguration_To_v1_AdmissionConfiguration(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_v1_AdmissionPluginConfiguration_To_apiserver_AdmissionPluginConfiguration(in *AdmissionPluginConfiguration, out *apiserver.AdmissionPluginConfiguration, s conversion.Scope) error {
|
||||||
|
out.Name = in.Name
|
||||||
|
out.Path = in.Path
|
||||||
|
out.Configuration = (*runtime.Unknown)(unsafe.Pointer(in.Configuration))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_v1_AdmissionPluginConfiguration_To_apiserver_AdmissionPluginConfiguration is an autogenerated conversion function.
|
||||||
|
func Convert_v1_AdmissionPluginConfiguration_To_apiserver_AdmissionPluginConfiguration(in *AdmissionPluginConfiguration, out *apiserver.AdmissionPluginConfiguration, s conversion.Scope) error {
|
||||||
|
return autoConvert_v1_AdmissionPluginConfiguration_To_apiserver_AdmissionPluginConfiguration(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func autoConvert_apiserver_AdmissionPluginConfiguration_To_v1_AdmissionPluginConfiguration(in *apiserver.AdmissionPluginConfiguration, out *AdmissionPluginConfiguration, s conversion.Scope) error {
|
||||||
|
out.Name = in.Name
|
||||||
|
out.Path = in.Path
|
||||||
|
out.Configuration = (*runtime.Unknown)(unsafe.Pointer(in.Configuration))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert_apiserver_AdmissionPluginConfiguration_To_v1_AdmissionPluginConfiguration is an autogenerated conversion function.
|
||||||
|
func Convert_apiserver_AdmissionPluginConfiguration_To_v1_AdmissionPluginConfiguration(in *apiserver.AdmissionPluginConfiguration, out *AdmissionPluginConfiguration, s conversion.Scope) error {
|
||||||
|
return autoConvert_apiserver_AdmissionPluginConfiguration_To_v1_AdmissionPluginConfiguration(in, out, s)
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AdmissionConfiguration) DeepCopyInto(out *AdmissionConfiguration) {
|
||||||
|
*out = *in
|
||||||
|
out.TypeMeta = in.TypeMeta
|
||||||
|
if in.Plugins != nil {
|
||||||
|
in, out := &in.Plugins, &out.Plugins
|
||||||
|
*out = make([]AdmissionPluginConfiguration, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmissionConfiguration.
|
||||||
|
func (in *AdmissionConfiguration) DeepCopy() *AdmissionConfiguration {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AdmissionConfiguration)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||||
|
func (in *AdmissionConfiguration) DeepCopyObject() runtime.Object {
|
||||||
|
if c := in.DeepCopy(); c != nil {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AdmissionPluginConfiguration) DeepCopyInto(out *AdmissionPluginConfiguration) {
|
||||||
|
*out = *in
|
||||||
|
if in.Configuration != nil {
|
||||||
|
in, out := &in.Configuration, &out.Configuration
|
||||||
|
*out = new(runtime.Unknown)
|
||||||
|
(*in).DeepCopyInto(*out)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmissionPluginConfiguration.
|
||||||
|
func (in *AdmissionPluginConfiguration) DeepCopy() *AdmissionPluginConfiguration {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AdmissionPluginConfiguration)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
// +build !ignore_autogenerated
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RegisterDefaults adds defaulters functions to the given scheme.
|
||||||
|
// Public to allow building arbitrary schemes.
|
||||||
|
// All generated defaulters are covering - they call all nested defaulters.
|
||||||
|
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -60,15 +60,12 @@ func ReadEgressSelectorConfiguration(configFilePath string) (*apiserver.EgressSe
|
||||||
if decodedConfig.Kind != "EgressSelectorConfiguration" {
|
if decodedConfig.Kind != "EgressSelectorConfiguration" {
|
||||||
return nil, fmt.Errorf("invalid service configuration object %q", decodedConfig.Kind)
|
return nil, fmt.Errorf("invalid service configuration object %q", decodedConfig.Kind)
|
||||||
}
|
}
|
||||||
config, err := cfgScheme.ConvertToVersion(&decodedConfig, apiserver.SchemeGroupVersion)
|
internalConfig := &apiserver.EgressSelectorConfiguration{}
|
||||||
if err != nil {
|
if err := cfgScheme.Convert(&decodedConfig, internalConfig, nil); err != nil {
|
||||||
// we got an error where the decode wasn't related to a missing type
|
// we got an error where the decode wasn't related to a missing type
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if internalConfig, ok := config.(*apiserver.EgressSelectorConfiguration); ok {
|
return internalConfig, nil
|
||||||
return internalConfig, nil
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("unable to convert %T to *apiserver.EgressSelectorConfiguration", config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateEgressSelectorConfiguration checks the apiserver.EgressSelectorConfiguration for
|
// ValidateEgressSelectorConfiguration checks the apiserver.EgressSelectorConfiguration for
|
||||||
|
|
|
@ -32,6 +32,7 @@ import (
|
||||||
mutatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/mutating"
|
mutatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/mutating"
|
||||||
validatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/validating"
|
validatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/validating"
|
||||||
apiserverapi "k8s.io/apiserver/pkg/apis/apiserver"
|
apiserverapi "k8s.io/apiserver/pkg/apis/apiserver"
|
||||||
|
apiserverapiv1 "k8s.io/apiserver/pkg/apis/apiserver/v1"
|
||||||
apiserverapiv1alpha1 "k8s.io/apiserver/pkg/apis/apiserver/v1alpha1"
|
apiserverapiv1alpha1 "k8s.io/apiserver/pkg/apis/apiserver/v1alpha1"
|
||||||
"k8s.io/apiserver/pkg/server"
|
"k8s.io/apiserver/pkg/server"
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
|
@ -45,6 +46,7 @@ var configScheme = runtime.NewScheme()
|
||||||
func init() {
|
func init() {
|
||||||
utilruntime.Must(apiserverapi.AddToScheme(configScheme))
|
utilruntime.Must(apiserverapi.AddToScheme(configScheme))
|
||||||
utilruntime.Must(apiserverapiv1alpha1.AddToScheme(configScheme))
|
utilruntime.Must(apiserverapiv1alpha1.AddToScheme(configScheme))
|
||||||
|
utilruntime.Must(apiserverapiv1.AddToScheme(configScheme))
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdmissionOptions holds the admission options
|
// AdmissionOptions holds the admission options
|
||||||
|
|
Loading…
Reference in New Issue