mirror of https://github.com/k3s-io/k3s
Remove settings
parent
efff75f045
commit
9422d1d788
|
@ -32,6 +32,5 @@ import (
|
||||||
_ "k8s.io/kubernetes/pkg/apis/policy/install"
|
_ "k8s.io/kubernetes/pkg/apis/policy/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/settings/install"
|
|
||||||
_ "k8s.io/kubernetes/pkg/apis/storage/install"
|
_ "k8s.io/kubernetes/pkg/apis/storage/install"
|
||||||
)
|
)
|
||||||
|
|
|
@ -85,7 +85,6 @@ rbac.authorization.k8s.io/v1beta1 \
|
||||||
scheduling.k8s.io/v1alpha1 \
|
scheduling.k8s.io/v1alpha1 \
|
||||||
scheduling.k8s.io/v1beta1 \
|
scheduling.k8s.io/v1beta1 \
|
||||||
scheduling.k8s.io/v1 \
|
scheduling.k8s.io/v1 \
|
||||||
settings.k8s.io/v1alpha1 \
|
|
||||||
storage.k8s.io/v1beta1 \
|
storage.k8s.io/v1beta1 \
|
||||||
storage.k8s.io/v1 \
|
storage.k8s.io/v1 \
|
||||||
}"
|
}"
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"doc.go",
|
|
||||||
"register.go",
|
|
||||||
"types.go",
|
|
||||||
"zz_generated.deepcopy.go",
|
|
||||||
],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/apis/settings",
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/core:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [
|
|
||||||
":package-srcs",
|
|
||||||
"//pkg/apis/settings/fuzzer:all-srcs",
|
|
||||||
"//pkg/apis/settings/install:all-srcs",
|
|
||||||
"//pkg/apis/settings/v1alpha1:all-srcs",
|
|
||||||
"//pkg/apis/settings/validation:all-srcs",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,20 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 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
|
|
||||||
// +groupName=settings.k8s.io
|
|
||||||
|
|
||||||
package settings // import "k8s.io/kubernetes/pkg/apis/settings"
|
|
|
@ -1,26 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["fuzzer.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/apis/settings/fuzzer",
|
|
||||||
deps = ["//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,26 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 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 fuzzer
|
|
||||||
|
|
||||||
import (
|
|
||||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Funcs returns the fuzzer functions for the settings api group.
|
|
||||||
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
|
||||||
return []interface{}{}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["install.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/apis/settings/install",
|
|
||||||
deps = [
|
|
||||||
"//pkg/api/legacyscheme:go_default_library",
|
|
||||||
"//pkg/apis/settings:go_default_library",
|
|
||||||
"//pkg/apis/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 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 install installs the settings API group, making it available as
|
|
||||||
// an option to all of the API encoding/decoding machinery.
|
|
||||||
package install
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/settings"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/settings/v1alpha1"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
Install(legacyscheme.Scheme)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Install registers the API group and adds types to a scheme
|
|
||||||
func Install(scheme *runtime.Scheme) {
|
|
||||||
utilruntime.Must(settings.AddToScheme(scheme))
|
|
||||||
utilruntime.Must(v1alpha1.AddToScheme(scheme))
|
|
||||||
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 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 settings
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
|
||||||
AddToScheme = SchemeBuilder.AddToScheme
|
|
||||||
)
|
|
||||||
|
|
||||||
// GroupName is the group name use in this package
|
|
||||||
const GroupName = "settings.k8s.io"
|
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
|
||||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
|
||||||
|
|
||||||
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
|
||||||
func Kind(kind string) schema.GroupKind {
|
|
||||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
|
||||||
func Resource(resource string) schema.GroupResource {
|
|
||||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds the list of known types to the given scheme.
|
|
||||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
|
||||||
&PodPreset{},
|
|
||||||
&PodPresetList{},
|
|
||||||
)
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 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 settings
|
|
||||||
|
|
||||||
import (
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
)
|
|
||||||
|
|
||||||
// +genclient
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
|
||||||
|
|
||||||
// PodPreset is a policy resource that defines additional runtime
|
|
||||||
// requirements for a Pod.
|
|
||||||
type PodPreset struct {
|
|
||||||
metav1.TypeMeta
|
|
||||||
// +optional
|
|
||||||
metav1.ObjectMeta
|
|
||||||
|
|
||||||
// +optional
|
|
||||||
Spec PodPresetSpec
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodPresetSpec is a description of a pod preset.
|
|
||||||
type PodPresetSpec struct {
|
|
||||||
// Selector is a label query over a set of resources, in this case pods.
|
|
||||||
// Required.
|
|
||||||
Selector metav1.LabelSelector
|
|
||||||
// Env defines the collection of EnvVar to inject into containers.
|
|
||||||
// +optional
|
|
||||||
Env []api.EnvVar
|
|
||||||
// EnvFrom defines the collection of EnvFromSource to inject into containers.
|
|
||||||
// +optional
|
|
||||||
EnvFrom []api.EnvFromSource
|
|
||||||
// Volumes defines the collection of Volume to inject into the pod.
|
|
||||||
// +optional
|
|
||||||
Volumes []api.Volume
|
|
||||||
// VolumeMounts defines the collection of VolumeMount to inject into containers.
|
|
||||||
// +optional
|
|
||||||
VolumeMounts []api.VolumeMount
|
|
||||||
}
|
|
||||||
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
|
||||||
|
|
||||||
// PodPresetList is a list of PodPreset objects.
|
|
||||||
type PodPresetList struct {
|
|
||||||
metav1.TypeMeta
|
|
||||||
// +optional
|
|
||||||
metav1.ListMeta
|
|
||||||
|
|
||||||
Items []PodPreset
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"doc.go",
|
|
||||||
"register.go",
|
|
||||||
"zz_generated.conversion.go",
|
|
||||||
"zz_generated.defaults.go",
|
|
||||||
],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/apis/settings/v1alpha1",
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/core:go_default_library",
|
|
||||||
"//pkg/apis/core/v1:go_default_library",
|
|
||||||
"//pkg/apis/settings:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 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:conversion-gen=k8s.io/kubernetes/pkg/apis/settings
|
|
||||||
// +k8s:conversion-gen-external-types=k8s.io/api/settings/v1alpha1
|
|
||||||
// +k8s:defaulter-gen=TypeMeta
|
|
||||||
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/settings/v1alpha1
|
|
||||||
|
|
||||||
// +groupName=settings.k8s.io
|
|
||||||
|
|
||||||
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/settings/v1alpha1"
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GroupName is the group name use in this package
|
|
||||||
const GroupName = "settings.k8s.io"
|
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
|
||||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
|
|
||||||
|
|
||||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
|
||||||
func Resource(resource string) schema.GroupResource {
|
|
||||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
localSchemeBuilder = &settingsv1alpha1.SchemeBuilder
|
|
||||||
// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
|
|
||||||
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(RegisterDefaults)
|
|
||||||
}
|
|
|
@ -1,190 +0,0 @@
|
||||||
// +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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
unsafe "unsafe"
|
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
v1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
core "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
settings "k8s.io/kubernetes/pkg/apis/settings"
|
|
||||||
)
|
|
||||||
|
|
||||||
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((*v1alpha1.PodPreset)(nil), (*settings.PodPreset)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_v1alpha1_PodPreset_To_settings_PodPreset(a.(*v1alpha1.PodPreset), b.(*settings.PodPreset), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*settings.PodPreset)(nil), (*v1alpha1.PodPreset)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_settings_PodPreset_To_v1alpha1_PodPreset(a.(*settings.PodPreset), b.(*v1alpha1.PodPreset), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.PodPresetList)(nil), (*settings.PodPresetList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_v1alpha1_PodPresetList_To_settings_PodPresetList(a.(*v1alpha1.PodPresetList), b.(*settings.PodPresetList), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*settings.PodPresetList)(nil), (*v1alpha1.PodPresetList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_settings_PodPresetList_To_v1alpha1_PodPresetList(a.(*settings.PodPresetList), b.(*v1alpha1.PodPresetList), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.PodPresetSpec)(nil), (*settings.PodPresetSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_v1alpha1_PodPresetSpec_To_settings_PodPresetSpec(a.(*v1alpha1.PodPresetSpec), b.(*settings.PodPresetSpec), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*settings.PodPresetSpec)(nil), (*v1alpha1.PodPresetSpec)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_settings_PodPresetSpec_To_v1alpha1_PodPresetSpec(a.(*settings.PodPresetSpec), b.(*v1alpha1.PodPresetSpec), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_v1alpha1_PodPreset_To_settings_PodPreset(in *v1alpha1.PodPreset, out *settings.PodPreset, s conversion.Scope) error {
|
|
||||||
out.ObjectMeta = in.ObjectMeta
|
|
||||||
if err := Convert_v1alpha1_PodPresetSpec_To_settings_PodPresetSpec(&in.Spec, &out.Spec, s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_v1alpha1_PodPreset_To_settings_PodPreset is an autogenerated conversion function.
|
|
||||||
func Convert_v1alpha1_PodPreset_To_settings_PodPreset(in *v1alpha1.PodPreset, out *settings.PodPreset, s conversion.Scope) error {
|
|
||||||
return autoConvert_v1alpha1_PodPreset_To_settings_PodPreset(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_settings_PodPreset_To_v1alpha1_PodPreset(in *settings.PodPreset, out *v1alpha1.PodPreset, s conversion.Scope) error {
|
|
||||||
out.ObjectMeta = in.ObjectMeta
|
|
||||||
if err := Convert_settings_PodPresetSpec_To_v1alpha1_PodPresetSpec(&in.Spec, &out.Spec, s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_settings_PodPreset_To_v1alpha1_PodPreset is an autogenerated conversion function.
|
|
||||||
func Convert_settings_PodPreset_To_v1alpha1_PodPreset(in *settings.PodPreset, out *v1alpha1.PodPreset, s conversion.Scope) error {
|
|
||||||
return autoConvert_settings_PodPreset_To_v1alpha1_PodPreset(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_v1alpha1_PodPresetList_To_settings_PodPresetList(in *v1alpha1.PodPresetList, out *settings.PodPresetList, s conversion.Scope) error {
|
|
||||||
out.ListMeta = in.ListMeta
|
|
||||||
if in.Items != nil {
|
|
||||||
in, out := &in.Items, &out.Items
|
|
||||||
*out = make([]settings.PodPreset, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
if err := Convert_v1alpha1_PodPreset_To_settings_PodPreset(&(*in)[i], &(*out)[i], s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.Items = nil
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_v1alpha1_PodPresetList_To_settings_PodPresetList is an autogenerated conversion function.
|
|
||||||
func Convert_v1alpha1_PodPresetList_To_settings_PodPresetList(in *v1alpha1.PodPresetList, out *settings.PodPresetList, s conversion.Scope) error {
|
|
||||||
return autoConvert_v1alpha1_PodPresetList_To_settings_PodPresetList(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_settings_PodPresetList_To_v1alpha1_PodPresetList(in *settings.PodPresetList, out *v1alpha1.PodPresetList, s conversion.Scope) error {
|
|
||||||
out.ListMeta = in.ListMeta
|
|
||||||
if in.Items != nil {
|
|
||||||
in, out := &in.Items, &out.Items
|
|
||||||
*out = make([]v1alpha1.PodPreset, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
if err := Convert_settings_PodPreset_To_v1alpha1_PodPreset(&(*in)[i], &(*out)[i], s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.Items = nil
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_settings_PodPresetList_To_v1alpha1_PodPresetList is an autogenerated conversion function.
|
|
||||||
func Convert_settings_PodPresetList_To_v1alpha1_PodPresetList(in *settings.PodPresetList, out *v1alpha1.PodPresetList, s conversion.Scope) error {
|
|
||||||
return autoConvert_settings_PodPresetList_To_v1alpha1_PodPresetList(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_v1alpha1_PodPresetSpec_To_settings_PodPresetSpec(in *v1alpha1.PodPresetSpec, out *settings.PodPresetSpec, s conversion.Scope) error {
|
|
||||||
out.Selector = in.Selector
|
|
||||||
out.Env = *(*[]core.EnvVar)(unsafe.Pointer(&in.Env))
|
|
||||||
out.EnvFrom = *(*[]core.EnvFromSource)(unsafe.Pointer(&in.EnvFrom))
|
|
||||||
if in.Volumes != nil {
|
|
||||||
in, out := &in.Volumes, &out.Volumes
|
|
||||||
*out = make([]core.Volume, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
// TODO: Inefficient conversion - can we improve it?
|
|
||||||
if err := s.Convert(&(*in)[i], &(*out)[i], 0); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.Volumes = nil
|
|
||||||
}
|
|
||||||
out.VolumeMounts = *(*[]core.VolumeMount)(unsafe.Pointer(&in.VolumeMounts))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_v1alpha1_PodPresetSpec_To_settings_PodPresetSpec is an autogenerated conversion function.
|
|
||||||
func Convert_v1alpha1_PodPresetSpec_To_settings_PodPresetSpec(in *v1alpha1.PodPresetSpec, out *settings.PodPresetSpec, s conversion.Scope) error {
|
|
||||||
return autoConvert_v1alpha1_PodPresetSpec_To_settings_PodPresetSpec(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_settings_PodPresetSpec_To_v1alpha1_PodPresetSpec(in *settings.PodPresetSpec, out *v1alpha1.PodPresetSpec, s conversion.Scope) error {
|
|
||||||
out.Selector = in.Selector
|
|
||||||
out.Env = *(*[]v1.EnvVar)(unsafe.Pointer(&in.Env))
|
|
||||||
out.EnvFrom = *(*[]v1.EnvFromSource)(unsafe.Pointer(&in.EnvFrom))
|
|
||||||
if in.Volumes != nil {
|
|
||||||
in, out := &in.Volumes, &out.Volumes
|
|
||||||
*out = make([]v1.Volume, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
// TODO: Inefficient conversion - can we improve it?
|
|
||||||
if err := s.Convert(&(*in)[i], &(*out)[i], 0); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.Volumes = nil
|
|
||||||
}
|
|
||||||
out.VolumeMounts = *(*[]v1.VolumeMount)(unsafe.Pointer(&in.VolumeMounts))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_settings_PodPresetSpec_To_v1alpha1_PodPresetSpec is an autogenerated conversion function.
|
|
||||||
func Convert_settings_PodPresetSpec_To_v1alpha1_PodPresetSpec(in *settings.PodPresetSpec, out *v1alpha1.PodPresetSpec, s conversion.Scope) error {
|
|
||||||
return autoConvert_settings_PodPresetSpec_To_v1alpha1_PodPresetSpec(in, out, s)
|
|
||||||
}
|
|
|
@ -1,105 +0,0 @@
|
||||||
// +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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
v1 "k8s.io/kubernetes/pkg/apis/core/v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 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 {
|
|
||||||
scheme.AddTypeDefaultingFunc(&v1alpha1.PodPreset{}, func(obj interface{}) { SetObjectDefaults_PodPreset(obj.(*v1alpha1.PodPreset)) })
|
|
||||||
scheme.AddTypeDefaultingFunc(&v1alpha1.PodPresetList{}, func(obj interface{}) { SetObjectDefaults_PodPresetList(obj.(*v1alpha1.PodPresetList)) })
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetObjectDefaults_PodPreset(in *v1alpha1.PodPreset) {
|
|
||||||
for i := range in.Spec.Env {
|
|
||||||
a := &in.Spec.Env[i]
|
|
||||||
if a.ValueFrom != nil {
|
|
||||||
if a.ValueFrom.FieldRef != nil {
|
|
||||||
v1.SetDefaults_ObjectFieldSelector(a.ValueFrom.FieldRef)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i := range in.Spec.Volumes {
|
|
||||||
a := &in.Spec.Volumes[i]
|
|
||||||
v1.SetDefaults_Volume(a)
|
|
||||||
if a.VolumeSource.HostPath != nil {
|
|
||||||
v1.SetDefaults_HostPathVolumeSource(a.VolumeSource.HostPath)
|
|
||||||
}
|
|
||||||
if a.VolumeSource.Secret != nil {
|
|
||||||
v1.SetDefaults_SecretVolumeSource(a.VolumeSource.Secret)
|
|
||||||
}
|
|
||||||
if a.VolumeSource.ISCSI != nil {
|
|
||||||
v1.SetDefaults_ISCSIVolumeSource(a.VolumeSource.ISCSI)
|
|
||||||
}
|
|
||||||
if a.VolumeSource.RBD != nil {
|
|
||||||
v1.SetDefaults_RBDVolumeSource(a.VolumeSource.RBD)
|
|
||||||
}
|
|
||||||
if a.VolumeSource.DownwardAPI != nil {
|
|
||||||
v1.SetDefaults_DownwardAPIVolumeSource(a.VolumeSource.DownwardAPI)
|
|
||||||
for j := range a.VolumeSource.DownwardAPI.Items {
|
|
||||||
b := &a.VolumeSource.DownwardAPI.Items[j]
|
|
||||||
if b.FieldRef != nil {
|
|
||||||
v1.SetDefaults_ObjectFieldSelector(b.FieldRef)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if a.VolumeSource.ConfigMap != nil {
|
|
||||||
v1.SetDefaults_ConfigMapVolumeSource(a.VolumeSource.ConfigMap)
|
|
||||||
}
|
|
||||||
if a.VolumeSource.AzureDisk != nil {
|
|
||||||
v1.SetDefaults_AzureDiskVolumeSource(a.VolumeSource.AzureDisk)
|
|
||||||
}
|
|
||||||
if a.VolumeSource.Projected != nil {
|
|
||||||
v1.SetDefaults_ProjectedVolumeSource(a.VolumeSource.Projected)
|
|
||||||
for j := range a.VolumeSource.Projected.Sources {
|
|
||||||
b := &a.VolumeSource.Projected.Sources[j]
|
|
||||||
if b.DownwardAPI != nil {
|
|
||||||
for k := range b.DownwardAPI.Items {
|
|
||||||
c := &b.DownwardAPI.Items[k]
|
|
||||||
if c.FieldRef != nil {
|
|
||||||
v1.SetDefaults_ObjectFieldSelector(c.FieldRef)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if b.ServiceAccountToken != nil {
|
|
||||||
v1.SetDefaults_ServiceAccountTokenProjection(b.ServiceAccountToken)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if a.VolumeSource.ScaleIO != nil {
|
|
||||||
v1.SetDefaults_ScaleIOVolumeSource(a.VolumeSource.ScaleIO)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetObjectDefaults_PodPresetList(in *v1alpha1.PodPresetList) {
|
|
||||||
for i := range in.Items {
|
|
||||||
a := &in.Items[i]
|
|
||||||
SetObjectDefaults_PodPreset(a)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
"go_test",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_test(
|
|
||||||
name = "go_default_test",
|
|
||||||
srcs = ["validation_test.go"],
|
|
||||||
embed = [":go_default_library"],
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/core:go_default_library",
|
|
||||||
"//pkg/apis/settings:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["validation.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/apis/settings/validation",
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/core/validation:go_default_library",
|
|
||||||
"//pkg/apis/settings:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/validation:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/validation:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 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 validation
|
|
||||||
|
|
||||||
import (
|
|
||||||
apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation"
|
|
||||||
unversionedvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
|
||||||
apivalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/settings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ValidatePodPresetName can be used to check whether the given PodPreset name is valid.
|
|
||||||
// Prefix indicates this name will be used as part of generation, in which case
|
|
||||||
// trailing dashes are allowed.
|
|
||||||
func ValidatePodPresetName(name string, prefix bool) []string {
|
|
||||||
// TODO: Validate that there's name for the suffix inserted by the pods.
|
|
||||||
// Currently this is just "-index". In the future we may allow a user
|
|
||||||
// specified list of suffixes and we need to validate the longest one.
|
|
||||||
return apimachineryvalidation.NameIsDNSSubdomain(name, prefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidatePodPresetSpec tests if required fields in the PodPreset spec are set.
|
|
||||||
func ValidatePodPresetSpec(spec *settings.PodPresetSpec, fldPath *field.Path) field.ErrorList {
|
|
||||||
allErrs := field.ErrorList{}
|
|
||||||
|
|
||||||
allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(&spec.Selector, fldPath.Child("selector"))...)
|
|
||||||
|
|
||||||
if spec.Env == nil && spec.EnvFrom == nil && spec.VolumeMounts == nil && spec.Volumes == nil {
|
|
||||||
allErrs = append(allErrs, field.Required(fldPath.Child("volumes", "env", "envFrom", "volumeMounts"), "must specify at least one"))
|
|
||||||
}
|
|
||||||
|
|
||||||
vols, vErrs := apivalidation.ValidateVolumes(spec.Volumes, fldPath.Child("volumes"))
|
|
||||||
allErrs = append(allErrs, vErrs...)
|
|
||||||
allErrs = append(allErrs, apivalidation.ValidateEnv(spec.Env, fldPath.Child("env"))...)
|
|
||||||
allErrs = append(allErrs, apivalidation.ValidateEnvFrom(spec.EnvFrom, fldPath.Child("envFrom"))...)
|
|
||||||
allErrs = append(allErrs, apivalidation.ValidateVolumeMounts(spec.VolumeMounts, nil, vols, nil, fldPath.Child("volumeMounts"))...)
|
|
||||||
|
|
||||||
return allErrs
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidatePodPreset validates a PodPreset.
|
|
||||||
func ValidatePodPreset(pip *settings.PodPreset) field.ErrorList {
|
|
||||||
allErrs := apivalidation.ValidateObjectMeta(&pip.ObjectMeta, true, ValidatePodPresetName, field.NewPath("metadata"))
|
|
||||||
allErrs = append(allErrs, ValidatePodPresetSpec(&pip.Spec, field.NewPath("spec"))...)
|
|
||||||
return allErrs
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidatePodPresetUpdate tests if required fields in the PodPreset are set.
|
|
||||||
func ValidatePodPresetUpdate(pip, oldPip *settings.PodPreset) field.ErrorList {
|
|
||||||
allErrs := apivalidation.ValidateObjectMetaUpdate(&pip.ObjectMeta, &oldPip.ObjectMeta, field.NewPath("metadata"))
|
|
||||||
allErrs = append(allErrs, ValidatePodPresetSpec(&pip.Spec, field.NewPath("spec"))...)
|
|
||||||
|
|
||||||
return allErrs
|
|
||||||
}
|
|
|
@ -1,190 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 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 validation
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/settings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestValidateEmptyPodPreset(t *testing.T) {
|
|
||||||
emptyPodPreset := &settings.PodPreset{
|
|
||||||
Spec: settings.PodPresetSpec{},
|
|
||||||
}
|
|
||||||
|
|
||||||
errList := ValidatePodPreset(emptyPodPreset)
|
|
||||||
if errList == nil {
|
|
||||||
t.Fatal("empty pod preset should return an error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestValidateEmptyPodPresetItems(t *testing.T) {
|
|
||||||
emptyPodPreset := &settings.PodPreset{
|
|
||||||
ObjectMeta: v1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "sample",
|
|
||||||
},
|
|
||||||
Spec: settings.PodPresetSpec{
|
|
||||||
Selector: v1.LabelSelector{
|
|
||||||
MatchExpressions: []v1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: v1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
errList := ValidatePodPreset(emptyPodPreset)
|
|
||||||
if !strings.Contains(errList.ToAggregate().Error(), "must specify at least one") {
|
|
||||||
t.Fatal("empty pod preset with label selector should return an error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestValidatePodPresets(t *testing.T) {
|
|
||||||
p := &settings.PodPreset{
|
|
||||||
ObjectMeta: v1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "sample",
|
|
||||||
},
|
|
||||||
Spec: settings.PodPresetSpec{
|
|
||||||
Selector: v1.LabelSelector{
|
|
||||||
MatchExpressions: []v1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: v1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
|
|
||||||
Env: []api.EnvVar{{Name: "abc", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
EnvFrom: []api.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
errList := ValidatePodPreset(p)
|
|
||||||
if errList != nil {
|
|
||||||
if errList.ToAggregate() != nil {
|
|
||||||
t.Fatalf("errors: %#v", errList.ToAggregate().Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p = &settings.PodPreset{
|
|
||||||
ObjectMeta: v1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "sample",
|
|
||||||
},
|
|
||||||
Spec: settings.PodPresetSpec{
|
|
||||||
Selector: v1.LabelSelector{
|
|
||||||
MatchExpressions: []v1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: v1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
|
|
||||||
Env: []api.EnvVar{{Name: "abc", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
VolumeMounts: []api.VolumeMount{
|
|
||||||
{Name: "vol", MountPath: "/foo"},
|
|
||||||
},
|
|
||||||
EnvFrom: []api.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
errList = ValidatePodPreset(p)
|
|
||||||
if errList != nil {
|
|
||||||
if errList.ToAggregate() != nil {
|
|
||||||
t.Fatalf("errors: %#v", errList.ToAggregate().Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestValidatePodPresetsiVolumeMountError(t *testing.T) {
|
|
||||||
p := &settings.PodPreset{
|
|
||||||
ObjectMeta: v1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "sample",
|
|
||||||
},
|
|
||||||
Spec: settings.PodPresetSpec{
|
|
||||||
Selector: v1.LabelSelector{
|
|
||||||
MatchExpressions: []v1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: v1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
|
|
||||||
VolumeMounts: []api.VolumeMount{
|
|
||||||
{Name: "dne", MountPath: "/foo"},
|
|
||||||
},
|
|
||||||
Env: []api.EnvVar{{Name: "abc", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
EnvFrom: []api.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
errList := ValidatePodPreset(p)
|
|
||||||
if !strings.Contains(errList.ToAggregate().Error(), "spec.volumeMounts[0].name: Not found") {
|
|
||||||
t.Fatal("should have returned error for volume that does not exist")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,131 +0,0 @@
|
||||||
// +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 settings
|
|
||||||
|
|
||||||
import (
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
core "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
||||||
func (in *PodPreset) DeepCopyInto(out *PodPreset) {
|
|
||||||
*out = *in
|
|
||||||
out.TypeMeta = in.TypeMeta
|
|
||||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
|
||||||
in.Spec.DeepCopyInto(&out.Spec)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodPreset.
|
|
||||||
func (in *PodPreset) DeepCopy() *PodPreset {
|
|
||||||
if in == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
out := new(PodPreset)
|
|
||||||
in.DeepCopyInto(out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
||||||
func (in *PodPreset) 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 *PodPresetList) DeepCopyInto(out *PodPresetList) {
|
|
||||||
*out = *in
|
|
||||||
out.TypeMeta = in.TypeMeta
|
|
||||||
out.ListMeta = in.ListMeta
|
|
||||||
if in.Items != nil {
|
|
||||||
in, out := &in.Items, &out.Items
|
|
||||||
*out = make([]PodPreset, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodPresetList.
|
|
||||||
func (in *PodPresetList) DeepCopy() *PodPresetList {
|
|
||||||
if in == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
out := new(PodPresetList)
|
|
||||||
in.DeepCopyInto(out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
||||||
func (in *PodPresetList) 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 *PodPresetSpec) DeepCopyInto(out *PodPresetSpec) {
|
|
||||||
*out = *in
|
|
||||||
in.Selector.DeepCopyInto(&out.Selector)
|
|
||||||
if in.Env != nil {
|
|
||||||
in, out := &in.Env, &out.Env
|
|
||||||
*out = make([]core.EnvVar, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if in.EnvFrom != nil {
|
|
||||||
in, out := &in.EnvFrom, &out.EnvFrom
|
|
||||||
*out = make([]core.EnvFromSource, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if in.Volumes != nil {
|
|
||||||
in, out := &in.Volumes, &out.Volumes
|
|
||||||
*out = make([]core.Volume, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if in.VolumeMounts != nil {
|
|
||||||
in, out := &in.VolumeMounts, &out.VolumeMounts
|
|
||||||
*out = make([]core.VolumeMount, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodPresetSpec.
|
|
||||||
func (in *PodPresetSpec) DeepCopy() *PodPresetSpec {
|
|
||||||
if in == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
out := new(PodPresetSpec)
|
|
||||||
in.DeepCopyInto(out)
|
|
||||||
return out
|
|
||||||
}
|
|
|
@ -38,7 +38,6 @@ import (
|
||||||
policyinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/policy/internalversion"
|
policyinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/policy/internalversion"
|
||||||
rbacinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/rbac/internalversion"
|
rbacinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/rbac/internalversion"
|
||||||
schedulinginternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/scheduling/internalversion"
|
schedulinginternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/scheduling/internalversion"
|
||||||
settingsinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/settings/internalversion"
|
|
||||||
storageinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/storage/internalversion"
|
storageinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/storage/internalversion"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,7 +59,6 @@ type Interface interface {
|
||||||
Policy() policyinternalversion.PolicyInterface
|
Policy() policyinternalversion.PolicyInterface
|
||||||
Rbac() rbacinternalversion.RbacInterface
|
Rbac() rbacinternalversion.RbacInterface
|
||||||
Scheduling() schedulinginternalversion.SchedulingInterface
|
Scheduling() schedulinginternalversion.SchedulingInterface
|
||||||
Settings() settingsinternalversion.SettingsInterface
|
|
||||||
Storage() storageinternalversion.StorageInterface
|
Storage() storageinternalversion.StorageInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +82,6 @@ type Clientset struct {
|
||||||
policy *policyinternalversion.PolicyClient
|
policy *policyinternalversion.PolicyClient
|
||||||
rbac *rbacinternalversion.RbacClient
|
rbac *rbacinternalversion.RbacClient
|
||||||
scheduling *schedulinginternalversion.SchedulingClient
|
scheduling *schedulinginternalversion.SchedulingClient
|
||||||
settings *settingsinternalversion.SettingsClient
|
|
||||||
storage *storageinternalversion.StorageClient
|
storage *storageinternalversion.StorageClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,11 +165,6 @@ func (c *Clientset) Scheduling() schedulinginternalversion.SchedulingInterface {
|
||||||
return c.scheduling
|
return c.scheduling
|
||||||
}
|
}
|
||||||
|
|
||||||
// Settings retrieves the SettingsClient
|
|
||||||
func (c *Clientset) Settings() settingsinternalversion.SettingsInterface {
|
|
||||||
return c.settings
|
|
||||||
}
|
|
||||||
|
|
||||||
// Storage retrieves the StorageClient
|
// Storage retrieves the StorageClient
|
||||||
func (c *Clientset) Storage() storageinternalversion.StorageInterface {
|
func (c *Clientset) Storage() storageinternalversion.StorageInterface {
|
||||||
return c.storage
|
return c.storage
|
||||||
|
@ -258,10 +250,6 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cs.settings, err = settingsinternalversion.NewForConfig(&configShallowCopy)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
cs.storage, err = storageinternalversion.NewForConfig(&configShallowCopy)
|
cs.storage, err = storageinternalversion.NewForConfig(&configShallowCopy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -294,7 +282,6 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||||
cs.policy = policyinternalversion.NewForConfigOrDie(c)
|
cs.policy = policyinternalversion.NewForConfigOrDie(c)
|
||||||
cs.rbac = rbacinternalversion.NewForConfigOrDie(c)
|
cs.rbac = rbacinternalversion.NewForConfigOrDie(c)
|
||||||
cs.scheduling = schedulinginternalversion.NewForConfigOrDie(c)
|
cs.scheduling = schedulinginternalversion.NewForConfigOrDie(c)
|
||||||
cs.settings = settingsinternalversion.NewForConfigOrDie(c)
|
|
||||||
cs.storage = storageinternalversion.NewForConfigOrDie(c)
|
cs.storage = storageinternalversion.NewForConfigOrDie(c)
|
||||||
|
|
||||||
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
|
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
|
||||||
|
@ -320,7 +307,6 @@ func New(c rest.Interface) *Clientset {
|
||||||
cs.policy = policyinternalversion.New(c)
|
cs.policy = policyinternalversion.New(c)
|
||||||
cs.rbac = rbacinternalversion.New(c)
|
cs.rbac = rbacinternalversion.New(c)
|
||||||
cs.scheduling = schedulinginternalversion.New(c)
|
cs.scheduling = schedulinginternalversion.New(c)
|
||||||
cs.settings = settingsinternalversion.New(c)
|
|
||||||
cs.storage = storageinternalversion.New(c)
|
cs.storage = storageinternalversion.New(c)
|
||||||
|
|
||||||
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
|
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
|
||||||
|
|
|
@ -57,8 +57,6 @@ import (
|
||||||
fakerbacinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/rbac/internalversion/fake"
|
fakerbacinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/rbac/internalversion/fake"
|
||||||
schedulinginternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/scheduling/internalversion"
|
schedulinginternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/scheduling/internalversion"
|
||||||
fakeschedulinginternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/scheduling/internalversion/fake"
|
fakeschedulinginternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/scheduling/internalversion/fake"
|
||||||
settingsinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/settings/internalversion"
|
|
||||||
fakesettingsinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/settings/internalversion/fake"
|
|
||||||
storageinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/storage/internalversion"
|
storageinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/storage/internalversion"
|
||||||
fakestorageinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/storage/internalversion/fake"
|
fakestorageinternalversion "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/storage/internalversion/fake"
|
||||||
)
|
)
|
||||||
|
@ -185,11 +183,6 @@ func (c *Clientset) Scheduling() schedulinginternalversion.SchedulingInterface {
|
||||||
return &fakeschedulinginternalversion.FakeScheduling{Fake: &c.Fake}
|
return &fakeschedulinginternalversion.FakeScheduling{Fake: &c.Fake}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Settings retrieves the SettingsClient
|
|
||||||
func (c *Clientset) Settings() settingsinternalversion.SettingsInterface {
|
|
||||||
return &fakesettingsinternalversion.FakeSettings{Fake: &c.Fake}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Storage retrieves the StorageClient
|
// Storage retrieves the StorageClient
|
||||||
func (c *Clientset) Storage() storageinternalversion.StorageInterface {
|
func (c *Clientset) Storage() storageinternalversion.StorageInterface {
|
||||||
return &fakestorageinternalversion.FakeStorage{Fake: &c.Fake}
|
return &fakestorageinternalversion.FakeStorage{Fake: &c.Fake}
|
||||||
|
|
|
@ -40,7 +40,6 @@ import (
|
||||||
policyinternalversion "k8s.io/kubernetes/pkg/apis/policy"
|
policyinternalversion "k8s.io/kubernetes/pkg/apis/policy"
|
||||||
rbacinternalversion "k8s.io/kubernetes/pkg/apis/rbac"
|
rbacinternalversion "k8s.io/kubernetes/pkg/apis/rbac"
|
||||||
schedulinginternalversion "k8s.io/kubernetes/pkg/apis/scheduling"
|
schedulinginternalversion "k8s.io/kubernetes/pkg/apis/scheduling"
|
||||||
settingsinternalversion "k8s.io/kubernetes/pkg/apis/settings"
|
|
||||||
storageinternalversion "k8s.io/kubernetes/pkg/apis/storage"
|
storageinternalversion "k8s.io/kubernetes/pkg/apis/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -64,7 +63,6 @@ var localSchemeBuilder = runtime.SchemeBuilder{
|
||||||
policyinternalversion.AddToScheme,
|
policyinternalversion.AddToScheme,
|
||||||
rbacinternalversion.AddToScheme,
|
rbacinternalversion.AddToScheme,
|
||||||
schedulinginternalversion.AddToScheme,
|
schedulinginternalversion.AddToScheme,
|
||||||
settingsinternalversion.AddToScheme,
|
|
||||||
storageinternalversion.AddToScheme,
|
storageinternalversion.AddToScheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ import (
|
||||||
policy "k8s.io/kubernetes/pkg/apis/policy/install"
|
policy "k8s.io/kubernetes/pkg/apis/policy/install"
|
||||||
rbac "k8s.io/kubernetes/pkg/apis/rbac/install"
|
rbac "k8s.io/kubernetes/pkg/apis/rbac/install"
|
||||||
scheduling "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
scheduling "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
||||||
settings "k8s.io/kubernetes/pkg/apis/settings/install"
|
|
||||||
storage "k8s.io/kubernetes/pkg/apis/storage/install"
|
storage "k8s.io/kubernetes/pkg/apis/storage/install"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,6 +69,5 @@ func Install(scheme *runtime.Scheme) {
|
||||||
policy.Install(scheme)
|
policy.Install(scheme)
|
||||||
rbac.Install(scheme)
|
rbac.Install(scheme)
|
||||||
scheduling.Install(scheme)
|
scheduling.Install(scheme)
|
||||||
settings.Install(scheme)
|
|
||||||
storage.Install(scheme)
|
storage.Install(scheme)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ import (
|
||||||
"k8s.io/kubernetes/plugin/pkg/admission/noderestriction"
|
"k8s.io/kubernetes/plugin/pkg/admission/noderestriction"
|
||||||
"k8s.io/kubernetes/plugin/pkg/admission/nodetaint"
|
"k8s.io/kubernetes/plugin/pkg/admission/nodetaint"
|
||||||
"k8s.io/kubernetes/plugin/pkg/admission/podnodeselector"
|
"k8s.io/kubernetes/plugin/pkg/admission/podnodeselector"
|
||||||
"k8s.io/kubernetes/plugin/pkg/admission/podpreset"
|
|
||||||
"k8s.io/kubernetes/plugin/pkg/admission/podtolerationrestriction"
|
"k8s.io/kubernetes/plugin/pkg/admission/podtolerationrestriction"
|
||||||
podpriority "k8s.io/kubernetes/plugin/pkg/admission/priority"
|
podpriority "k8s.io/kubernetes/plugin/pkg/admission/priority"
|
||||||
"k8s.io/kubernetes/plugin/pkg/admission/resourcequota"
|
"k8s.io/kubernetes/plugin/pkg/admission/resourcequota"
|
||||||
|
@ -65,7 +64,6 @@ var AllOrderedPlugins = []string{
|
||||||
exists.PluginName, // NamespaceExists
|
exists.PluginName, // NamespaceExists
|
||||||
scdeny.PluginName, // SecurityContextDeny
|
scdeny.PluginName, // SecurityContextDeny
|
||||||
antiaffinity.PluginName, // LimitPodHardAntiAffinityTopology
|
antiaffinity.PluginName, // LimitPodHardAntiAffinityTopology
|
||||||
podpreset.PluginName, // PodPreset
|
|
||||||
limitranger.PluginName, // LimitRanger
|
limitranger.PluginName, // LimitRanger
|
||||||
serviceaccount.PluginName, // ServiceAccount
|
serviceaccount.PluginName, // ServiceAccount
|
||||||
noderestriction.PluginName, // NodeRestriction
|
noderestriction.PluginName, // NodeRestriction
|
||||||
|
@ -110,7 +108,6 @@ func RegisterAllAdmissionPlugins(plugins *admission.Plugins) {
|
||||||
nodetaint.Register(plugins)
|
nodetaint.Register(plugins)
|
||||||
label.Register(plugins) // DEPRECATED, future PVs should not rely on labels for zone topology
|
label.Register(plugins) // DEPRECATED, future PVs should not rely on labels for zone topology
|
||||||
podnodeselector.Register(plugins)
|
podnodeselector.Register(plugins)
|
||||||
podpreset.Register(plugins)
|
|
||||||
podtolerationrestriction.Register(plugins)
|
podtolerationrestriction.Register(plugins)
|
||||||
resourcequota.Register(plugins)
|
resourcequota.Register(plugins)
|
||||||
podsecuritypolicy.Register(plugins)
|
podsecuritypolicy.Register(plugins)
|
||||||
|
|
|
@ -31,6 +31,5 @@ import (
|
||||||
_ "k8s.io/kubernetes/pkg/apis/policy/install"
|
_ "k8s.io/kubernetes/pkg/apis/policy/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/settings/install"
|
|
||||||
_ "k8s.io/kubernetes/pkg/apis/storage/install"
|
_ "k8s.io/kubernetes/pkg/apis/storage/install"
|
||||||
)
|
)
|
||||||
|
|
|
@ -38,7 +38,6 @@ import (
|
||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
rbacv1beta1 "k8s.io/api/rbac/v1beta1"
|
rbacv1beta1 "k8s.io/api/rbac/v1beta1"
|
||||||
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
||||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
storagev1 "k8s.io/api/storage/v1"
|
||||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -69,6 +68,5 @@ func init() {
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(policyv1beta1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(policyv1beta1.SchemeGroupVersion))
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(rbacv1.SchemeGroupVersion, rbacv1beta1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(rbacv1.SchemeGroupVersion, rbacv1beta1.SchemeGroupVersion))
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(schedulingv1alpha1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(schedulingv1alpha1.SchemeGroupVersion))
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(settingsv1alpha1.SchemeGroupVersion))
|
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(storagev1.SchemeGroupVersion, storagev1beta1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(storagev1.SchemeGroupVersion, storagev1beta1.SchemeGroupVersion))
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,5 @@ import (
|
||||||
_ "k8s.io/kubernetes/pkg/apis/policy/install"
|
_ "k8s.io/kubernetes/pkg/apis/policy/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/settings/install"
|
|
||||||
_ "k8s.io/kubernetes/pkg/apis/storage/install"
|
_ "k8s.io/kubernetes/pkg/apis/storage/install"
|
||||||
)
|
)
|
||||||
|
|
|
@ -53,7 +53,6 @@ import (
|
||||||
schedulingapiv1 "k8s.io/api/scheduling/v1"
|
schedulingapiv1 "k8s.io/api/scheduling/v1"
|
||||||
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
||||||
schedulingapiv1beta1 "k8s.io/api/scheduling/v1beta1"
|
schedulingapiv1beta1 "k8s.io/api/scheduling/v1beta1"
|
||||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
storageapiv1 "k8s.io/api/storage/v1"
|
storageapiv1 "k8s.io/api/storage/v1"
|
||||||
storageapiv1beta1 "k8s.io/api/storage/v1beta1"
|
storageapiv1beta1 "k8s.io/api/storage/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -95,7 +94,6 @@ import (
|
||||||
policyrest "k8s.io/kubernetes/pkg/registry/policy/rest"
|
policyrest "k8s.io/kubernetes/pkg/registry/policy/rest"
|
||||||
rbacrest "k8s.io/kubernetes/pkg/registry/rbac/rest"
|
rbacrest "k8s.io/kubernetes/pkg/registry/rbac/rest"
|
||||||
schedulingrest "k8s.io/kubernetes/pkg/registry/scheduling/rest"
|
schedulingrest "k8s.io/kubernetes/pkg/registry/scheduling/rest"
|
||||||
settingsrest "k8s.io/kubernetes/pkg/registry/settings/rest"
|
|
||||||
storagerest "k8s.io/kubernetes/pkg/registry/storage/rest"
|
storagerest "k8s.io/kubernetes/pkg/registry/storage/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -347,7 +345,6 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
|
||||||
policyrest.RESTStorageProvider{},
|
policyrest.RESTStorageProvider{},
|
||||||
rbacrest.RESTStorageProvider{Authorizer: c.GenericConfig.Authorization.Authorizer},
|
rbacrest.RESTStorageProvider{Authorizer: c.GenericConfig.Authorization.Authorizer},
|
||||||
schedulingrest.RESTStorageProvider{},
|
schedulingrest.RESTStorageProvider{},
|
||||||
settingsrest.RESTStorageProvider{},
|
|
||||||
storagerest.RESTStorageProvider{},
|
storagerest.RESTStorageProvider{},
|
||||||
// keep apps after extensions so legacy clients resolve the extensions versions of shared resource names.
|
// keep apps after extensions so legacy clients resolve the extensions versions of shared resource names.
|
||||||
// See https://github.com/kubernetes/kubernetes/issues/42392
|
// See https://github.com/kubernetes/kubernetes/issues/42392
|
||||||
|
@ -523,7 +520,6 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
|
||||||
batchapiv2alpha1.SchemeGroupVersion,
|
batchapiv2alpha1.SchemeGroupVersion,
|
||||||
nodev1alpha1.SchemeGroupVersion,
|
nodev1alpha1.SchemeGroupVersion,
|
||||||
schedulingv1alpha1.SchemeGroupVersion,
|
schedulingv1alpha1.SchemeGroupVersion,
|
||||||
settingsv1alpha1.SchemeGroupVersion,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -31,6 +31,5 @@ import (
|
||||||
_ "k8s.io/kubernetes/pkg/apis/policy/install"
|
_ "k8s.io/kubernetes/pkg/apis/policy/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
_ "k8s.io/kubernetes/pkg/apis/rbac/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/settings/install"
|
|
||||||
_ "k8s.io/kubernetes/pkg/apis/storage/install"
|
_ "k8s.io/kubernetes/pkg/apis/storage/install"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"doc.go",
|
|
||||||
"strategy.go",
|
|
||||||
],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/registry/settings/podpreset",
|
|
||||||
deps = [
|
|
||||||
"//pkg/api/legacyscheme:go_default_library",
|
|
||||||
"//pkg/apis/settings:go_default_library",
|
|
||||||
"//pkg/apis/settings/validation:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [
|
|
||||||
":package-srcs",
|
|
||||||
"//pkg/registry/settings/podpreset/storage:all-srcs",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2015 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 podpreset // import "k8s.io/kubernetes/pkg/registry/settings/podpreset"
|
|
|
@ -1,51 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
"go_test",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["storage.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/registry/settings/podpreset/storage",
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/settings:go_default_library",
|
|
||||||
"//pkg/registry/settings/podpreset:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_test(
|
|
||||||
name = "go_default_test",
|
|
||||||
srcs = ["storage_test.go"],
|
|
||||||
embed = [":go_default_library"],
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/core:go_default_library",
|
|
||||||
"//pkg/apis/settings:go_default_library",
|
|
||||||
"//pkg/registry/registrytest:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic/testing:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/storage/etcd/testing:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2015 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 storage
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
|
||||||
settingsapi "k8s.io/kubernetes/pkg/apis/settings"
|
|
||||||
"k8s.io/kubernetes/pkg/registry/settings/podpreset"
|
|
||||||
)
|
|
||||||
|
|
||||||
// rest implements a RESTStorage for replication controllers against etcd
|
|
||||||
type REST struct {
|
|
||||||
*genericregistry.Store
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against replication controllers.
|
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
|
|
||||||
store := &genericregistry.Store{
|
|
||||||
NewFunc: func() runtime.Object { return &settingsapi.PodPreset{} },
|
|
||||||
NewListFunc: func() runtime.Object { return &settingsapi.PodPresetList{} },
|
|
||||||
DefaultQualifiedResource: settingsapi.Resource("podpresets"),
|
|
||||||
|
|
||||||
CreateStrategy: podpreset.Strategy,
|
|
||||||
UpdateStrategy: podpreset.Strategy,
|
|
||||||
DeleteStrategy: podpreset.Strategy,
|
|
||||||
}
|
|
||||||
options := &generic.StoreOptions{RESTOptions: optsGetter}
|
|
||||||
if err := store.CompleteWithOptions(options); err != nil {
|
|
||||||
panic(err) // TODO: Propagate error up
|
|
||||||
}
|
|
||||||
|
|
||||||
return &REST{store}
|
|
||||||
}
|
|
|
@ -1,181 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 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 storage
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
|
||||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/settings"
|
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) {
|
|
||||||
etcdStorage, server := registrytest.NewEtcdStorage(t, settings.GroupName)
|
|
||||||
restOptions := generic.RESTOptions{
|
|
||||||
StorageConfig: etcdStorage,
|
|
||||||
Decorator: generic.UndecoratedStorage,
|
|
||||||
DeleteCollectionWorkers: 1,
|
|
||||||
ResourcePrefix: "podpresets",
|
|
||||||
}
|
|
||||||
return NewREST(restOptions), server
|
|
||||||
}
|
|
||||||
|
|
||||||
func validNewPodPreset(namespace string) *settings.PodPreset {
|
|
||||||
return &settings.PodPreset{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "podPreset",
|
|
||||||
Namespace: namespace,
|
|
||||||
Labels: map[string]string{"a": "b"},
|
|
||||||
},
|
|
||||||
Spec: settings.PodPresetSpec{
|
|
||||||
Selector: metav1.LabelSelector{
|
|
||||||
MatchLabels: map[string]string{
|
|
||||||
"role": "frontend",
|
|
||||||
},
|
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: metav1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Env: []api.EnvVar{
|
|
||||||
{
|
|
||||||
Name: "DB_PORT",
|
|
||||||
Value: "6379",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
EnvFrom: []api.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
VolumeMounts: []api.VolumeMount{
|
|
||||||
{
|
|
||||||
MountPath: "/cache",
|
|
||||||
Name: "cache-volume",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Volumes: []api.Volume{
|
|
||||||
{
|
|
||||||
Name: "cache-volume",
|
|
||||||
VolumeSource: api.VolumeSource{
|
|
||||||
EmptyDir: &api.EmptyDirVolumeSource{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCreate(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
test := genericregistrytest.New(t, storage.Store)
|
|
||||||
invalidPodPreset := validNewPodPreset(test.TestNamespace())
|
|
||||||
invalidPodPreset.Spec.VolumeMounts[0].Name = "/cache/VolumeMounts"
|
|
||||||
test.TestCreate(
|
|
||||||
validNewPodPreset(test.TestNamespace()),
|
|
||||||
// invalid cases
|
|
||||||
invalidPodPreset,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdate(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
test := genericregistrytest.New(t, storage.Store)
|
|
||||||
test.TestUpdate(
|
|
||||||
// valid
|
|
||||||
validNewPodPreset(test.TestNamespace()),
|
|
||||||
// invalid updates
|
|
||||||
func(obj runtime.Object) runtime.Object {
|
|
||||||
pp := obj.(*settings.PodPreset)
|
|
||||||
pp.Labels = map[string]string{"c": "d"}
|
|
||||||
return pp
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDelete(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
test := genericregistrytest.New(t, storage.Store)
|
|
||||||
test.TestDelete(validNewPodPreset(test.TestNamespace()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
test := genericregistrytest.New(t, storage.Store)
|
|
||||||
test.TestGet(validNewPodPreset(test.TestNamespace()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestList(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
test := genericregistrytest.New(t, storage.Store)
|
|
||||||
test.TestList(validNewPodPreset(test.TestNamespace()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWatch(t *testing.T) {
|
|
||||||
storage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
test := genericregistrytest.New(t, storage.Store)
|
|
||||||
test.TestWatch(
|
|
||||||
validNewPodPreset(test.TestNamespace()),
|
|
||||||
// matching labels
|
|
||||||
[]labels.Set{},
|
|
||||||
// not matching labels
|
|
||||||
// not matching labels
|
|
||||||
[]labels.Set{
|
|
||||||
{"foo": "bar"},
|
|
||||||
},
|
|
||||||
|
|
||||||
// matching fields
|
|
||||||
[]fields.Set{
|
|
||||||
{"metadata.name": "podPreset"},
|
|
||||||
},
|
|
||||||
// not matching fields
|
|
||||||
[]fields.Set{
|
|
||||||
{"metadata.name": "bar"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2014 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 podpreset
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
|
||||||
"k8s.io/apiserver/pkg/storage/names"
|
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/settings"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/settings/validation"
|
|
||||||
)
|
|
||||||
|
|
||||||
// podPresetStrategy implements verification logic for Pod Presets.
|
|
||||||
type podPresetStrategy struct {
|
|
||||||
runtime.ObjectTyper
|
|
||||||
names.NameGenerator
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strategy is the default logic that applies when creating and updating Pod Preset objects.
|
|
||||||
var Strategy = podPresetStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
|
|
||||||
|
|
||||||
// NamespaceScoped returns true because all Pod Presets need to be within a namespace.
|
|
||||||
func (podPresetStrategy) NamespaceScoped() bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// PrepareForCreate clears the status of a Pod Preset before creation.
|
|
||||||
func (podPresetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
|
||||||
pip := obj.(*settings.PodPreset)
|
|
||||||
pip.Generation = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
|
||||||
func (podPresetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
|
||||||
newPodPreset := obj.(*settings.PodPreset)
|
|
||||||
oldPodPreset := old.(*settings.PodPreset)
|
|
||||||
|
|
||||||
// Update is not allowed
|
|
||||||
newPodPreset.Spec = oldPodPreset.Spec
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate validates a new PodPreset.
|
|
||||||
func (podPresetStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
|
||||||
pip := obj.(*settings.PodPreset)
|
|
||||||
return validation.ValidatePodPreset(pip)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Canonicalize normalizes the object after validation.
|
|
||||||
func (podPresetStrategy) Canonicalize(obj runtime.Object) {}
|
|
||||||
|
|
||||||
// AllowCreateOnUpdate is false for PodPreset; this means POST is needed to create one.
|
|
||||||
func (podPresetStrategy) AllowCreateOnUpdate() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidateUpdate is the default update validation for an end user.
|
|
||||||
func (podPresetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
|
||||||
validationErrorList := validation.ValidatePodPreset(obj.(*settings.PodPreset))
|
|
||||||
updateErrorList := validation.ValidatePodPresetUpdate(obj.(*settings.PodPreset), old.(*settings.PodPreset))
|
|
||||||
return append(validationErrorList, updateErrorList...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllowUnconditionalUpdate is the default update policy for Pod Preset objects.
|
|
||||||
func (podPresetStrategy) AllowUnconditionalUpdate() bool {
|
|
||||||
return true
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["storage_settings.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/registry/settings/rest",
|
|
||||||
deps = [
|
|
||||||
"//pkg/api/legacyscheme:go_default_library",
|
|
||||||
"//pkg/apis/settings:go_default_library",
|
|
||||||
"//pkg/registry/settings/podpreset/storage:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/server:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/server/storage:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 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 rest
|
|
||||||
|
|
||||||
import (
|
|
||||||
settingsapiv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
|
||||||
genericapiserver "k8s.io/apiserver/pkg/server"
|
|
||||||
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/settings"
|
|
||||||
podpresetstore "k8s.io/kubernetes/pkg/registry/settings/podpreset/storage"
|
|
||||||
)
|
|
||||||
|
|
||||||
type RESTStorageProvider struct{}
|
|
||||||
|
|
||||||
func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (genericapiserver.APIGroupInfo, bool) {
|
|
||||||
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(settings.GroupName, legacyscheme.Scheme, legacyscheme.ParameterCodec, legacyscheme.Codecs)
|
|
||||||
// If you add a version here, be sure to add an entry in `k8s.io/kubernetes/cmd/kube-apiserver/app/aggregator.go with specific priorities.
|
|
||||||
// TODO refactor the plumbing to provide the information in the APIGroupInfo
|
|
||||||
|
|
||||||
if apiResourceConfigSource.VersionEnabled(settingsapiv1alpha1.SchemeGroupVersion) {
|
|
||||||
apiGroupInfo.VersionedResourcesStorageMap[settingsapiv1alpha1.SchemeGroupVersion.Version] = p.v1alpha1Storage(apiResourceConfigSource, restOptionsGetter)
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiGroupInfo, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p RESTStorageProvider) v1alpha1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) map[string]rest.Storage {
|
|
||||||
storage := map[string]rest.Storage{}
|
|
||||||
// podpresets
|
|
||||||
podPresetStorage := podpresetstore.NewREST(restOptionsGetter)
|
|
||||||
storage["podpresets"] = podPresetStorage
|
|
||||||
|
|
||||||
return storage
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p RESTStorageProvider) GroupName() string {
|
|
||||||
return settings.GroupName
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
"go_test",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_test(
|
|
||||||
name = "go_default_test",
|
|
||||||
srcs = ["admission_test.go"],
|
|
||||||
embed = [":go_default_library"],
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/core:go_default_library",
|
|
||||||
"//pkg/controller:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/listers/settings/v1alpha1:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["admission.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/plugin/pkg/admission/podpreset",
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/core:go_default_library",
|
|
||||||
"//pkg/apis/core/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission/initializer:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/listers/settings/v1alpha1:go_default_library",
|
|
||||||
"//vendor/k8s.io/klog:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,417 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 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 podpreset
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"reflect"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"k8s.io/klog"
|
|
||||||
|
|
||||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
|
||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
|
||||||
"k8s.io/apiserver/pkg/admission"
|
|
||||||
genericadmissioninitializer "k8s.io/apiserver/pkg/admission/initializer"
|
|
||||||
"k8s.io/client-go/informers"
|
|
||||||
"k8s.io/client-go/kubernetes"
|
|
||||||
settingsv1alpha1listers "k8s.io/client-go/listers/settings/v1alpha1"
|
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
apiscorev1 "k8s.io/kubernetes/pkg/apis/core/v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
annotationPrefix = "podpreset.admission.kubernetes.io"
|
|
||||||
PluginName = "PodPreset"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Register registers a plugin
|
|
||||||
func Register(plugins *admission.Plugins) {
|
|
||||||
plugins.Register(PluginName, func(config io.Reader) (admission.Interface, error) {
|
|
||||||
return NewPlugin(), nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// podPresetPlugin is an implementation of admission.Interface.
|
|
||||||
type podPresetPlugin struct {
|
|
||||||
*admission.Handler
|
|
||||||
client kubernetes.Interface
|
|
||||||
|
|
||||||
lister settingsv1alpha1listers.PodPresetLister
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ admission.MutationInterface = &podPresetPlugin{}
|
|
||||||
var _ = genericadmissioninitializer.WantsExternalKubeInformerFactory(&podPresetPlugin{})
|
|
||||||
var _ = genericadmissioninitializer.WantsExternalKubeClientSet(&podPresetPlugin{})
|
|
||||||
|
|
||||||
// NewPlugin creates a new pod preset admission plugin.
|
|
||||||
func NewPlugin() *podPresetPlugin {
|
|
||||||
return &podPresetPlugin{
|
|
||||||
Handler: admission.NewHandler(admission.Create, admission.Update),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (plugin *podPresetPlugin) ValidateInitialization() error {
|
|
||||||
if plugin.client == nil {
|
|
||||||
return fmt.Errorf("%s requires a client", PluginName)
|
|
||||||
}
|
|
||||||
if plugin.lister == nil {
|
|
||||||
return fmt.Errorf("%s requires a lister", PluginName)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *podPresetPlugin) SetExternalKubeClientSet(client kubernetes.Interface) {
|
|
||||||
a.client = client
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *podPresetPlugin) SetExternalKubeInformerFactory(f informers.SharedInformerFactory) {
|
|
||||||
podPresetInformer := f.Settings().V1alpha1().PodPresets()
|
|
||||||
a.lister = podPresetInformer.Lister()
|
|
||||||
a.SetReadyFunc(podPresetInformer.Informer().HasSynced)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Admit injects a pod with the specific fields for each pod preset it matches.
|
|
||||||
func (c *podPresetPlugin) Admit(a admission.Attributes, o admission.ObjectInterfaces) error {
|
|
||||||
// Ignore all calls to subresources or resources other than pods.
|
|
||||||
// Ignore all operations other than CREATE.
|
|
||||||
if len(a.GetSubresource()) != 0 || a.GetResource().GroupResource() != api.Resource("pods") || a.GetOperation() != admission.Create {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
pod, ok := a.GetObject().(*api.Pod)
|
|
||||||
if !ok {
|
|
||||||
return errors.NewBadRequest("Resource was marked with kind Pod but was unable to be converted")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, isMirrorPod := pod.Annotations[api.MirrorPodAnnotationKey]; isMirrorPod {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ignore if exclusion annotation is present
|
|
||||||
if podAnnotations := pod.GetAnnotations(); podAnnotations != nil {
|
|
||||||
klog.V(5).Infof("Looking at pod annotations, found: %v", podAnnotations)
|
|
||||||
if podAnnotations[api.PodPresetOptOutAnnotationKey] == "true" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list, err := c.lister.PodPresets(a.GetNamespace()).List(labels.Everything())
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("listing pod presets failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
matchingPPs, err := filterPodPresets(list, pod)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("filtering pod presets failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(matchingPPs) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
presetNames := make([]string, len(matchingPPs))
|
|
||||||
for i, pp := range matchingPPs {
|
|
||||||
presetNames[i] = pp.GetName()
|
|
||||||
}
|
|
||||||
|
|
||||||
// detect merge conflict
|
|
||||||
err = safeToApplyPodPresetsOnPod(pod, matchingPPs)
|
|
||||||
if err != nil {
|
|
||||||
// conflict, ignore the error, but raise an event
|
|
||||||
klog.Warningf("conflict occurred while applying podpresets: %s on pod: %v err: %v",
|
|
||||||
strings.Join(presetNames, ","), pod.GetGenerateName(), err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
applyPodPresetsOnPod(pod, matchingPPs)
|
|
||||||
|
|
||||||
klog.Infof("applied podpresets: %s successfully on Pod: %+v ", strings.Join(presetNames, ","), pod.GetGenerateName())
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// filterPodPresets returns list of PodPresets which match given Pod.
|
|
||||||
func filterPodPresets(list []*settingsv1alpha1.PodPreset, pod *api.Pod) ([]*settingsv1alpha1.PodPreset, error) {
|
|
||||||
var matchingPPs []*settingsv1alpha1.PodPreset
|
|
||||||
|
|
||||||
for _, pp := range list {
|
|
||||||
selector, err := metav1.LabelSelectorAsSelector(&pp.Spec.Selector)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("label selector conversion failed: %v for selector: %v", pp.Spec.Selector, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the pod labels match the selector
|
|
||||||
if !selector.Matches(labels.Set(pod.Labels)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
klog.V(4).Infof("PodPreset %s matches pod %s labels", pp.GetName(), pod.GetName())
|
|
||||||
matchingPPs = append(matchingPPs, pp)
|
|
||||||
}
|
|
||||||
return matchingPPs, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// safeToApplyPodPresetsOnPod determines if there is any conflict in information
|
|
||||||
// injected by given PodPresets in the Pod.
|
|
||||||
func safeToApplyPodPresetsOnPod(pod *api.Pod, podPresets []*settingsv1alpha1.PodPreset) error {
|
|
||||||
var errs []error
|
|
||||||
|
|
||||||
// volumes attribute is defined at the Pod level, so determine if volumes
|
|
||||||
// injection is causing any conflict.
|
|
||||||
if _, err := mergeVolumes(pod.Spec.Volumes, podPresets); err != nil {
|
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
for _, ctr := range pod.Spec.Containers {
|
|
||||||
if err := safeToApplyPodPresetsOnContainer(&ctr, podPresets); err != nil {
|
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, iCtr := range pod.Spec.InitContainers {
|
|
||||||
if err := safeToApplyPodPresetsOnContainer(&iCtr, podPresets); err != nil {
|
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return utilerrors.NewAggregate(errs)
|
|
||||||
}
|
|
||||||
|
|
||||||
// safeToApplyPodPresetsOnContainer determines if there is any conflict in
|
|
||||||
// information injected by given PodPresets in the given container.
|
|
||||||
func safeToApplyPodPresetsOnContainer(ctr *api.Container, podPresets []*settingsv1alpha1.PodPreset) error {
|
|
||||||
var errs []error
|
|
||||||
// check if it is safe to merge env vars and volume mounts from given podpresets and
|
|
||||||
// container's existing env vars.
|
|
||||||
if _, err := mergeEnv(ctr.Env, podPresets); err != nil {
|
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
if _, err := mergeVolumeMounts(ctr.VolumeMounts, podPresets); err != nil {
|
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return utilerrors.NewAggregate(errs)
|
|
||||||
}
|
|
||||||
|
|
||||||
// mergeEnv merges a list of env vars with the env vars injected by given list podPresets.
|
|
||||||
// It returns an error if it detects any conflict during the merge.
|
|
||||||
func mergeEnv(envVars []api.EnvVar, podPresets []*settingsv1alpha1.PodPreset) ([]api.EnvVar, error) {
|
|
||||||
origEnv := map[string]api.EnvVar{}
|
|
||||||
for _, v := range envVars {
|
|
||||||
origEnv[v.Name] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
mergedEnv := make([]api.EnvVar, len(envVars))
|
|
||||||
copy(mergedEnv, envVars)
|
|
||||||
|
|
||||||
var errs []error
|
|
||||||
|
|
||||||
for _, pp := range podPresets {
|
|
||||||
for _, v := range pp.Spec.Env {
|
|
||||||
internalEnv := api.EnvVar{}
|
|
||||||
if err := apiscorev1.Convert_v1_EnvVar_To_core_EnvVar(&v, &internalEnv, nil); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
found, ok := origEnv[v.Name]
|
|
||||||
if !ok {
|
|
||||||
// if we don't already have it append it and continue
|
|
||||||
origEnv[v.Name] = internalEnv
|
|
||||||
mergedEnv = append(mergedEnv, internalEnv)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure they are identical or throw an error
|
|
||||||
if !reflect.DeepEqual(found, internalEnv) {
|
|
||||||
errs = append(errs, fmt.Errorf("merging env for %s has a conflict on %s: \n%#v\ndoes not match\n%#v\n in container", pp.GetName(), v.Name, v, found))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err := utilerrors.NewAggregate(errs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return mergedEnv, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func mergeEnvFrom(envSources []api.EnvFromSource, podPresets []*settingsv1alpha1.PodPreset) ([]api.EnvFromSource, error) {
|
|
||||||
var mergedEnvFrom []api.EnvFromSource
|
|
||||||
|
|
||||||
mergedEnvFrom = append(mergedEnvFrom, envSources...)
|
|
||||||
for _, pp := range podPresets {
|
|
||||||
for _, envFromSource := range pp.Spec.EnvFrom {
|
|
||||||
internalEnvFrom := api.EnvFromSource{}
|
|
||||||
if err := apiscorev1.Convert_v1_EnvFromSource_To_core_EnvFromSource(&envFromSource, &internalEnvFrom, nil); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
mergedEnvFrom = append(mergedEnvFrom, internalEnvFrom)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return mergedEnvFrom, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// mergeVolumeMounts merges given list of VolumeMounts with the volumeMounts
|
|
||||||
// injected by given podPresets. It returns an error if it detects any conflict during the merge.
|
|
||||||
func mergeVolumeMounts(volumeMounts []api.VolumeMount, podPresets []*settingsv1alpha1.PodPreset) ([]api.VolumeMount, error) {
|
|
||||||
|
|
||||||
origVolumeMounts := map[string]api.VolumeMount{}
|
|
||||||
volumeMountsByPath := map[string]api.VolumeMount{}
|
|
||||||
for _, v := range volumeMounts {
|
|
||||||
origVolumeMounts[v.Name] = v
|
|
||||||
volumeMountsByPath[v.MountPath] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
mergedVolumeMounts := make([]api.VolumeMount, len(volumeMounts))
|
|
||||||
copy(mergedVolumeMounts, volumeMounts)
|
|
||||||
|
|
||||||
var errs []error
|
|
||||||
|
|
||||||
for _, pp := range podPresets {
|
|
||||||
for _, v := range pp.Spec.VolumeMounts {
|
|
||||||
internalVolumeMount := api.VolumeMount{}
|
|
||||||
if err := apiscorev1.Convert_v1_VolumeMount_To_core_VolumeMount(&v, &internalVolumeMount, nil); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
found, ok := origVolumeMounts[v.Name]
|
|
||||||
if !ok {
|
|
||||||
// if we don't already have it append it and continue
|
|
||||||
origVolumeMounts[v.Name] = internalVolumeMount
|
|
||||||
mergedVolumeMounts = append(mergedVolumeMounts, internalVolumeMount)
|
|
||||||
} else {
|
|
||||||
// make sure they are identical or throw an error
|
|
||||||
// shall we throw an error for identical volumeMounts ?
|
|
||||||
if !reflect.DeepEqual(found, internalVolumeMount) {
|
|
||||||
errs = append(errs, fmt.Errorf("merging volume mounts for %s has a conflict on %s: \n%#v\ndoes not match\n%#v\n in container", pp.GetName(), v.Name, v, found))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
found, ok = volumeMountsByPath[v.MountPath]
|
|
||||||
if !ok {
|
|
||||||
// if we don't already have it append it and continue
|
|
||||||
volumeMountsByPath[v.MountPath] = internalVolumeMount
|
|
||||||
} else {
|
|
||||||
// make sure they are identical or throw an error
|
|
||||||
if !reflect.DeepEqual(found, internalVolumeMount) {
|
|
||||||
errs = append(errs, fmt.Errorf("merging volume mounts for %s has a conflict on mount path %s: \n%#v\ndoes not match\n%#v\n in container", pp.GetName(), v.MountPath, v, found))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err := utilerrors.NewAggregate(errs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return mergedVolumeMounts, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// mergeVolumes merges given list of Volumes with the volumes injected by given
|
|
||||||
// podPresets. It returns an error if it detects any conflict during the merge.
|
|
||||||
func mergeVolumes(volumes []api.Volume, podPresets []*settingsv1alpha1.PodPreset) ([]api.Volume, error) {
|
|
||||||
origVolumes := map[string]api.Volume{}
|
|
||||||
for _, v := range volumes {
|
|
||||||
origVolumes[v.Name] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
mergedVolumes := make([]api.Volume, len(volumes))
|
|
||||||
copy(mergedVolumes, volumes)
|
|
||||||
|
|
||||||
var errs []error
|
|
||||||
|
|
||||||
for _, pp := range podPresets {
|
|
||||||
for _, v := range pp.Spec.Volumes {
|
|
||||||
internalVolume := api.Volume{}
|
|
||||||
if err := apiscorev1.Convert_v1_Volume_To_core_Volume(&v, &internalVolume, nil); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
found, ok := origVolumes[v.Name]
|
|
||||||
if !ok {
|
|
||||||
// if we don't already have it append it and continue
|
|
||||||
origVolumes[v.Name] = internalVolume
|
|
||||||
mergedVolumes = append(mergedVolumes, internalVolume)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure they are identical or throw an error
|
|
||||||
if !reflect.DeepEqual(found, internalVolume) {
|
|
||||||
errs = append(errs, fmt.Errorf("merging volumes for %s has a conflict on %s: \n%#v\ndoes not match\n%#v\n in container", pp.GetName(), v.Name, v, found))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err := utilerrors.NewAggregate(errs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(mergedVolumes) == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return mergedVolumes, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// applyPodPresetsOnPod updates the PodSpec with merged information from all the
|
|
||||||
// applicable PodPresets. It ignores the errors of merge functions because merge
|
|
||||||
// errors have already been checked in safeToApplyPodPresetsOnPod function.
|
|
||||||
func applyPodPresetsOnPod(pod *api.Pod, podPresets []*settingsv1alpha1.PodPreset) {
|
|
||||||
if len(podPresets) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
volumes, _ := mergeVolumes(pod.Spec.Volumes, podPresets)
|
|
||||||
pod.Spec.Volumes = volumes
|
|
||||||
|
|
||||||
for i, ctr := range pod.Spec.Containers {
|
|
||||||
applyPodPresetsOnContainer(&ctr, podPresets)
|
|
||||||
pod.Spec.Containers[i] = ctr
|
|
||||||
}
|
|
||||||
for i, iCtr := range pod.Spec.InitContainers {
|
|
||||||
applyPodPresetsOnContainer(&iCtr, podPresets)
|
|
||||||
pod.Spec.InitContainers[i] = iCtr
|
|
||||||
}
|
|
||||||
|
|
||||||
// add annotation
|
|
||||||
if pod.ObjectMeta.Annotations == nil {
|
|
||||||
pod.ObjectMeta.Annotations = map[string]string{}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, pp := range podPresets {
|
|
||||||
pod.ObjectMeta.Annotations[fmt.Sprintf("%s/podpreset-%s", annotationPrefix, pp.GetName())] = pp.GetResourceVersion()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// applyPodPresetsOnContainer injects envVars, VolumeMounts and envFrom from
|
|
||||||
// given podPresets in to the given container. It ignores conflict errors
|
|
||||||
// because it assumes those have been checked already by the caller.
|
|
||||||
func applyPodPresetsOnContainer(ctr *api.Container, podPresets []*settingsv1alpha1.PodPreset) {
|
|
||||||
envVars, _ := mergeEnv(ctr.Env, podPresets)
|
|
||||||
ctr.Env = envVars
|
|
||||||
|
|
||||||
volumeMounts, _ := mergeVolumeMounts(ctr.VolumeMounts, podPresets)
|
|
||||||
ctr.VolumeMounts = volumeMounts
|
|
||||||
|
|
||||||
envFrom, _ := mergeEnvFrom(ctr.EnvFrom, podPresets)
|
|
||||||
ctr.EnvFrom = envFrom
|
|
||||||
}
|
|
|
@ -1,832 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2016 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 podpreset
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
|
||||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
kadmission "k8s.io/apiserver/pkg/admission"
|
|
||||||
"k8s.io/apiserver/pkg/authentication/user"
|
|
||||||
"k8s.io/client-go/informers"
|
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
|
||||||
settingsv1alpha1listers "k8s.io/client-go/listers/settings/v1alpha1"
|
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
"k8s.io/kubernetes/pkg/controller"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestMergeEnv(t *testing.T) {
|
|
||||||
tests := map[string]struct {
|
|
||||||
orig []api.EnvVar
|
|
||||||
mod []corev1.EnvVar
|
|
||||||
result []api.EnvVar
|
|
||||||
shouldFail bool
|
|
||||||
}{
|
|
||||||
"empty original": {
|
|
||||||
mod: []corev1.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
result: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
"good merge": {
|
|
||||||
orig: []api.EnvVar{{Name: "abcd", Value: "value2"}, {Name: "hello", Value: "value3"}},
|
|
||||||
mod: []corev1.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
result: []api.EnvVar{{Name: "abcd", Value: "value2"}, {Name: "hello", Value: "value3"}, {Name: "abc", Value: "value2"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
orig: []api.EnvVar{{Name: "abc", Value: "value3"}},
|
|
||||||
mod: []corev1.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
shouldFail: true,
|
|
||||||
},
|
|
||||||
"one is exact same": {
|
|
||||||
orig: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "hello", Value: "value3"}},
|
|
||||||
mod: []corev1.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
result: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "hello", Value: "value3"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, test := range tests {
|
|
||||||
result, err := mergeEnv(
|
|
||||||
test.orig,
|
|
||||||
[]*settingsv1alpha1.PodPreset{{Spec: settingsv1alpha1.PodPresetSpec{Env: test.mod}}},
|
|
||||||
)
|
|
||||||
if test.shouldFail && err == nil {
|
|
||||||
t.Fatalf("expected test %q to fail but got nil", name)
|
|
||||||
}
|
|
||||||
if !test.shouldFail && err != nil {
|
|
||||||
t.Fatalf("test %q failed: %v", name, err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(test.result, result) {
|
|
||||||
t.Fatalf("results were not equal for test %q: got %#v; expected: %#v", name, result, test.result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeEnvFrom(t *testing.T) {
|
|
||||||
tests := map[string]struct {
|
|
||||||
orig []api.EnvFromSource
|
|
||||||
mod []corev1.EnvFromSource
|
|
||||||
result []api.EnvFromSource
|
|
||||||
shouldFail bool
|
|
||||||
}{
|
|
||||||
"empty original": {
|
|
||||||
mod: []corev1.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
result: []api.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
"good merge": {
|
|
||||||
orig: []api.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "thing"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mod: []corev1.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
result: []api.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "thing"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, test := range tests {
|
|
||||||
result, err := mergeEnvFrom(
|
|
||||||
test.orig,
|
|
||||||
[]*settingsv1alpha1.PodPreset{{Spec: settingsv1alpha1.PodPresetSpec{EnvFrom: test.mod}}},
|
|
||||||
)
|
|
||||||
if test.shouldFail && err == nil {
|
|
||||||
t.Fatalf("expected test %q to fail but got nil", name)
|
|
||||||
}
|
|
||||||
if !test.shouldFail && err != nil {
|
|
||||||
t.Fatalf("test %q failed: %v", name, err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(test.result, result) {
|
|
||||||
t.Fatalf("results were not equal for test %q: got %#v; expected: %#v", name, result, test.result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeVolumeMounts(t *testing.T) {
|
|
||||||
tests := map[string]struct {
|
|
||||||
orig []api.VolumeMount
|
|
||||||
mod []corev1.VolumeMount
|
|
||||||
result []api.VolumeMount
|
|
||||||
shouldFail bool
|
|
||||||
}{
|
|
||||||
"empty original": {
|
|
||||||
mod: []corev1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "simply-mounted-volume",
|
|
||||||
MountPath: "/opt/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
result: []api.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "simply-mounted-volume",
|
|
||||||
MountPath: "/opt/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
"good merge": {
|
|
||||||
mod: []corev1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "simply-mounted-volume",
|
|
||||||
MountPath: "/opt/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
orig: []api.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "etc-volume",
|
|
||||||
MountPath: "/etc/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
result: []api.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "etc-volume",
|
|
||||||
MountPath: "/etc/",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "simply-mounted-volume",
|
|
||||||
MountPath: "/opt/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
mod: []corev1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "simply-mounted-volume",
|
|
||||||
MountPath: "/opt/",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "etc-volume",
|
|
||||||
MountPath: "/things/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
orig: []api.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "etc-volume",
|
|
||||||
MountPath: "/etc/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shouldFail: true,
|
|
||||||
},
|
|
||||||
"conflict on mount path": {
|
|
||||||
mod: []corev1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "simply-mounted-volume",
|
|
||||||
MountPath: "/opt/",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "things-volume",
|
|
||||||
MountPath: "/etc/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
orig: []api.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "etc-volume",
|
|
||||||
MountPath: "/etc/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shouldFail: true,
|
|
||||||
},
|
|
||||||
"one is exact same": {
|
|
||||||
mod: []corev1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "simply-mounted-volume",
|
|
||||||
MountPath: "/opt/",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "etc-volume",
|
|
||||||
MountPath: "/etc/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
orig: []api.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "etc-volume",
|
|
||||||
MountPath: "/etc/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
result: []api.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "etc-volume",
|
|
||||||
MountPath: "/etc/",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "simply-mounted-volume",
|
|
||||||
MountPath: "/opt/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, test := range tests {
|
|
||||||
result, err := mergeVolumeMounts(
|
|
||||||
test.orig,
|
|
||||||
[]*settingsv1alpha1.PodPreset{{Spec: settingsv1alpha1.PodPresetSpec{VolumeMounts: test.mod}}},
|
|
||||||
)
|
|
||||||
if test.shouldFail && err == nil {
|
|
||||||
t.Fatalf("expected test %q to fail but got nil", name)
|
|
||||||
}
|
|
||||||
if !test.shouldFail && err != nil {
|
|
||||||
t.Fatalf("test %q failed: %v", name, err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(test.result, result) {
|
|
||||||
t.Fatalf("results were not equal for test %q: got %#v; expected: %#v", name, result, test.result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeVolumes(t *testing.T) {
|
|
||||||
tests := map[string]struct {
|
|
||||||
orig []api.Volume
|
|
||||||
mod []corev1.Volume
|
|
||||||
result []api.Volume
|
|
||||||
shouldFail bool
|
|
||||||
}{
|
|
||||||
"empty original": {
|
|
||||||
mod: []corev1.Volume{
|
|
||||||
{Name: "vol", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol2", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
result: []api.Volume{
|
|
||||||
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
"good merge": {
|
|
||||||
orig: []api.Volume{
|
|
||||||
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
mod: []corev1.Volume{
|
|
||||||
{Name: "vol", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol2", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
result: []api.Volume{
|
|
||||||
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
orig: []api.Volume{
|
|
||||||
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
mod: []corev1.Volume{
|
|
||||||
{Name: "vol3", VolumeSource: corev1.VolumeSource{HostPath: &corev1.HostPathVolumeSource{Path: "/etc/apparmor.d"}}},
|
|
||||||
{Name: "vol2", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
shouldFail: true,
|
|
||||||
},
|
|
||||||
"one is exact same": {
|
|
||||||
orig: []api.Volume{
|
|
||||||
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
mod: []corev1.Volume{
|
|
||||||
{Name: "vol3", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol2", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
result: []api.Volume{
|
|
||||||
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
|
|
||||||
},
|
|
||||||
shouldFail: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, test := range tests {
|
|
||||||
result, err := mergeVolumes(
|
|
||||||
test.orig,
|
|
||||||
[]*settingsv1alpha1.PodPreset{{Spec: settingsv1alpha1.PodPresetSpec{Volumes: test.mod}}},
|
|
||||||
)
|
|
||||||
if test.shouldFail && err == nil {
|
|
||||||
t.Fatalf("expected test %q to fail but got nil", name)
|
|
||||||
}
|
|
||||||
if !test.shouldFail && err != nil {
|
|
||||||
t.Fatalf("test %q failed: %v", name, err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(test.result, result) {
|
|
||||||
t.Fatalf("results were not equal for test %q: got %#v; expected: %#v", name, result, test.result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewTestAdmission provides an admission plugin with test implementations of internal structs. It uses
|
|
||||||
// an authorizer that always returns true.
|
|
||||||
func NewTestAdmission(lister settingsv1alpha1listers.PodPresetLister, objects ...runtime.Object) kadmission.MutationInterface {
|
|
||||||
// Build a test client that the admission plugin can use to look up the service account missing from its cache
|
|
||||||
client := fake.NewSimpleClientset(objects...)
|
|
||||||
|
|
||||||
return &podPresetPlugin{
|
|
||||||
client: client,
|
|
||||||
Handler: kadmission.NewHandler(kadmission.Create),
|
|
||||||
lister: lister,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAdmitConflictWithDifferentNamespaceShouldDoNothing(t *testing.T) {
|
|
||||||
containerName := "container"
|
|
||||||
|
|
||||||
pod := &api.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "mypod",
|
|
||||||
Namespace: "namespace",
|
|
||||||
Labels: map[string]string{
|
|
||||||
"security": "S2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: api.PodSpec{
|
|
||||||
Containers: []api.Container{
|
|
||||||
{
|
|
||||||
Name: containerName,
|
|
||||||
Env: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
pip := &settingsv1alpha1.PodPreset{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "othernamespace",
|
|
||||||
},
|
|
||||||
Spec: settingsv1alpha1.PodPresetSpec{
|
|
||||||
Selector: metav1.LabelSelector{
|
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: metav1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Env: []corev1.EnvVar{{Name: "abc", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
err := admitPod(pod, pip)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAdmitConflictWithNonMatchingLabelsShouldNotError(t *testing.T) {
|
|
||||||
containerName := "container"
|
|
||||||
|
|
||||||
pod := &api.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "mypod",
|
|
||||||
Namespace: "namespace",
|
|
||||||
Labels: map[string]string{
|
|
||||||
"security": "S2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: api.PodSpec{
|
|
||||||
Containers: []api.Container{
|
|
||||||
{
|
|
||||||
Name: containerName,
|
|
||||||
Env: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
pip := &settingsv1alpha1.PodPreset{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "namespace",
|
|
||||||
},
|
|
||||||
Spec: settingsv1alpha1.PodPresetSpec{
|
|
||||||
Selector: metav1.LabelSelector{
|
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: metav1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S3"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Env: []corev1.EnvVar{{Name: "abc", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
err := admitPod(pod, pip)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAdmitConflictShouldNotModifyPod(t *testing.T) {
|
|
||||||
containerName := "container"
|
|
||||||
|
|
||||||
pod := &api.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "mypod",
|
|
||||||
Namespace: "namespace",
|
|
||||||
Labels: map[string]string{
|
|
||||||
"security": "S2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: api.PodSpec{
|
|
||||||
Containers: []api.Container{
|
|
||||||
{
|
|
||||||
Name: containerName,
|
|
||||||
Env: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABC", Value: "value3"}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
origPod := *pod
|
|
||||||
|
|
||||||
pip := &settingsv1alpha1.PodPreset{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "namespace",
|
|
||||||
},
|
|
||||||
Spec: settingsv1alpha1.PodPresetSpec{
|
|
||||||
Selector: metav1.LabelSelector{
|
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: metav1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Env: []corev1.EnvVar{{Name: "abc", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
err := admitPod(pod, pip)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(&origPod, pod) {
|
|
||||||
t.Fatalf("pod should not get modified in case of conflict origPod: %+v got: %+v", &origPod, pod)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAdmit(t *testing.T) {
|
|
||||||
containerName := "container"
|
|
||||||
|
|
||||||
pod := &api.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "mypod",
|
|
||||||
Namespace: "namespace",
|
|
||||||
Labels: map[string]string{
|
|
||||||
"security": "S2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: api.PodSpec{
|
|
||||||
Containers: []api.Container{
|
|
||||||
{
|
|
||||||
Name: containerName,
|
|
||||||
Env: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABCD", Value: "value3"}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
pip := &settingsv1alpha1.PodPreset{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "namespace",
|
|
||||||
},
|
|
||||||
Spec: settingsv1alpha1.PodPresetSpec{
|
|
||||||
Selector: metav1.LabelSelector{
|
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: metav1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Volumes: []corev1.Volume{{Name: "vol", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}}},
|
|
||||||
Env: []corev1.EnvVar{{Name: "abcd", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
EnvFrom: []corev1.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
err := admitPod(pod, pip)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAdmitMirrorPod(t *testing.T) {
|
|
||||||
containerName := "container"
|
|
||||||
|
|
||||||
mirrorPod := &api.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "mypod",
|
|
||||||
Namespace: "namespace",
|
|
||||||
Labels: map[string]string{
|
|
||||||
"security": "S2",
|
|
||||||
},
|
|
||||||
Annotations: map[string]string{api.MirrorPodAnnotationKey: "mirror"},
|
|
||||||
},
|
|
||||||
Spec: api.PodSpec{
|
|
||||||
Containers: []api.Container{
|
|
||||||
{
|
|
||||||
Name: containerName,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
pip := &settingsv1alpha1.PodPreset{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "namespace",
|
|
||||||
},
|
|
||||||
Spec: settingsv1alpha1.PodPresetSpec{
|
|
||||||
Selector: metav1.LabelSelector{
|
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: metav1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Volumes: []corev1.Volume{{Name: "vol", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}}},
|
|
||||||
Env: []corev1.EnvVar{{Name: "abcd", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
EnvFrom: []corev1.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := admitPod(mirrorPod, pip); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
container := mirrorPod.Spec.Containers[0]
|
|
||||||
if len(mirrorPod.Spec.Volumes) != 0 ||
|
|
||||||
len(container.VolumeMounts) != 0 ||
|
|
||||||
len(container.Env) != 0 ||
|
|
||||||
len(container.EnvFrom) != 0 {
|
|
||||||
t.Fatalf("mirror pod is updated by PodPreset admission:\n\tVolumes got %d, expected 0\n\tVolumeMounts go %d, expected 0\n\tEnv got, %d expected 0\n\tEnvFrom got %d, expected 0", len(mirrorPod.Spec.Volumes), len(container.VolumeMounts), len(container.Env), len(container.EnvFrom))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestExclusionNoAdmit(t *testing.T) {
|
|
||||||
containerName := "container"
|
|
||||||
|
|
||||||
pod := &api.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "mypod",
|
|
||||||
Namespace: "namespace",
|
|
||||||
Labels: map[string]string{
|
|
||||||
"security": "S2",
|
|
||||||
},
|
|
||||||
Annotations: map[string]string{
|
|
||||||
api.PodPresetOptOutAnnotationKey: "true",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: api.PodSpec{
|
|
||||||
Containers: []api.Container{
|
|
||||||
{
|
|
||||||
Name: containerName,
|
|
||||||
Env: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABCD", Value: "value3"}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
pip := &settingsv1alpha1.PodPreset{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "namespace",
|
|
||||||
},
|
|
||||||
Spec: settingsv1alpha1.PodPresetSpec{
|
|
||||||
Selector: metav1.LabelSelector{
|
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: metav1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Volumes: []corev1.Volume{{Name: "vol", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}}},
|
|
||||||
Env: []corev1.EnvVar{{Name: "abcd", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
EnvFrom: []corev1.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
originalPod := pod.DeepCopy()
|
|
||||||
err := admitPod(pod, pip)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify PodSpec has not been mutated
|
|
||||||
if !reflect.DeepEqual(pod, originalPod) {
|
|
||||||
t.Fatalf("Expected pod spec of '%v' to be unchanged", pod.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAdmitEmptyPodNamespace(t *testing.T) {
|
|
||||||
containerName := "container"
|
|
||||||
|
|
||||||
pod := &api.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "mypod",
|
|
||||||
Labels: map[string]string{
|
|
||||||
"security": "S2",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Spec: api.PodSpec{
|
|
||||||
Containers: []api.Container{
|
|
||||||
{
|
|
||||||
Name: containerName,
|
|
||||||
Env: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABCD", Value: "value3"}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
pip := &settingsv1alpha1.PodPreset{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "hello",
|
|
||||||
Namespace: "different", // (pod will be submitted to namespace 'namespace')
|
|
||||||
},
|
|
||||||
Spec: settingsv1alpha1.PodPresetSpec{
|
|
||||||
Selector: metav1.LabelSelector{
|
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
|
||||||
{
|
|
||||||
Key: "security",
|
|
||||||
Operator: metav1.LabelSelectorOpIn,
|
|
||||||
Values: []string{"S2"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Volumes: []corev1.Volume{{Name: "vol", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}}},
|
|
||||||
Env: []corev1.EnvVar{{Name: "abcd", Value: "value"}, {Name: "ABC", Value: "value"}},
|
|
||||||
EnvFrom: []corev1.EnvFromSource{
|
|
||||||
{
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Prefix: "pre_",
|
|
||||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: "abc"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
originalPod := pod.DeepCopy()
|
|
||||||
err := admitPod(pod, pip)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify PodSpec has not been mutated
|
|
||||||
if !reflect.DeepEqual(pod, originalPod) {
|
|
||||||
t.Fatalf("pod should not get modified in case of emptyNamespace origPod: %+v got: %+v", originalPod, pod)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func admitPod(pod *api.Pod, pip *settingsv1alpha1.PodPreset) error {
|
|
||||||
informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc())
|
|
||||||
store := informerFactory.Settings().V1alpha1().PodPresets().Informer().GetStore()
|
|
||||||
store.Add(pip)
|
|
||||||
plugin := NewTestAdmission(informerFactory.Settings().V1alpha1().PodPresets().Lister())
|
|
||||||
attrs := kadmission.NewAttributesRecord(
|
|
||||||
pod,
|
|
||||||
nil,
|
|
||||||
api.Kind("Pod").WithVersion("version"),
|
|
||||||
"namespace",
|
|
||||||
"",
|
|
||||||
api.Resource("pods").WithVersion("version"),
|
|
||||||
"",
|
|
||||||
kadmission.Create,
|
|
||||||
false,
|
|
||||||
&user.DefaultInfo{},
|
|
||||||
)
|
|
||||||
|
|
||||||
err := plugin.Admit(attrs, nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"doc.go",
|
|
||||||
"generated.pb.go",
|
|
||||||
"register.go",
|
|
||||||
"types.go",
|
|
||||||
"types_swagger_doc_generated.go",
|
|
||||||
"zz_generated.deepcopy.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/api/settings/v1alpha1",
|
|
||||||
importpath = "k8s.io/api/settings/v1alpha1",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
|
||||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 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:protobuf-gen=package
|
|
||||||
// +k8s:openapi-gen=true
|
|
||||||
|
|
||||||
// +groupName=settings.k8s.io
|
|
||||||
|
|
||||||
package v1alpha1 // import "k8s.io/api/settings/v1alpha1"
|
|
|
@ -1,915 +0,0 @@
|
||||||
/*
|
|
||||||
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 protoc-gen-gogo. DO NOT EDIT.
|
|
||||||
// source: k8s.io/kubernetes/vendor/k8s.io/api/settings/v1alpha1/generated.proto
|
|
||||||
|
|
||||||
/*
|
|
||||||
Package v1alpha1 is a generated protocol buffer package.
|
|
||||||
|
|
||||||
It is generated from these files:
|
|
||||||
k8s.io/kubernetes/vendor/k8s.io/api/settings/v1alpha1/generated.proto
|
|
||||||
|
|
||||||
It has these top-level messages:
|
|
||||||
PodPreset
|
|
||||||
PodPresetList
|
|
||||||
PodPresetSpec
|
|
||||||
*/
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
fmt "fmt"
|
|
||||||
|
|
||||||
proto "github.com/gogo/protobuf/proto"
|
|
||||||
|
|
||||||
math "math"
|
|
||||||
|
|
||||||
k8s_io_api_core_v1 "k8s.io/api/core/v1"
|
|
||||||
|
|
||||||
strings "strings"
|
|
||||||
|
|
||||||
reflect "reflect"
|
|
||||||
|
|
||||||
io "io"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
|
||||||
var _ = proto.Marshal
|
|
||||||
var _ = fmt.Errorf
|
|
||||||
var _ = math.Inf
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the proto package it is being compiled against.
|
|
||||||
// A compilation error at this line likely means your copy of the
|
|
||||||
// proto package needs to be updated.
|
|
||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
|
||||||
|
|
||||||
func (m *PodPreset) Reset() { *m = PodPreset{} }
|
|
||||||
func (*PodPreset) ProtoMessage() {}
|
|
||||||
func (*PodPreset) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{0} }
|
|
||||||
|
|
||||||
func (m *PodPresetList) Reset() { *m = PodPresetList{} }
|
|
||||||
func (*PodPresetList) ProtoMessage() {}
|
|
||||||
func (*PodPresetList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{1} }
|
|
||||||
|
|
||||||
func (m *PodPresetSpec) Reset() { *m = PodPresetSpec{} }
|
|
||||||
func (*PodPresetSpec) ProtoMessage() {}
|
|
||||||
func (*PodPresetSpec) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{2} }
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
proto.RegisterType((*PodPreset)(nil), "k8s.io.api.settings.v1alpha1.PodPreset")
|
|
||||||
proto.RegisterType((*PodPresetList)(nil), "k8s.io.api.settings.v1alpha1.PodPresetList")
|
|
||||||
proto.RegisterType((*PodPresetSpec)(nil), "k8s.io.api.settings.v1alpha1.PodPresetSpec")
|
|
||||||
}
|
|
||||||
func (m *PodPreset) Marshal() (dAtA []byte, err error) {
|
|
||||||
size := m.Size()
|
|
||||||
dAtA = make([]byte, size)
|
|
||||||
n, err := m.MarshalTo(dAtA)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return dAtA[:n], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *PodPreset) MarshalTo(dAtA []byte) (int, error) {
|
|
||||||
var i int
|
|
||||||
_ = i
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
dAtA[i] = 0xa
|
|
||||||
i++
|
|
||||||
i = encodeVarintGenerated(dAtA, i, uint64(m.ObjectMeta.Size()))
|
|
||||||
n1, err := m.ObjectMeta.MarshalTo(dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n1
|
|
||||||
dAtA[i] = 0x12
|
|
||||||
i++
|
|
||||||
i = encodeVarintGenerated(dAtA, i, uint64(m.Spec.Size()))
|
|
||||||
n2, err := m.Spec.MarshalTo(dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n2
|
|
||||||
return i, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *PodPresetList) Marshal() (dAtA []byte, err error) {
|
|
||||||
size := m.Size()
|
|
||||||
dAtA = make([]byte, size)
|
|
||||||
n, err := m.MarshalTo(dAtA)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return dAtA[:n], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *PodPresetList) MarshalTo(dAtA []byte) (int, error) {
|
|
||||||
var i int
|
|
||||||
_ = i
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
dAtA[i] = 0xa
|
|
||||||
i++
|
|
||||||
i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size()))
|
|
||||||
n3, err := m.ListMeta.MarshalTo(dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n3
|
|
||||||
if len(m.Items) > 0 {
|
|
||||||
for _, msg := range m.Items {
|
|
||||||
dAtA[i] = 0x12
|
|
||||||
i++
|
|
||||||
i = encodeVarintGenerated(dAtA, i, uint64(msg.Size()))
|
|
||||||
n, err := msg.MarshalTo(dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *PodPresetSpec) Marshal() (dAtA []byte, err error) {
|
|
||||||
size := m.Size()
|
|
||||||
dAtA = make([]byte, size)
|
|
||||||
n, err := m.MarshalTo(dAtA)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return dAtA[:n], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *PodPresetSpec) MarshalTo(dAtA []byte) (int, error) {
|
|
||||||
var i int
|
|
||||||
_ = i
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
dAtA[i] = 0xa
|
|
||||||
i++
|
|
||||||
i = encodeVarintGenerated(dAtA, i, uint64(m.Selector.Size()))
|
|
||||||
n4, err := m.Selector.MarshalTo(dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n4
|
|
||||||
if len(m.Env) > 0 {
|
|
||||||
for _, msg := range m.Env {
|
|
||||||
dAtA[i] = 0x12
|
|
||||||
i++
|
|
||||||
i = encodeVarintGenerated(dAtA, i, uint64(msg.Size()))
|
|
||||||
n, err := msg.MarshalTo(dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(m.EnvFrom) > 0 {
|
|
||||||
for _, msg := range m.EnvFrom {
|
|
||||||
dAtA[i] = 0x1a
|
|
||||||
i++
|
|
||||||
i = encodeVarintGenerated(dAtA, i, uint64(msg.Size()))
|
|
||||||
n, err := msg.MarshalTo(dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(m.Volumes) > 0 {
|
|
||||||
for _, msg := range m.Volumes {
|
|
||||||
dAtA[i] = 0x22
|
|
||||||
i++
|
|
||||||
i = encodeVarintGenerated(dAtA, i, uint64(msg.Size()))
|
|
||||||
n, err := msg.MarshalTo(dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(m.VolumeMounts) > 0 {
|
|
||||||
for _, msg := range m.VolumeMounts {
|
|
||||||
dAtA[i] = 0x2a
|
|
||||||
i++
|
|
||||||
i = encodeVarintGenerated(dAtA, i, uint64(msg.Size()))
|
|
||||||
n, err := msg.MarshalTo(dAtA[i:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i += n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int {
|
|
||||||
for v >= 1<<7 {
|
|
||||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
|
||||||
v >>= 7
|
|
||||||
offset++
|
|
||||||
}
|
|
||||||
dAtA[offset] = uint8(v)
|
|
||||||
return offset + 1
|
|
||||||
}
|
|
||||||
func (m *PodPreset) Size() (n int) {
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
l = m.ObjectMeta.Size()
|
|
||||||
n += 1 + l + sovGenerated(uint64(l))
|
|
||||||
l = m.Spec.Size()
|
|
||||||
n += 1 + l + sovGenerated(uint64(l))
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *PodPresetList) Size() (n int) {
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
l = m.ListMeta.Size()
|
|
||||||
n += 1 + l + sovGenerated(uint64(l))
|
|
||||||
if len(m.Items) > 0 {
|
|
||||||
for _, e := range m.Items {
|
|
||||||
l = e.Size()
|
|
||||||
n += 1 + l + sovGenerated(uint64(l))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *PodPresetSpec) Size() (n int) {
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
l = m.Selector.Size()
|
|
||||||
n += 1 + l + sovGenerated(uint64(l))
|
|
||||||
if len(m.Env) > 0 {
|
|
||||||
for _, e := range m.Env {
|
|
||||||
l = e.Size()
|
|
||||||
n += 1 + l + sovGenerated(uint64(l))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(m.EnvFrom) > 0 {
|
|
||||||
for _, e := range m.EnvFrom {
|
|
||||||
l = e.Size()
|
|
||||||
n += 1 + l + sovGenerated(uint64(l))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(m.Volumes) > 0 {
|
|
||||||
for _, e := range m.Volumes {
|
|
||||||
l = e.Size()
|
|
||||||
n += 1 + l + sovGenerated(uint64(l))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(m.VolumeMounts) > 0 {
|
|
||||||
for _, e := range m.VolumeMounts {
|
|
||||||
l = e.Size()
|
|
||||||
n += 1 + l + sovGenerated(uint64(l))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func sovGenerated(x uint64) (n int) {
|
|
||||||
for {
|
|
||||||
n++
|
|
||||||
x >>= 7
|
|
||||||
if x == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
func sozGenerated(x uint64) (n int) {
|
|
||||||
return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
|
||||||
}
|
|
||||||
func (this *PodPreset) String() string {
|
|
||||||
if this == nil {
|
|
||||||
return "nil"
|
|
||||||
}
|
|
||||||
s := strings.Join([]string{`&PodPreset{`,
|
|
||||||
`ObjectMeta:` + strings.Replace(strings.Replace(this.ObjectMeta.String(), "ObjectMeta", "k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta", 1), `&`, ``, 1) + `,`,
|
|
||||||
`Spec:` + strings.Replace(strings.Replace(this.Spec.String(), "PodPresetSpec", "PodPresetSpec", 1), `&`, ``, 1) + `,`,
|
|
||||||
`}`,
|
|
||||||
}, "")
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
func (this *PodPresetList) String() string {
|
|
||||||
if this == nil {
|
|
||||||
return "nil"
|
|
||||||
}
|
|
||||||
s := strings.Join([]string{`&PodPresetList{`,
|
|
||||||
`ListMeta:` + strings.Replace(strings.Replace(this.ListMeta.String(), "ListMeta", "k8s_io_apimachinery_pkg_apis_meta_v1.ListMeta", 1), `&`, ``, 1) + `,`,
|
|
||||||
`Items:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Items), "PodPreset", "PodPreset", 1), `&`, ``, 1) + `,`,
|
|
||||||
`}`,
|
|
||||||
}, "")
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
func (this *PodPresetSpec) String() string {
|
|
||||||
if this == nil {
|
|
||||||
return "nil"
|
|
||||||
}
|
|
||||||
s := strings.Join([]string{`&PodPresetSpec{`,
|
|
||||||
`Selector:` + strings.Replace(strings.Replace(this.Selector.String(), "LabelSelector", "k8s_io_apimachinery_pkg_apis_meta_v1.LabelSelector", 1), `&`, ``, 1) + `,`,
|
|
||||||
`Env:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Env), "EnvVar", "k8s_io_api_core_v1.EnvVar", 1), `&`, ``, 1) + `,`,
|
|
||||||
`EnvFrom:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.EnvFrom), "EnvFromSource", "k8s_io_api_core_v1.EnvFromSource", 1), `&`, ``, 1) + `,`,
|
|
||||||
`Volumes:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Volumes), "Volume", "k8s_io_api_core_v1.Volume", 1), `&`, ``, 1) + `,`,
|
|
||||||
`VolumeMounts:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.VolumeMounts), "VolumeMount", "k8s_io_api_core_v1.VolumeMount", 1), `&`, ``, 1) + `,`,
|
|
||||||
`}`,
|
|
||||||
}, "")
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
func valueToStringGenerated(v interface{}) string {
|
|
||||||
rv := reflect.ValueOf(v)
|
|
||||||
if rv.IsNil() {
|
|
||||||
return "nil"
|
|
||||||
}
|
|
||||||
pv := reflect.Indirect(rv).Interface()
|
|
||||||
return fmt.Sprintf("*%v", pv)
|
|
||||||
}
|
|
||||||
func (m *PodPreset) Unmarshal(dAtA []byte) error {
|
|
||||||
l := len(dAtA)
|
|
||||||
iNdEx := 0
|
|
||||||
for iNdEx < l {
|
|
||||||
preIndex := iNdEx
|
|
||||||
var wire uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
wire |= (uint64(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldNum := int32(wire >> 3)
|
|
||||||
wireType := int(wire & 0x7)
|
|
||||||
if wireType == 4 {
|
|
||||||
return fmt.Errorf("proto: PodPreset: wiretype end group for non-group")
|
|
||||||
}
|
|
||||||
if fieldNum <= 0 {
|
|
||||||
return fmt.Errorf("proto: PodPreset: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
||||||
}
|
|
||||||
switch fieldNum {
|
|
||||||
case 1:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field ObjectMeta", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
if err := m.ObjectMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 2:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
default:
|
|
||||||
iNdEx = preIndex
|
|
||||||
skippy, err := skipGenerated(dAtA[iNdEx:])
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if skippy < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
if (iNdEx + skippy) > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
iNdEx += skippy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if iNdEx > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (m *PodPresetList) Unmarshal(dAtA []byte) error {
|
|
||||||
l := len(dAtA)
|
|
||||||
iNdEx := 0
|
|
||||||
for iNdEx < l {
|
|
||||||
preIndex := iNdEx
|
|
||||||
var wire uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
wire |= (uint64(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldNum := int32(wire >> 3)
|
|
||||||
wireType := int(wire & 0x7)
|
|
||||||
if wireType == 4 {
|
|
||||||
return fmt.Errorf("proto: PodPresetList: wiretype end group for non-group")
|
|
||||||
}
|
|
||||||
if fieldNum <= 0 {
|
|
||||||
return fmt.Errorf("proto: PodPresetList: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
||||||
}
|
|
||||||
switch fieldNum {
|
|
||||||
case 1:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 2:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
m.Items = append(m.Items, PodPreset{})
|
|
||||||
if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
default:
|
|
||||||
iNdEx = preIndex
|
|
||||||
skippy, err := skipGenerated(dAtA[iNdEx:])
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if skippy < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
if (iNdEx + skippy) > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
iNdEx += skippy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if iNdEx > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (m *PodPresetSpec) Unmarshal(dAtA []byte) error {
|
|
||||||
l := len(dAtA)
|
|
||||||
iNdEx := 0
|
|
||||||
for iNdEx < l {
|
|
||||||
preIndex := iNdEx
|
|
||||||
var wire uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
wire |= (uint64(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldNum := int32(wire >> 3)
|
|
||||||
wireType := int(wire & 0x7)
|
|
||||||
if wireType == 4 {
|
|
||||||
return fmt.Errorf("proto: PodPresetSpec: wiretype end group for non-group")
|
|
||||||
}
|
|
||||||
if fieldNum <= 0 {
|
|
||||||
return fmt.Errorf("proto: PodPresetSpec: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
||||||
}
|
|
||||||
switch fieldNum {
|
|
||||||
case 1:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Selector", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
if err := m.Selector.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 2:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Env", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
m.Env = append(m.Env, k8s_io_api_core_v1.EnvVar{})
|
|
||||||
if err := m.Env[len(m.Env)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 3:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field EnvFrom", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
m.EnvFrom = append(m.EnvFrom, k8s_io_api_core_v1.EnvFromSource{})
|
|
||||||
if err := m.EnvFrom[len(m.EnvFrom)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 4:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Volumes", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
m.Volumes = append(m.Volumes, k8s_io_api_core_v1.Volume{})
|
|
||||||
if err := m.Volumes[len(m.Volumes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 5:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field VolumeMounts", wireType)
|
|
||||||
}
|
|
||||||
var msglen int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
msglen |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if msglen < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + msglen
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
m.VolumeMounts = append(m.VolumeMounts, k8s_io_api_core_v1.VolumeMount{})
|
|
||||||
if err := m.VolumeMounts[len(m.VolumeMounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
default:
|
|
||||||
iNdEx = preIndex
|
|
||||||
skippy, err := skipGenerated(dAtA[iNdEx:])
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if skippy < 0 {
|
|
||||||
return ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
if (iNdEx + skippy) > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
iNdEx += skippy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if iNdEx > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func skipGenerated(dAtA []byte) (n int, err error) {
|
|
||||||
l := len(dAtA)
|
|
||||||
iNdEx := 0
|
|
||||||
for iNdEx < l {
|
|
||||||
var wire uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return 0, ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return 0, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
wire |= (uint64(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wireType := int(wire & 0x7)
|
|
||||||
switch wireType {
|
|
||||||
case 0:
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return 0, ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return 0, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
iNdEx++
|
|
||||||
if dAtA[iNdEx-1] < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return iNdEx, nil
|
|
||||||
case 1:
|
|
||||||
iNdEx += 8
|
|
||||||
return iNdEx, nil
|
|
||||||
case 2:
|
|
||||||
var length int
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return 0, ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return 0, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
length |= (int(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iNdEx += length
|
|
||||||
if length < 0 {
|
|
||||||
return 0, ErrInvalidLengthGenerated
|
|
||||||
}
|
|
||||||
return iNdEx, nil
|
|
||||||
case 3:
|
|
||||||
for {
|
|
||||||
var innerWire uint64
|
|
||||||
var start int = iNdEx
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return 0, ErrIntOverflowGenerated
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return 0, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
innerWire |= (uint64(b) & 0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
innerWireType := int(innerWire & 0x7)
|
|
||||||
if innerWireType == 4 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
next, err := skipGenerated(dAtA[start:])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
iNdEx = start + next
|
|
||||||
}
|
|
||||||
return iNdEx, nil
|
|
||||||
case 4:
|
|
||||||
return iNdEx, nil
|
|
||||||
case 5:
|
|
||||||
iNdEx += 4
|
|
||||||
return iNdEx, nil
|
|
||||||
default:
|
|
||||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
|
|
||||||
ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/api/settings/v1alpha1/generated.proto", fileDescriptorGenerated)
|
|
||||||
}
|
|
||||||
|
|
||||||
var fileDescriptorGenerated = []byte{
|
|
||||||
// 542 bytes of a gzipped FileDescriptorProto
|
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0x8e, 0xd2, 0x40,
|
|
||||||
0x1c, 0xc6, 0xe9, 0xb2, 0x04, 0x1c, 0xd8, 0x68, 0x1a, 0x0f, 0x0d, 0x31, 0x65, 0xe5, 0xe2, 0x26,
|
|
||||||
0xc6, 0x19, 0x59, 0x8d, 0xd1, 0x6b, 0x13, 0x4c, 0x4c, 0x20, 0x6e, 0x4a, 0xb2, 0x89, 0xc6, 0x83,
|
|
||||||
0x43, 0xf9, 0x5b, 0x2a, 0xb4, 0xd3, 0xcc, 0x4c, 0x9b, 0x78, 0xf3, 0x11, 0x7c, 0x01, 0x9f, 0x44,
|
|
||||||
0x1f, 0x80, 0xe3, 0x1e, 0xf7, 0xb4, 0x91, 0xfa, 0x22, 0x66, 0x86, 0x29, 0xa0, 0x88, 0x72, 0x9b,
|
|
||||||
0xff, 0x9f, 0xef, 0xfb, 0xcd, 0xf7, 0x31, 0x45, 0xfd, 0xd9, 0x73, 0x81, 0x23, 0x46, 0x66, 0xd9,
|
|
||||||
0x18, 0x78, 0x02, 0x12, 0x04, 0xc9, 0x21, 0x99, 0x30, 0x4e, 0xcc, 0x0f, 0x34, 0x8d, 0x88, 0x00,
|
|
||||||
0x29, 0xa3, 0x24, 0x14, 0x24, 0xef, 0xd1, 0x79, 0x3a, 0xa5, 0x3d, 0x12, 0x42, 0x02, 0x9c, 0x4a,
|
|
||||||
0x98, 0xe0, 0x94, 0x33, 0xc9, 0xec, 0x7b, 0x2b, 0x35, 0xa6, 0x69, 0x84, 0x4b, 0x35, 0x2e, 0xd5,
|
|
||||||
0xed, 0x47, 0x61, 0x24, 0xa7, 0xd9, 0x18, 0x07, 0x2c, 0x26, 0x21, 0x0b, 0x19, 0xd1, 0xa6, 0x71,
|
|
||||||
0xf6, 0x41, 0x4f, 0x7a, 0xd0, 0xa7, 0x15, 0xac, 0xdd, 0xdd, 0xba, 0x3a, 0x60, 0x1c, 0x48, 0xbe,
|
|
||||||
0x73, 0x61, 0xfb, 0xe9, 0x46, 0x13, 0xd3, 0x60, 0x1a, 0x25, 0xc0, 0x3f, 0x91, 0x74, 0x16, 0xaa,
|
|
||||||
0x85, 0x20, 0x31, 0x48, 0xfa, 0x37, 0x17, 0xd9, 0xe7, 0xe2, 0x59, 0x22, 0xa3, 0x18, 0x76, 0x0c,
|
|
||||||
0xcf, 0xfe, 0x67, 0x10, 0xc1, 0x14, 0x62, 0xfa, 0xa7, 0xaf, 0xfb, 0xdd, 0x42, 0xb7, 0x2e, 0xd8,
|
|
||||||
0xe4, 0x82, 0x83, 0x00, 0x69, 0xbf, 0x47, 0x0d, 0x95, 0x68, 0x42, 0x25, 0x75, 0xac, 0x53, 0xeb,
|
|
||||||
0xac, 0x79, 0xfe, 0x18, 0x6f, 0xfe, 0xb0, 0x35, 0x18, 0xa7, 0xb3, 0x50, 0x2d, 0x04, 0x56, 0x6a,
|
|
||||||
0x9c, 0xf7, 0xf0, 0xeb, 0xf1, 0x47, 0x08, 0xe4, 0x10, 0x24, 0xf5, 0xec, 0xc5, 0x4d, 0xa7, 0x52,
|
|
||||||
0xdc, 0x74, 0xd0, 0x66, 0xe7, 0xaf, 0xa9, 0xf6, 0x10, 0x1d, 0x8b, 0x14, 0x02, 0xe7, 0x48, 0xd3,
|
|
||||||
0x1f, 0xe2, 0x7f, 0x3d, 0x07, 0x5e, 0x07, 0x1b, 0xa5, 0x10, 0x78, 0x2d, 0x03, 0x3e, 0x56, 0x93,
|
|
||||||
0xaf, 0x31, 0xdd, 0x6f, 0x16, 0x3a, 0x59, 0xab, 0x06, 0x91, 0x90, 0xf6, 0xbb, 0x9d, 0x0a, 0xf8,
|
|
||||||
0xb0, 0x0a, 0xca, 0xad, 0x0b, 0xdc, 0x31, 0xf7, 0x34, 0xca, 0xcd, 0x56, 0xfc, 0x01, 0xaa, 0x45,
|
|
||||||
0x12, 0x62, 0xe1, 0x1c, 0x9d, 0x56, 0xcf, 0x9a, 0xe7, 0x0f, 0x0e, 0xcc, 0xef, 0x9d, 0x18, 0x66,
|
|
||||||
0xed, 0x95, 0x72, 0xfb, 0x2b, 0x48, 0xf7, 0x6b, 0x75, 0x2b, 0xbd, 0x6a, 0x65, 0x53, 0xd4, 0x10,
|
|
||||||
0x30, 0x87, 0x40, 0x32, 0x6e, 0xd2, 0x3f, 0x39, 0x30, 0x3d, 0x1d, 0xc3, 0x7c, 0x64, 0xac, 0x9b,
|
|
||||||
0x0a, 0xe5, 0xc6, 0x5f, 0x63, 0xed, 0x17, 0xa8, 0x0a, 0x49, 0x6e, 0x0a, 0xb4, 0xb7, 0x0b, 0xa8,
|
|
||||||
0x4f, 0x58, 0xb1, 0xfa, 0x49, 0x7e, 0x49, 0xb9, 0xd7, 0x34, 0x90, 0x6a, 0x3f, 0xc9, 0x7d, 0xe5,
|
|
||||||
0xb1, 0x07, 0xa8, 0x0e, 0x49, 0xfe, 0x92, 0xb3, 0xd8, 0xa9, 0x6a, 0xfb, 0xfd, 0x3d, 0x76, 0x25,
|
|
||||||
0x19, 0xb1, 0x8c, 0x07, 0xe0, 0xdd, 0x36, 0x94, 0xba, 0x59, 0xfb, 0x25, 0xc2, 0xee, 0xa3, 0x7a,
|
|
||||||
0xce, 0xe6, 0x59, 0x0c, 0xc2, 0x39, 0xde, 0x1f, 0xe6, 0x52, 0x4b, 0x36, 0x98, 0xd5, 0x2c, 0xfc,
|
|
||||||
0xd2, 0x6b, 0xbf, 0x41, 0xad, 0xd5, 0x71, 0xc8, 0xb2, 0x44, 0x0a, 0xa7, 0xa6, 0x59, 0x9d, 0xfd,
|
|
||||||
0x2c, 0xad, 0xf3, 0xee, 0x1a, 0x60, 0x6b, 0x6b, 0x29, 0xfc, 0xdf, 0x50, 0x1e, 0x5e, 0x2c, 0xdd,
|
|
||||||
0xca, 0xd5, 0xd2, 0xad, 0x5c, 0x2f, 0xdd, 0xca, 0xe7, 0xc2, 0xb5, 0x16, 0x85, 0x6b, 0x5d, 0x15,
|
|
||||||
0xae, 0x75, 0x5d, 0xb8, 0xd6, 0x8f, 0xc2, 0xb5, 0xbe, 0xfc, 0x74, 0x2b, 0x6f, 0x1b, 0xe5, 0x7b,
|
|
||||||
0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x46, 0x15, 0xf2, 0x97, 0xa4, 0x04, 0x00, 0x00,
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// This file was autogenerated by go-to-protobuf. Do not edit it manually!
|
|
||||||
|
|
||||||
syntax = 'proto2';
|
|
||||||
|
|
||||||
package k8s.io.api.settings.v1alpha1;
|
|
||||||
|
|
||||||
import "k8s.io/api/core/v1/generated.proto";
|
|
||||||
import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
|
|
||||||
import "k8s.io/apimachinery/pkg/runtime/generated.proto";
|
|
||||||
import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
|
|
||||||
|
|
||||||
// Package-wide variables from generator "generated".
|
|
||||||
option go_package = "v1alpha1";
|
|
||||||
|
|
||||||
// PodPreset is a policy resource that defines additional runtime
|
|
||||||
// requirements for a Pod.
|
|
||||||
message PodPreset {
|
|
||||||
// +optional
|
|
||||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
|
|
||||||
|
|
||||||
// +optional
|
|
||||||
optional PodPresetSpec spec = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodPresetList is a list of PodPreset objects.
|
|
||||||
message PodPresetList {
|
|
||||||
// Standard list metadata.
|
|
||||||
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
|
|
||||||
// +optional
|
|
||||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
|
|
||||||
|
|
||||||
// Items is a list of schema objects.
|
|
||||||
repeated PodPreset items = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodPresetSpec is a description of a pod preset.
|
|
||||||
message PodPresetSpec {
|
|
||||||
// Selector is a label query over a set of resources, in this case pods.
|
|
||||||
// Required.
|
|
||||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector selector = 1;
|
|
||||||
|
|
||||||
// Env defines the collection of EnvVar to inject into containers.
|
|
||||||
// +optional
|
|
||||||
repeated k8s.io.api.core.v1.EnvVar env = 2;
|
|
||||||
|
|
||||||
// EnvFrom defines the collection of EnvFromSource to inject into containers.
|
|
||||||
// +optional
|
|
||||||
repeated k8s.io.api.core.v1.EnvFromSource envFrom = 3;
|
|
||||||
|
|
||||||
// Volumes defines the collection of Volume to inject into the pod.
|
|
||||||
// +optional
|
|
||||||
repeated k8s.io.api.core.v1.Volume volumes = 4;
|
|
||||||
|
|
||||||
// VolumeMounts defines the collection of VolumeMount to inject into containers.
|
|
||||||
// +optional
|
|
||||||
repeated k8s.io.api.core.v1.VolumeMount volumeMounts = 5;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GroupName is the group name use in this package
|
|
||||||
const GroupName = "settings.k8s.io"
|
|
||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
|
||||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
|
|
||||||
|
|
||||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
|
||||||
func Resource(resource string) schema.GroupResource {
|
|
||||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
|
|
||||||
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
|
|
||||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
|
||||||
localSchemeBuilder = &SchemeBuilder
|
|
||||||
AddToScheme = localSchemeBuilder.AddToScheme
|
|
||||||
)
|
|
||||||
|
|
||||||
// Adds the list of known types to the given scheme.
|
|
||||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
|
||||||
&PodPreset{},
|
|
||||||
&PodPresetList{},
|
|
||||||
)
|
|
||||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2017 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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/api/core/v1"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// +genclient
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
|
||||||
|
|
||||||
// PodPreset is a policy resource that defines additional runtime
|
|
||||||
// requirements for a Pod.
|
|
||||||
type PodPreset struct {
|
|
||||||
metav1.TypeMeta `json:",inline"`
|
|
||||||
// +optional
|
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
|
||||||
|
|
||||||
// +optional
|
|
||||||
Spec PodPresetSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodPresetSpec is a description of a pod preset.
|
|
||||||
type PodPresetSpec struct {
|
|
||||||
// Selector is a label query over a set of resources, in this case pods.
|
|
||||||
// Required.
|
|
||||||
Selector metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,1,opt,name=selector"`
|
|
||||||
|
|
||||||
// Env defines the collection of EnvVar to inject into containers.
|
|
||||||
// +optional
|
|
||||||
Env []v1.EnvVar `json:"env,omitempty" protobuf:"bytes,2,rep,name=env"`
|
|
||||||
// EnvFrom defines the collection of EnvFromSource to inject into containers.
|
|
||||||
// +optional
|
|
||||||
EnvFrom []v1.EnvFromSource `json:"envFrom,omitempty" protobuf:"bytes,3,rep,name=envFrom"`
|
|
||||||
// Volumes defines the collection of Volume to inject into the pod.
|
|
||||||
// +optional
|
|
||||||
Volumes []v1.Volume `json:"volumes,omitempty" protobuf:"bytes,4,rep,name=volumes"`
|
|
||||||
// VolumeMounts defines the collection of VolumeMount to inject into containers.
|
|
||||||
// +optional
|
|
||||||
VolumeMounts []v1.VolumeMount `json:"volumeMounts,omitempty" protobuf:"bytes,5,rep,name=volumeMounts"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
|
||||||
|
|
||||||
// PodPresetList is a list of PodPreset objects.
|
|
||||||
type PodPresetList struct {
|
|
||||||
metav1.TypeMeta `json:",inline"`
|
|
||||||
// Standard list metadata.
|
|
||||||
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
|
|
||||||
// +optional
|
|
||||||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
|
||||||
|
|
||||||
// Items is a list of schema objects.
|
|
||||||
Items []PodPreset `json:"items" protobuf:"bytes,2,rep,name=items"`
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
// This file contains a collection of methods that can be used from go-restful to
|
|
||||||
// generate Swagger API documentation for its models. Please read this PR for more
|
|
||||||
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
|
|
||||||
//
|
|
||||||
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
|
|
||||||
// they are on one line! For multiple line or blocks that you want to ignore use ---.
|
|
||||||
// Any context after a --- is ignored.
|
|
||||||
//
|
|
||||||
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
|
|
||||||
|
|
||||||
// AUTO-GENERATED FUNCTIONS START HERE. DO NOT EDIT.
|
|
||||||
var map_PodPreset = map[string]string{
|
|
||||||
"": "PodPreset is a policy resource that defines additional runtime requirements for a Pod.",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (PodPreset) SwaggerDoc() map[string]string {
|
|
||||||
return map_PodPreset
|
|
||||||
}
|
|
||||||
|
|
||||||
var map_PodPresetList = map[string]string{
|
|
||||||
"": "PodPresetList is a list of PodPreset objects.",
|
|
||||||
"metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata",
|
|
||||||
"items": "Items is a list of schema objects.",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (PodPresetList) SwaggerDoc() map[string]string {
|
|
||||||
return map_PodPresetList
|
|
||||||
}
|
|
||||||
|
|
||||||
var map_PodPresetSpec = map[string]string{
|
|
||||||
"": "PodPresetSpec is a description of a pod preset.",
|
|
||||||
"selector": "Selector is a label query over a set of resources, in this case pods. Required.",
|
|
||||||
"env": "Env defines the collection of EnvVar to inject into containers.",
|
|
||||||
"envFrom": "EnvFrom defines the collection of EnvFromSource to inject into containers.",
|
|
||||||
"volumes": "Volumes defines the collection of Volume to inject into the pod.",
|
|
||||||
"volumeMounts": "VolumeMounts defines the collection of VolumeMount to inject into containers.",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (PodPresetSpec) SwaggerDoc() map[string]string {
|
|
||||||
return map_PodPresetSpec
|
|
||||||
}
|
|
||||||
|
|
||||||
// AUTO-GENERATED FUNCTIONS END HERE
|
|
|
@ -1,131 +0,0 @@
|
||||||
// +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 v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
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 *PodPreset) DeepCopyInto(out *PodPreset) {
|
|
||||||
*out = *in
|
|
||||||
out.TypeMeta = in.TypeMeta
|
|
||||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
|
||||||
in.Spec.DeepCopyInto(&out.Spec)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodPreset.
|
|
||||||
func (in *PodPreset) DeepCopy() *PodPreset {
|
|
||||||
if in == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
out := new(PodPreset)
|
|
||||||
in.DeepCopyInto(out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
||||||
func (in *PodPreset) 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 *PodPresetList) DeepCopyInto(out *PodPresetList) {
|
|
||||||
*out = *in
|
|
||||||
out.TypeMeta = in.TypeMeta
|
|
||||||
out.ListMeta = in.ListMeta
|
|
||||||
if in.Items != nil {
|
|
||||||
in, out := &in.Items, &out.Items
|
|
||||||
*out = make([]PodPreset, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodPresetList.
|
|
||||||
func (in *PodPresetList) DeepCopy() *PodPresetList {
|
|
||||||
if in == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
out := new(PodPresetList)
|
|
||||||
in.DeepCopyInto(out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
||||||
func (in *PodPresetList) 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 *PodPresetSpec) DeepCopyInto(out *PodPresetSpec) {
|
|
||||||
*out = *in
|
|
||||||
in.Selector.DeepCopyInto(&out.Selector)
|
|
||||||
if in.Env != nil {
|
|
||||||
in, out := &in.Env, &out.Env
|
|
||||||
*out = make([]v1.EnvVar, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if in.EnvFrom != nil {
|
|
||||||
in, out := &in.EnvFrom, &out.EnvFrom
|
|
||||||
*out = make([]v1.EnvFromSource, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if in.Volumes != nil {
|
|
||||||
in, out := &in.Volumes, &out.Volumes
|
|
||||||
*out = make([]v1.Volume, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if in.VolumeMounts != nil {
|
|
||||||
in, out := &in.VolumeMounts, &out.VolumeMounts
|
|
||||||
*out = make([]v1.VolumeMount, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodPresetSpec.
|
|
||||||
func (in *PodPresetSpec) DeepCopy() *PodPresetSpec {
|
|
||||||
if in == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
out := new(PodPresetSpec)
|
|
||||||
in.DeepCopyInto(out)
|
|
||||||
return out
|
|
||||||
}
|
|
|
@ -41,7 +41,6 @@ import (
|
||||||
policy "k8s.io/client-go/informers/policy"
|
policy "k8s.io/client-go/informers/policy"
|
||||||
rbac "k8s.io/client-go/informers/rbac"
|
rbac "k8s.io/client-go/informers/rbac"
|
||||||
scheduling "k8s.io/client-go/informers/scheduling"
|
scheduling "k8s.io/client-go/informers/scheduling"
|
||||||
settings "k8s.io/client-go/informers/settings"
|
|
||||||
storage "k8s.io/client-go/informers/storage"
|
storage "k8s.io/client-go/informers/storage"
|
||||||
kubernetes "k8s.io/client-go/kubernetes"
|
kubernetes "k8s.io/client-go/kubernetes"
|
||||||
cache "k8s.io/client-go/tools/cache"
|
cache "k8s.io/client-go/tools/cache"
|
||||||
|
@ -201,7 +200,6 @@ type SharedInformerFactory interface {
|
||||||
Policy() policy.Interface
|
Policy() policy.Interface
|
||||||
Rbac() rbac.Interface
|
Rbac() rbac.Interface
|
||||||
Scheduling() scheduling.Interface
|
Scheduling() scheduling.Interface
|
||||||
Settings() settings.Interface
|
|
||||||
Storage() storage.Interface
|
Storage() storage.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,10 +259,6 @@ func (f *sharedInformerFactory) Scheduling() scheduling.Interface {
|
||||||
return scheduling.New(f, f.namespace, f.tweakListOptions)
|
return scheduling.New(f, f.namespace, f.tweakListOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *sharedInformerFactory) Settings() settings.Interface {
|
|
||||||
return settings.New(f, f.namespace, f.tweakListOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *sharedInformerFactory) Storage() storage.Interface {
|
func (f *sharedInformerFactory) Storage() storage.Interface {
|
||||||
return storage.New(f, f.namespace, f.tweakListOptions)
|
return storage.New(f, f.namespace, f.tweakListOptions)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ import (
|
||||||
schedulingv1 "k8s.io/api/scheduling/v1"
|
schedulingv1 "k8s.io/api/scheduling/v1"
|
||||||
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
||||||
schedulingv1beta1 "k8s.io/api/scheduling/v1beta1"
|
schedulingv1beta1 "k8s.io/api/scheduling/v1beta1"
|
||||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
storagev1 "k8s.io/api/storage/v1"
|
||||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
||||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
@ -258,10 +257,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
|
||||||
case schedulingv1beta1.SchemeGroupVersion.WithResource("priorityclasses"):
|
case schedulingv1beta1.SchemeGroupVersion.WithResource("priorityclasses"):
|
||||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1beta1().PriorityClasses().Informer()}, nil
|
return &genericInformer{resource: resource.GroupResource(), informer: f.Scheduling().V1beta1().PriorityClasses().Informer()}, nil
|
||||||
|
|
||||||
// Group=settings.k8s.io, Version=v1alpha1
|
|
||||||
case settingsv1alpha1.SchemeGroupVersion.WithResource("podpresets"):
|
|
||||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Settings().V1alpha1().PodPresets().Informer()}, nil
|
|
||||||
|
|
||||||
// Group=storage.k8s.io, Version=v1
|
// Group=storage.k8s.io, Version=v1
|
||||||
case storagev1.SchemeGroupVersion.WithResource("storageclasses"):
|
case storagev1.SchemeGroupVersion.WithResource("storageclasses"):
|
||||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Storage().V1().StorageClasses().Informer()}, nil
|
return &genericInformer{resource: resource.GroupResource(), informer: f.Storage().V1().StorageClasses().Informer()}, nil
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"interface.go",
|
|
||||||
"podpreset.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/informers/settings/v1alpha1",
|
|
||||||
importpath = "k8s.io/client-go/informers/settings/v1alpha1",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/api/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/informers/internalinterfaces:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/listers/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
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 informer-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Interface provides access to all the informers in this group version.
|
|
||||||
type Interface interface {
|
|
||||||
// PodPresets returns a PodPresetInformer.
|
|
||||||
PodPresets() PodPresetInformer
|
|
||||||
}
|
|
||||||
|
|
||||||
type version struct {
|
|
||||||
factory internalinterfaces.SharedInformerFactory
|
|
||||||
namespace string
|
|
||||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns a new Interface.
|
|
||||||
func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface {
|
|
||||||
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodPresets returns a PodPresetInformer.
|
|
||||||
func (v *version) PodPresets() PodPresetInformer {
|
|
||||||
return &podPresetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
/*
|
|
||||||
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 informer-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
time "time"
|
|
||||||
|
|
||||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
|
||||||
kubernetes "k8s.io/client-go/kubernetes"
|
|
||||||
v1alpha1 "k8s.io/client-go/listers/settings/v1alpha1"
|
|
||||||
cache "k8s.io/client-go/tools/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PodPresetInformer provides access to a shared informer and lister for
|
|
||||||
// PodPresets.
|
|
||||||
type PodPresetInformer interface {
|
|
||||||
Informer() cache.SharedIndexInformer
|
|
||||||
Lister() v1alpha1.PodPresetLister
|
|
||||||
}
|
|
||||||
|
|
||||||
type podPresetInformer struct {
|
|
||||||
factory internalinterfaces.SharedInformerFactory
|
|
||||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
|
||||||
namespace string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewPodPresetInformer constructs a new informer for PodPreset type.
|
|
||||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
|
||||||
// one. This reduces memory footprint and number of connections to the server.
|
|
||||||
func NewPodPresetInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
|
||||||
return NewFilteredPodPresetInformer(client, namespace, resyncPeriod, indexers, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewFilteredPodPresetInformer constructs a new informer for PodPreset type.
|
|
||||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
|
||||||
// one. This reduces memory footprint and number of connections to the server.
|
|
||||||
func NewFilteredPodPresetInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
|
||||||
return cache.NewSharedIndexInformer(
|
|
||||||
&cache.ListWatch{
|
|
||||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
|
||||||
if tweakListOptions != nil {
|
|
||||||
tweakListOptions(&options)
|
|
||||||
}
|
|
||||||
return client.SettingsV1alpha1().PodPresets(namespace).List(options)
|
|
||||||
},
|
|
||||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
|
||||||
if tweakListOptions != nil {
|
|
||||||
tweakListOptions(&options)
|
|
||||||
}
|
|
||||||
return client.SettingsV1alpha1().PodPresets(namespace).Watch(options)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
&settingsv1alpha1.PodPreset{},
|
|
||||||
resyncPeriod,
|
|
||||||
indexers,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *podPresetInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
|
||||||
return NewFilteredPodPresetInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *podPresetInformer) Informer() cache.SharedIndexInformer {
|
|
||||||
return f.factory.InformerFor(&settingsv1alpha1.PodPreset{}, f.defaultInformer)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *podPresetInformer) Lister() v1alpha1.PodPresetLister {
|
|
||||||
return v1alpha1.NewPodPresetLister(f.Informer().GetIndexer())
|
|
||||||
}
|
|
|
@ -49,7 +49,6 @@ import (
|
||||||
schedulingv1 "k8s.io/client-go/kubernetes/typed/scheduling/v1"
|
schedulingv1 "k8s.io/client-go/kubernetes/typed/scheduling/v1"
|
||||||
schedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1"
|
schedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1"
|
||||||
schedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1"
|
schedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1"
|
||||||
settingsv1alpha1 "k8s.io/client-go/kubernetes/typed/settings/v1alpha1"
|
|
||||||
storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
|
storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
|
||||||
storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1"
|
storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1"
|
||||||
rest "k8s.io/client-go/rest"
|
rest "k8s.io/client-go/rest"
|
||||||
|
@ -87,7 +86,6 @@ type Interface interface {
|
||||||
SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface
|
SchedulingV1alpha1() schedulingv1alpha1.SchedulingV1alpha1Interface
|
||||||
SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface
|
SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface
|
||||||
SchedulingV1() schedulingv1.SchedulingV1Interface
|
SchedulingV1() schedulingv1.SchedulingV1Interface
|
||||||
SettingsV1alpha1() settingsv1alpha1.SettingsV1alpha1Interface
|
|
||||||
StorageV1beta1() storagev1beta1.StorageV1beta1Interface
|
StorageV1beta1() storagev1beta1.StorageV1beta1Interface
|
||||||
StorageV1() storagev1.StorageV1Interface
|
StorageV1() storagev1.StorageV1Interface
|
||||||
}
|
}
|
||||||
|
@ -125,7 +123,6 @@ type Clientset struct {
|
||||||
schedulingV1alpha1 *schedulingv1alpha1.SchedulingV1alpha1Client
|
schedulingV1alpha1 *schedulingv1alpha1.SchedulingV1alpha1Client
|
||||||
schedulingV1beta1 *schedulingv1beta1.SchedulingV1beta1Client
|
schedulingV1beta1 *schedulingv1beta1.SchedulingV1beta1Client
|
||||||
schedulingV1 *schedulingv1.SchedulingV1Client
|
schedulingV1 *schedulingv1.SchedulingV1Client
|
||||||
settingsV1alpha1 *settingsv1alpha1.SettingsV1alpha1Client
|
|
||||||
storageV1beta1 *storagev1beta1.StorageV1beta1Client
|
storageV1beta1 *storagev1beta1.StorageV1beta1Client
|
||||||
storageV1 *storagev1.StorageV1Client
|
storageV1 *storagev1.StorageV1Client
|
||||||
}
|
}
|
||||||
|
@ -275,11 +272,6 @@ func (c *Clientset) SchedulingV1() schedulingv1.SchedulingV1Interface {
|
||||||
return c.schedulingV1
|
return c.schedulingV1
|
||||||
}
|
}
|
||||||
|
|
||||||
// SettingsV1alpha1 retrieves the SettingsV1alpha1Client
|
|
||||||
func (c *Clientset) SettingsV1alpha1() settingsv1alpha1.SettingsV1alpha1Interface {
|
|
||||||
return c.settingsV1alpha1
|
|
||||||
}
|
|
||||||
|
|
||||||
// StorageV1beta1 retrieves the StorageV1beta1Client
|
// StorageV1beta1 retrieves the StorageV1beta1Client
|
||||||
func (c *Clientset) StorageV1beta1() storagev1beta1.StorageV1beta1Interface {
|
func (c *Clientset) StorageV1beta1() storagev1beta1.StorageV1beta1Interface {
|
||||||
return c.storageV1beta1
|
return c.storageV1beta1
|
||||||
|
@ -422,10 +414,6 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cs.settingsV1alpha1, err = settingsv1alpha1.NewForConfig(&configShallowCopy)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
cs.storageV1beta1, err = storagev1beta1.NewForConfig(&configShallowCopy)
|
cs.storageV1beta1, err = storagev1beta1.NewForConfig(&configShallowCopy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -475,7 +463,6 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||||
cs.schedulingV1alpha1 = schedulingv1alpha1.NewForConfigOrDie(c)
|
cs.schedulingV1alpha1 = schedulingv1alpha1.NewForConfigOrDie(c)
|
||||||
cs.schedulingV1beta1 = schedulingv1beta1.NewForConfigOrDie(c)
|
cs.schedulingV1beta1 = schedulingv1beta1.NewForConfigOrDie(c)
|
||||||
cs.schedulingV1 = schedulingv1.NewForConfigOrDie(c)
|
cs.schedulingV1 = schedulingv1.NewForConfigOrDie(c)
|
||||||
cs.settingsV1alpha1 = settingsv1alpha1.NewForConfigOrDie(c)
|
|
||||||
cs.storageV1beta1 = storagev1beta1.NewForConfigOrDie(c)
|
cs.storageV1beta1 = storagev1beta1.NewForConfigOrDie(c)
|
||||||
cs.storageV1 = storagev1.NewForConfigOrDie(c)
|
cs.storageV1 = storagev1.NewForConfigOrDie(c)
|
||||||
|
|
||||||
|
@ -515,7 +502,6 @@ func New(c rest.Interface) *Clientset {
|
||||||
cs.schedulingV1alpha1 = schedulingv1alpha1.New(c)
|
cs.schedulingV1alpha1 = schedulingv1alpha1.New(c)
|
||||||
cs.schedulingV1beta1 = schedulingv1beta1.New(c)
|
cs.schedulingV1beta1 = schedulingv1beta1.New(c)
|
||||||
cs.schedulingV1 = schedulingv1.New(c)
|
cs.schedulingV1 = schedulingv1.New(c)
|
||||||
cs.settingsV1alpha1 = settingsv1alpha1.New(c)
|
|
||||||
cs.storageV1beta1 = storagev1beta1.New(c)
|
cs.storageV1beta1 = storagev1beta1.New(c)
|
||||||
cs.storageV1 = storagev1.New(c)
|
cs.storageV1 = storagev1.New(c)
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,6 @@ import (
|
||||||
fakeschedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1/fake"
|
fakeschedulingv1alpha1 "k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1/fake"
|
||||||
schedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1"
|
schedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1"
|
||||||
fakeschedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1/fake"
|
fakeschedulingv1beta1 "k8s.io/client-go/kubernetes/typed/scheduling/v1beta1/fake"
|
||||||
settingsv1alpha1 "k8s.io/client-go/kubernetes/typed/settings/v1alpha1"
|
|
||||||
fakesettingsv1alpha1 "k8s.io/client-go/kubernetes/typed/settings/v1alpha1/fake"
|
|
||||||
storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
|
storagev1 "k8s.io/client-go/kubernetes/typed/storage/v1"
|
||||||
fakestoragev1 "k8s.io/client-go/kubernetes/typed/storage/v1/fake"
|
fakestoragev1 "k8s.io/client-go/kubernetes/typed/storage/v1/fake"
|
||||||
storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1"
|
storagev1beta1 "k8s.io/client-go/kubernetes/typed/storage/v1beta1"
|
||||||
|
@ -278,11 +276,6 @@ func (c *Clientset) SchedulingV1() schedulingv1.SchedulingV1Interface {
|
||||||
return &fakeschedulingv1.FakeSchedulingV1{Fake: &c.Fake}
|
return &fakeschedulingv1.FakeSchedulingV1{Fake: &c.Fake}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SettingsV1alpha1 retrieves the SettingsV1alpha1Client
|
|
||||||
func (c *Clientset) SettingsV1alpha1() settingsv1alpha1.SettingsV1alpha1Interface {
|
|
||||||
return &fakesettingsv1alpha1.FakeSettingsV1alpha1{Fake: &c.Fake}
|
|
||||||
}
|
|
||||||
|
|
||||||
// StorageV1beta1 retrieves the StorageV1beta1Client
|
// StorageV1beta1 retrieves the StorageV1beta1Client
|
||||||
func (c *Clientset) StorageV1beta1() storagev1beta1.StorageV1beta1Interface {
|
func (c *Clientset) StorageV1beta1() storagev1beta1.StorageV1beta1Interface {
|
||||||
return &fakestoragev1beta1.FakeStorageV1beta1{Fake: &c.Fake}
|
return &fakestoragev1beta1.FakeStorageV1beta1{Fake: &c.Fake}
|
||||||
|
|
|
@ -48,7 +48,6 @@ import (
|
||||||
schedulingv1 "k8s.io/api/scheduling/v1"
|
schedulingv1 "k8s.io/api/scheduling/v1"
|
||||||
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
||||||
schedulingv1beta1 "k8s.io/api/scheduling/v1beta1"
|
schedulingv1beta1 "k8s.io/api/scheduling/v1beta1"
|
||||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
storagev1 "k8s.io/api/storage/v1"
|
||||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -91,7 +90,6 @@ var localSchemeBuilder = runtime.SchemeBuilder{
|
||||||
schedulingv1alpha1.AddToScheme,
|
schedulingv1alpha1.AddToScheme,
|
||||||
schedulingv1beta1.AddToScheme,
|
schedulingv1beta1.AddToScheme,
|
||||||
schedulingv1.AddToScheme,
|
schedulingv1.AddToScheme,
|
||||||
settingsv1alpha1.AddToScheme,
|
|
||||||
storagev1beta1.AddToScheme,
|
storagev1beta1.AddToScheme,
|
||||||
storagev1.AddToScheme,
|
storagev1.AddToScheme,
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ import (
|
||||||
schedulingv1 "k8s.io/api/scheduling/v1"
|
schedulingv1 "k8s.io/api/scheduling/v1"
|
||||||
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
schedulingv1alpha1 "k8s.io/api/scheduling/v1alpha1"
|
||||||
schedulingv1beta1 "k8s.io/api/scheduling/v1beta1"
|
schedulingv1beta1 "k8s.io/api/scheduling/v1beta1"
|
||||||
settingsv1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
storagev1 "k8s.io/api/storage/v1"
|
storagev1 "k8s.io/api/storage/v1"
|
||||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -91,7 +90,6 @@ var localSchemeBuilder = runtime.SchemeBuilder{
|
||||||
schedulingv1alpha1.AddToScheme,
|
schedulingv1alpha1.AddToScheme,
|
||||||
schedulingv1beta1.AddToScheme,
|
schedulingv1beta1.AddToScheme,
|
||||||
schedulingv1.AddToScheme,
|
schedulingv1.AddToScheme,
|
||||||
settingsv1alpha1.AddToScheme,
|
|
||||||
storagev1beta1.AddToScheme,
|
storagev1beta1.AddToScheme,
|
||||||
storagev1.AddToScheme,
|
storagev1.AddToScheme,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"doc.go",
|
|
||||||
"generated_expansion.go",
|
|
||||||
"podpreset.go",
|
|
||||||
"settings_client.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/typed/settings/v1alpha1",
|
|
||||||
importpath = "k8s.io/client-go/kubernetes/typed/settings/v1alpha1",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/api/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/kubernetes/scheme:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [
|
|
||||||
":package-srcs",
|
|
||||||
"//staging/src/k8s.io/client-go/kubernetes/typed/settings/v1alpha1/fake:all-srcs",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,20 +0,0 @@
|
||||||
/*
|
|
||||||
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 client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
// This package has the automatically generated typed clients.
|
|
||||||
package v1alpha1
|
|
|
@ -1,41 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"doc.go",
|
|
||||||
"fake_podpreset.go",
|
|
||||||
"fake_settings_client.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/kubernetes/typed/settings/v1alpha1/fake",
|
|
||||||
importpath = "k8s.io/client-go/kubernetes/typed/settings/v1alpha1/fake",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/api/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/kubernetes/typed/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/testing:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,20 +0,0 @@
|
||||||
/*
|
|
||||||
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 client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
// Package fake has the automatically generated clients.
|
|
||||||
package fake
|
|
|
@ -1,128 +0,0 @@
|
||||||
/*
|
|
||||||
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 client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package fake
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
labels "k8s.io/apimachinery/pkg/labels"
|
|
||||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
testing "k8s.io/client-go/testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FakePodPresets implements PodPresetInterface
|
|
||||||
type FakePodPresets struct {
|
|
||||||
Fake *FakeSettingsV1alpha1
|
|
||||||
ns string
|
|
||||||
}
|
|
||||||
|
|
||||||
var podpresetsResource = schema.GroupVersionResource{Group: "settings.k8s.io", Version: "v1alpha1", Resource: "podpresets"}
|
|
||||||
|
|
||||||
var podpresetsKind = schema.GroupVersionKind{Group: "settings.k8s.io", Version: "v1alpha1", Kind: "PodPreset"}
|
|
||||||
|
|
||||||
// Get takes name of the podPreset, and returns the corresponding podPreset object, and an error if there is any.
|
|
||||||
func (c *FakePodPresets) Get(name string, options v1.GetOptions) (result *v1alpha1.PodPreset, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewGetAction(podpresetsResource, c.ns, name), &v1alpha1.PodPreset{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodPreset), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// List takes label and field selectors, and returns the list of PodPresets that match those selectors.
|
|
||||||
func (c *FakePodPresets) List(opts v1.ListOptions) (result *v1alpha1.PodPresetList, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewListAction(podpresetsResource, podpresetsKind, c.ns, opts), &v1alpha1.PodPresetList{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
|
||||||
if label == nil {
|
|
||||||
label = labels.Everything()
|
|
||||||
}
|
|
||||||
list := &v1alpha1.PodPresetList{ListMeta: obj.(*v1alpha1.PodPresetList).ListMeta}
|
|
||||||
for _, item := range obj.(*v1alpha1.PodPresetList).Items {
|
|
||||||
if label.Matches(labels.Set(item.Labels)) {
|
|
||||||
list.Items = append(list.Items, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested podPresets.
|
|
||||||
func (c *FakePodPresets) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
return c.Fake.
|
|
||||||
InvokesWatch(testing.NewWatchAction(podpresetsResource, c.ns, opts))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create takes the representation of a podPreset and creates it. Returns the server's representation of the podPreset, and an error, if there is any.
|
|
||||||
func (c *FakePodPresets) Create(podPreset *v1alpha1.PodPreset) (result *v1alpha1.PodPreset, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewCreateAction(podpresetsResource, c.ns, podPreset), &v1alpha1.PodPreset{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodPreset), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update takes the representation of a podPreset and updates it. Returns the server's representation of the podPreset, and an error, if there is any.
|
|
||||||
func (c *FakePodPresets) Update(podPreset *v1alpha1.PodPreset) (result *v1alpha1.PodPreset, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewUpdateAction(podpresetsResource, c.ns, podPreset), &v1alpha1.PodPreset{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodPreset), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete takes name of the podPreset and deletes it. Returns an error if one occurs.
|
|
||||||
func (c *FakePodPresets) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
_, err := c.Fake.
|
|
||||||
Invokes(testing.NewDeleteAction(podpresetsResource, c.ns, name), &v1alpha1.PodPreset{})
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCollection deletes a collection of objects.
|
|
||||||
func (c *FakePodPresets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
action := testing.NewDeleteCollectionAction(podpresetsResource, c.ns, listOptions)
|
|
||||||
|
|
||||||
_, err := c.Fake.Invokes(action, &v1alpha1.PodPresetList{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched podPreset.
|
|
||||||
func (c *FakePodPresets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodPreset, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewPatchSubresourceAction(podpresetsResource, c.ns, name, pt, data, subresources...), &v1alpha1.PodPreset{})
|
|
||||||
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodPreset), err
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
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 client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package fake
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1alpha1 "k8s.io/client-go/kubernetes/typed/settings/v1alpha1"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
testing "k8s.io/client-go/testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
type FakeSettingsV1alpha1 struct {
|
|
||||||
*testing.Fake
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeSettingsV1alpha1) PodPresets(namespace string) v1alpha1.PodPresetInterface {
|
|
||||||
return &FakePodPresets{c, namespace}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RESTClient returns a RESTClient that is used to communicate
|
|
||||||
// with API server by this client implementation.
|
|
||||||
func (c *FakeSettingsV1alpha1) RESTClient() rest.Interface {
|
|
||||||
var ret *rest.RESTClient
|
|
||||||
return ret
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
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 client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
type PodPresetExpansion interface{}
|
|
|
@ -1,174 +0,0 @@
|
||||||
/*
|
|
||||||
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 client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
v1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PodPresetsGetter has a method to return a PodPresetInterface.
|
|
||||||
// A group's client should implement this interface.
|
|
||||||
type PodPresetsGetter interface {
|
|
||||||
PodPresets(namespace string) PodPresetInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodPresetInterface has methods to work with PodPreset resources.
|
|
||||||
type PodPresetInterface interface {
|
|
||||||
Create(*v1alpha1.PodPreset) (*v1alpha1.PodPreset, error)
|
|
||||||
Update(*v1alpha1.PodPreset) (*v1alpha1.PodPreset, error)
|
|
||||||
Delete(name string, options *v1.DeleteOptions) error
|
|
||||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
|
||||||
Get(name string, options v1.GetOptions) (*v1alpha1.PodPreset, error)
|
|
||||||
List(opts v1.ListOptions) (*v1alpha1.PodPresetList, error)
|
|
||||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
|
||||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodPreset, err error)
|
|
||||||
PodPresetExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// podPresets implements PodPresetInterface
|
|
||||||
type podPresets struct {
|
|
||||||
client rest.Interface
|
|
||||||
ns string
|
|
||||||
}
|
|
||||||
|
|
||||||
// newPodPresets returns a PodPresets
|
|
||||||
func newPodPresets(c *SettingsV1alpha1Client, namespace string) *podPresets {
|
|
||||||
return &podPresets{
|
|
||||||
client: c.RESTClient(),
|
|
||||||
ns: namespace,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get takes name of the podPreset, and returns the corresponding podPreset object, and an error if there is any.
|
|
||||||
func (c *podPresets) Get(name string, options v1.GetOptions) (result *v1alpha1.PodPreset, err error) {
|
|
||||||
result = &v1alpha1.PodPreset{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("podpresets").
|
|
||||||
Name(name).
|
|
||||||
VersionedParams(&options, scheme.ParameterCodec).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// List takes label and field selectors, and returns the list of PodPresets that match those selectors.
|
|
||||||
func (c *podPresets) List(opts v1.ListOptions) (result *v1alpha1.PodPresetList, err error) {
|
|
||||||
var timeout time.Duration
|
|
||||||
if opts.TimeoutSeconds != nil {
|
|
||||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
|
||||||
}
|
|
||||||
result = &v1alpha1.PodPresetList{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("podpresets").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Timeout(timeout).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested podPresets.
|
|
||||||
func (c *podPresets) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
var timeout time.Duration
|
|
||||||
if opts.TimeoutSeconds != nil {
|
|
||||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
|
||||||
}
|
|
||||||
opts.Watch = true
|
|
||||||
return c.client.Get().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("podpresets").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Timeout(timeout).
|
|
||||||
Watch()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create takes the representation of a podPreset and creates it. Returns the server's representation of the podPreset, and an error, if there is any.
|
|
||||||
func (c *podPresets) Create(podPreset *v1alpha1.PodPreset) (result *v1alpha1.PodPreset, err error) {
|
|
||||||
result = &v1alpha1.PodPreset{}
|
|
||||||
err = c.client.Post().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("podpresets").
|
|
||||||
Body(podPreset).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update takes the representation of a podPreset and updates it. Returns the server's representation of the podPreset, and an error, if there is any.
|
|
||||||
func (c *podPresets) Update(podPreset *v1alpha1.PodPreset) (result *v1alpha1.PodPreset, err error) {
|
|
||||||
result = &v1alpha1.PodPreset{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("podpresets").
|
|
||||||
Name(podPreset.Name).
|
|
||||||
Body(podPreset).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete takes name of the podPreset and deletes it. Returns an error if one occurs.
|
|
||||||
func (c *podPresets) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
return c.client.Delete().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("podpresets").
|
|
||||||
Name(name).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCollection deletes a collection of objects.
|
|
||||||
func (c *podPresets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
var timeout time.Duration
|
|
||||||
if listOptions.TimeoutSeconds != nil {
|
|
||||||
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
|
|
||||||
}
|
|
||||||
return c.client.Delete().
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("podpresets").
|
|
||||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
|
||||||
Timeout(timeout).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched podPreset.
|
|
||||||
func (c *podPresets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodPreset, err error) {
|
|
||||||
result = &v1alpha1.PodPreset{}
|
|
||||||
err = c.client.Patch(pt).
|
|
||||||
Namespace(c.ns).
|
|
||||||
Resource("podpresets").
|
|
||||||
SubResource(subresources...).
|
|
||||||
Name(name).
|
|
||||||
Body(data).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
/*
|
|
||||||
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 client-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SettingsV1alpha1Interface interface {
|
|
||||||
RESTClient() rest.Interface
|
|
||||||
PodPresetsGetter
|
|
||||||
}
|
|
||||||
|
|
||||||
// SettingsV1alpha1Client is used to interact with features provided by the settings.k8s.io group.
|
|
||||||
type SettingsV1alpha1Client struct {
|
|
||||||
restClient rest.Interface
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *SettingsV1alpha1Client) PodPresets(namespace string) PodPresetInterface {
|
|
||||||
return newPodPresets(c, namespace)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewForConfig creates a new SettingsV1alpha1Client for the given config.
|
|
||||||
func NewForConfig(c *rest.Config) (*SettingsV1alpha1Client, error) {
|
|
||||||
config := *c
|
|
||||||
if err := setConfigDefaults(&config); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
client, err := rest.RESTClientFor(&config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &SettingsV1alpha1Client{client}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewForConfigOrDie creates a new SettingsV1alpha1Client for the given config and
|
|
||||||
// panics if there is an error in the config.
|
|
||||||
func NewForConfigOrDie(c *rest.Config) *SettingsV1alpha1Client {
|
|
||||||
client, err := NewForConfig(c)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return client
|
|
||||||
}
|
|
||||||
|
|
||||||
// New creates a new SettingsV1alpha1Client for the given RESTClient.
|
|
||||||
func New(c rest.Interface) *SettingsV1alpha1Client {
|
|
||||||
return &SettingsV1alpha1Client{c}
|
|
||||||
}
|
|
||||||
|
|
||||||
func setConfigDefaults(config *rest.Config) error {
|
|
||||||
gv := v1alpha1.SchemeGroupVersion
|
|
||||||
config.GroupVersion = &gv
|
|
||||||
config.APIPath = "/apis"
|
|
||||||
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
|
|
||||||
|
|
||||||
if config.UserAgent == "" {
|
|
||||||
config.UserAgent = rest.DefaultKubernetesUserAgent()
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RESTClient returns a RESTClient that is used to communicate
|
|
||||||
// with API server by this client implementation.
|
|
||||||
func (c *SettingsV1alpha1Client) RESTClient() rest.Interface {
|
|
||||||
if c == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return c.restClient
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"expansion_generated.go",
|
|
||||||
"podpreset.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/client-go/listers/settings/v1alpha1",
|
|
||||||
importpath = "k8s.io/client-go/listers/settings/v1alpha1",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/api/settings/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*
|
|
||||||
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 lister-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
// PodPresetListerExpansion allows custom methods to be added to
|
|
||||||
// PodPresetLister.
|
|
||||||
type PodPresetListerExpansion interface{}
|
|
||||||
|
|
||||||
// PodPresetNamespaceListerExpansion allows custom methods to be added to
|
|
||||||
// PodPresetNamespaceLister.
|
|
||||||
type PodPresetNamespaceListerExpansion interface{}
|
|
|
@ -1,94 +0,0 @@
|
||||||
/*
|
|
||||||
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 lister-gen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package v1alpha1
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1alpha1 "k8s.io/api/settings/v1alpha1"
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
|
||||||
"k8s.io/client-go/tools/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PodPresetLister helps list PodPresets.
|
|
||||||
type PodPresetLister interface {
|
|
||||||
// List lists all PodPresets in the indexer.
|
|
||||||
List(selector labels.Selector) (ret []*v1alpha1.PodPreset, err error)
|
|
||||||
// PodPresets returns an object that can list and get PodPresets.
|
|
||||||
PodPresets(namespace string) PodPresetNamespaceLister
|
|
||||||
PodPresetListerExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// podPresetLister implements the PodPresetLister interface.
|
|
||||||
type podPresetLister struct {
|
|
||||||
indexer cache.Indexer
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewPodPresetLister returns a new PodPresetLister.
|
|
||||||
func NewPodPresetLister(indexer cache.Indexer) PodPresetLister {
|
|
||||||
return &podPresetLister{indexer: indexer}
|
|
||||||
}
|
|
||||||
|
|
||||||
// List lists all PodPresets in the indexer.
|
|
||||||
func (s *podPresetLister) List(selector labels.Selector) (ret []*v1alpha1.PodPreset, err error) {
|
|
||||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
|
||||||
ret = append(ret, m.(*v1alpha1.PodPreset))
|
|
||||||
})
|
|
||||||
return ret, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodPresets returns an object that can list and get PodPresets.
|
|
||||||
func (s *podPresetLister) PodPresets(namespace string) PodPresetNamespaceLister {
|
|
||||||
return podPresetNamespaceLister{indexer: s.indexer, namespace: namespace}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodPresetNamespaceLister helps list and get PodPresets.
|
|
||||||
type PodPresetNamespaceLister interface {
|
|
||||||
// List lists all PodPresets in the indexer for a given namespace.
|
|
||||||
List(selector labels.Selector) (ret []*v1alpha1.PodPreset, err error)
|
|
||||||
// Get retrieves the PodPreset from the indexer for a given namespace and name.
|
|
||||||
Get(name string) (*v1alpha1.PodPreset, error)
|
|
||||||
PodPresetNamespaceListerExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// podPresetNamespaceLister implements the PodPresetNamespaceLister
|
|
||||||
// interface.
|
|
||||||
type podPresetNamespaceLister struct {
|
|
||||||
indexer cache.Indexer
|
|
||||||
namespace string
|
|
||||||
}
|
|
||||||
|
|
||||||
// List lists all PodPresets in the indexer for a given namespace.
|
|
||||||
func (s podPresetNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PodPreset, err error) {
|
|
||||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
|
||||||
ret = append(ret, m.(*v1alpha1.PodPreset))
|
|
||||||
})
|
|
||||||
return ret, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get retrieves the PodPreset from the indexer for a given namespace and name.
|
|
||||||
func (s podPresetNamespaceLister) Get(name string) (*v1alpha1.PodPreset, error) {
|
|
||||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !exists {
|
|
||||||
return nil, errors.NewNotFound(v1alpha1.Resource("podpreset"), name)
|
|
||||||
}
|
|
||||||
return obj.(*v1alpha1.PodPreset), nil
|
|
||||||
}
|
|
Loading…
Reference in New Issue