mirror of https://github.com/k3s-io/k3s
Merge pull request #72972 from liggitt/remove-alpha-initializers
Remove use of alpha initializerspull/564/head
commit
e28c757e87
File diff suppressed because it is too large
Load Diff
|
@ -39,7 +39,6 @@ tags_values_pkgs = {"openapi-gen": {
|
||||||
"pkg/apis/abac/v1beta1",
|
"pkg/apis/abac/v1beta1",
|
||||||
"pkg/apis/auditregistration",
|
"pkg/apis/auditregistration",
|
||||||
"pkg/version",
|
"pkg/version",
|
||||||
"staging/src/k8s.io/api/admissionregistration/v1alpha1",
|
|
||||||
"staging/src/k8s.io/api/admissionregistration/v1beta1",
|
"staging/src/k8s.io/api/admissionregistration/v1beta1",
|
||||||
"staging/src/k8s.io/api/apps/v1",
|
"staging/src/k8s.io/api/apps/v1",
|
||||||
"staging/src/k8s.io/api/apps/v1beta1",
|
"staging/src/k8s.io/api/apps/v1beta1",
|
||||||
|
@ -110,7 +109,6 @@ tags_pkgs_values = {"openapi-gen": {
|
||||||
"pkg/apis/auditregistration": ["true"],
|
"pkg/apis/auditregistration": ["true"],
|
||||||
"pkg/version": ["true"],
|
"pkg/version": ["true"],
|
||||||
"staging/src/k8s.io/api/admission/v1beta1": ["false"],
|
"staging/src/k8s.io/api/admission/v1beta1": ["false"],
|
||||||
"staging/src/k8s.io/api/admissionregistration/v1alpha1": ["true"],
|
|
||||||
"staging/src/k8s.io/api/admissionregistration/v1beta1": ["true"],
|
"staging/src/k8s.io/api/admissionregistration/v1beta1": ["true"],
|
||||||
"staging/src/k8s.io/api/apps/v1": ["true"],
|
"staging/src/k8s.io/api/apps/v1": ["true"],
|
||||||
"staging/src/k8s.io/api/apps/v1beta1": ["true"],
|
"staging/src/k8s.io/api/apps/v1beta1": ["true"],
|
||||||
|
|
|
@ -235,39 +235,38 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{
|
||||||
// can reasonably expect seems questionable.
|
// can reasonably expect seems questionable.
|
||||||
{Group: "extensions", Version: "v1beta1"}: {group: 17900, version: 1},
|
{Group: "extensions", Version: "v1beta1"}: {group: 17900, version: 1},
|
||||||
// to my knowledge, nothing below here collides
|
// to my knowledge, nothing below here collides
|
||||||
{Group: "apps", Version: "v1beta1"}: {group: 17800, version: 1},
|
{Group: "apps", Version: "v1beta1"}: {group: 17800, version: 1},
|
||||||
{Group: "apps", Version: "v1beta2"}: {group: 17800, version: 9},
|
{Group: "apps", Version: "v1beta2"}: {group: 17800, version: 9},
|
||||||
{Group: "apps", Version: "v1"}: {group: 17800, version: 15},
|
{Group: "apps", Version: "v1"}: {group: 17800, version: 15},
|
||||||
{Group: "events.k8s.io", Version: "v1beta1"}: {group: 17750, version: 5},
|
{Group: "events.k8s.io", Version: "v1beta1"}: {group: 17750, version: 5},
|
||||||
{Group: "authentication.k8s.io", Version: "v1"}: {group: 17700, version: 15},
|
{Group: "authentication.k8s.io", Version: "v1"}: {group: 17700, version: 15},
|
||||||
{Group: "authentication.k8s.io", Version: "v1beta1"}: {group: 17700, version: 9},
|
{Group: "authentication.k8s.io", Version: "v1beta1"}: {group: 17700, version: 9},
|
||||||
{Group: "authorization.k8s.io", Version: "v1"}: {group: 17600, version: 15},
|
{Group: "authorization.k8s.io", Version: "v1"}: {group: 17600, version: 15},
|
||||||
{Group: "authorization.k8s.io", Version: "v1beta1"}: {group: 17600, version: 9},
|
{Group: "authorization.k8s.io", Version: "v1beta1"}: {group: 17600, version: 9},
|
||||||
{Group: "autoscaling", Version: "v1"}: {group: 17500, version: 15},
|
{Group: "autoscaling", Version: "v1"}: {group: 17500, version: 15},
|
||||||
{Group: "autoscaling", Version: "v2beta1"}: {group: 17500, version: 9},
|
{Group: "autoscaling", Version: "v2beta1"}: {group: 17500, version: 9},
|
||||||
{Group: "autoscaling", Version: "v2beta2"}: {group: 17500, version: 1},
|
{Group: "autoscaling", Version: "v2beta2"}: {group: 17500, version: 1},
|
||||||
{Group: "batch", Version: "v1"}: {group: 17400, version: 15},
|
{Group: "batch", Version: "v1"}: {group: 17400, version: 15},
|
||||||
{Group: "batch", Version: "v1beta1"}: {group: 17400, version: 9},
|
{Group: "batch", Version: "v1beta1"}: {group: 17400, version: 9},
|
||||||
{Group: "batch", Version: "v2alpha1"}: {group: 17400, version: 9},
|
{Group: "batch", Version: "v2alpha1"}: {group: 17400, version: 9},
|
||||||
{Group: "certificates.k8s.io", Version: "v1beta1"}: {group: 17300, version: 9},
|
{Group: "certificates.k8s.io", Version: "v1beta1"}: {group: 17300, version: 9},
|
||||||
{Group: "networking.k8s.io", Version: "v1"}: {group: 17200, version: 15},
|
{Group: "networking.k8s.io", Version: "v1"}: {group: 17200, version: 15},
|
||||||
{Group: "policy", Version: "v1beta1"}: {group: 17100, version: 9},
|
{Group: "policy", Version: "v1beta1"}: {group: 17100, version: 9},
|
||||||
{Group: "rbac.authorization.k8s.io", Version: "v1"}: {group: 17000, version: 15},
|
{Group: "rbac.authorization.k8s.io", Version: "v1"}: {group: 17000, version: 15},
|
||||||
{Group: "rbac.authorization.k8s.io", Version: "v1beta1"}: {group: 17000, version: 12},
|
{Group: "rbac.authorization.k8s.io", Version: "v1beta1"}: {group: 17000, version: 12},
|
||||||
{Group: "rbac.authorization.k8s.io", Version: "v1alpha1"}: {group: 17000, version: 9},
|
{Group: "rbac.authorization.k8s.io", Version: "v1alpha1"}: {group: 17000, version: 9},
|
||||||
{Group: "settings.k8s.io", Version: "v1alpha1"}: {group: 16900, version: 9},
|
{Group: "settings.k8s.io", Version: "v1alpha1"}: {group: 16900, version: 9},
|
||||||
{Group: "storage.k8s.io", Version: "v1"}: {group: 16800, version: 15},
|
{Group: "storage.k8s.io", Version: "v1"}: {group: 16800, version: 15},
|
||||||
{Group: "storage.k8s.io", Version: "v1beta1"}: {group: 16800, version: 9},
|
{Group: "storage.k8s.io", Version: "v1beta1"}: {group: 16800, version: 9},
|
||||||
{Group: "storage.k8s.io", Version: "v1alpha1"}: {group: 16800, version: 1},
|
{Group: "storage.k8s.io", Version: "v1alpha1"}: {group: 16800, version: 1},
|
||||||
{Group: "apiextensions.k8s.io", Version: "v1beta1"}: {group: 16700, version: 9},
|
{Group: "apiextensions.k8s.io", Version: "v1beta1"}: {group: 16700, version: 9},
|
||||||
{Group: "admissionregistration.k8s.io", Version: "v1"}: {group: 16700, version: 15},
|
{Group: "admissionregistration.k8s.io", Version: "v1"}: {group: 16700, version: 15},
|
||||||
{Group: "admissionregistration.k8s.io", Version: "v1beta1"}: {group: 16700, version: 12},
|
{Group: "admissionregistration.k8s.io", Version: "v1beta1"}: {group: 16700, version: 12},
|
||||||
{Group: "admissionregistration.k8s.io", Version: "v1alpha1"}: {group: 16700, version: 9},
|
{Group: "scheduling.k8s.io", Version: "v1beta1"}: {group: 16600, version: 12},
|
||||||
{Group: "scheduling.k8s.io", Version: "v1beta1"}: {group: 16600, version: 12},
|
{Group: "scheduling.k8s.io", Version: "v1alpha1"}: {group: 16600, version: 9},
|
||||||
{Group: "scheduling.k8s.io", Version: "v1alpha1"}: {group: 16600, version: 9},
|
{Group: "coordination.k8s.io", Version: "v1"}: {group: 16500, version: 15},
|
||||||
{Group: "coordination.k8s.io", Version: "v1"}: {group: 16500, version: 15},
|
{Group: "coordination.k8s.io", Version: "v1beta1"}: {group: 16500, version: 9},
|
||||||
{Group: "coordination.k8s.io", Version: "v1beta1"}: {group: 16500, version: 9},
|
{Group: "auditregistration.k8s.io", Version: "v1alpha1"}: {group: 16400, version: 1},
|
||||||
{Group: "auditregistration.k8s.io", Version: "v1alpha1"}: {group: 16400, version: 1},
|
|
||||||
// Append a new group to the end of the list if unsure.
|
// Append a new group to the end of the list if unsure.
|
||||||
// You can use min(existing group)-100 as the initial value for a group.
|
// You can use min(existing group)-100 as the initial value for a group.
|
||||||
// Version can be set to 9 (to have space around) for a new group.
|
// Version can be set to 9 (to have space around) for a new group.
|
||||||
|
|
|
@ -689,7 +689,6 @@ func postProcessOpenAPISpecForBackwardCompatibility(s *spec.Swagger) (*spec.Swag
|
||||||
"io.k8s.kubernetes.pkg.apis.extensions.v1beta1.DeploymentStatus": "io.k8s.api.extensions.v1beta1.DeploymentStatus",
|
"io.k8s.kubernetes.pkg.apis.extensions.v1beta1.DeploymentStatus": "io.k8s.api.extensions.v1beta1.DeploymentStatus",
|
||||||
"io.k8s.kubernetes.pkg.apis.rbac.v1beta1.RoleRef": "io.k8s.api.rbac.v1beta1.RoleRef",
|
"io.k8s.kubernetes.pkg.apis.rbac.v1beta1.RoleRef": "io.k8s.api.rbac.v1beta1.RoleRef",
|
||||||
"io.k8s.kubernetes.pkg.apis.apps.v1beta1.Scale": "io.k8s.api.apps.v1beta1.Scale",
|
"io.k8s.kubernetes.pkg.apis.apps.v1beta1.Scale": "io.k8s.api.apps.v1beta1.Scale",
|
||||||
"io.k8s.kubernetes.pkg.apis.admissionregistration.v1alpha1.InitializerConfiguration": "io.k8s.api.admissionregistration.v1alpha1.InitializerConfiguration",
|
|
||||||
"io.k8s.kubernetes.pkg.api.v1.PhotonPersistentDiskVolumeSource": "io.k8s.api.core.v1.PhotonPersistentDiskVolumeSource",
|
"io.k8s.kubernetes.pkg.api.v1.PhotonPersistentDiskVolumeSource": "io.k8s.api.core.v1.PhotonPersistentDiskVolumeSource",
|
||||||
"io.k8s.kubernetes.pkg.api.v1.PreferredSchedulingTerm": "io.k8s.api.core.v1.PreferredSchedulingTerm",
|
"io.k8s.kubernetes.pkg.api.v1.PreferredSchedulingTerm": "io.k8s.api.core.v1.PreferredSchedulingTerm",
|
||||||
"io.k8s.kubernetes.pkg.apis.batch.v1.JobSpec": "io.k8s.api.batch.v1.JobSpec",
|
"io.k8s.kubernetes.pkg.apis.batch.v1.JobSpec": "io.k8s.api.batch.v1.JobSpec",
|
||||||
|
@ -727,7 +726,6 @@ func postProcessOpenAPISpecForBackwardCompatibility(s *spec.Swagger) (*spec.Swag
|
||||||
"io.k8s.kubernetes.pkg.api.v1.Volume": "io.k8s.api.core.v1.Volume",
|
"io.k8s.kubernetes.pkg.api.v1.Volume": "io.k8s.api.core.v1.Volume",
|
||||||
"io.k8s.kubernetes.pkg.apis.rbac.v1alpha1.RoleBindingList": "io.k8s.api.rbac.v1alpha1.RoleBindingList",
|
"io.k8s.kubernetes.pkg.apis.rbac.v1alpha1.RoleBindingList": "io.k8s.api.rbac.v1alpha1.RoleBindingList",
|
||||||
"io.k8s.kubernetes.pkg.apis.admissionregistration.v1alpha1.Rule": "io.k8s.api.admissionregistration.v1alpha1.Rule",
|
"io.k8s.kubernetes.pkg.apis.admissionregistration.v1alpha1.Rule": "io.k8s.api.admissionregistration.v1alpha1.Rule",
|
||||||
"io.k8s.kubernetes.pkg.apis.admissionregistration.v1alpha1.InitializerConfigurationList": "io.k8s.api.admissionregistration.v1alpha1.InitializerConfigurationList",
|
|
||||||
"io.k8s.kubernetes.pkg.apis.extensions.v1beta1.NetworkPolicy": "io.k8s.api.extensions.v1beta1.NetworkPolicy",
|
"io.k8s.kubernetes.pkg.apis.extensions.v1beta1.NetworkPolicy": "io.k8s.api.extensions.v1beta1.NetworkPolicy",
|
||||||
"io.k8s.kubernetes.pkg.apis.rbac.v1alpha1.ClusterRoleList": "io.k8s.api.rbac.v1alpha1.ClusterRoleList",
|
"io.k8s.kubernetes.pkg.apis.rbac.v1alpha1.ClusterRoleList": "io.k8s.api.rbac.v1alpha1.ClusterRoleList",
|
||||||
"io.k8s.kubernetes.pkg.api.v1.ObjectFieldSelector": "io.k8s.api.core.v1.ObjectFieldSelector",
|
"io.k8s.kubernetes.pkg.api.v1.ObjectFieldSelector": "io.k8s.api.core.v1.ObjectFieldSelector",
|
||||||
|
|
|
@ -15,7 +15,6 @@ pkg/apis/abac/latest
|
||||||
pkg/apis/admission
|
pkg/apis/admission
|
||||||
pkg/apis/admission/v1beta1
|
pkg/apis/admission/v1beta1
|
||||||
pkg/apis/admissionregistration
|
pkg/apis/admissionregistration
|
||||||
pkg/apis/admissionregistration/v1alpha1
|
|
||||||
pkg/apis/admissionregistration/v1beta1
|
pkg/apis/admissionregistration/v1beta1
|
||||||
pkg/apis/admissionregistration/validation
|
pkg/apis/admissionregistration/validation
|
||||||
pkg/apis/apps
|
pkg/apis/apps
|
||||||
|
@ -254,7 +253,6 @@ pkg/proxy/util
|
||||||
pkg/proxy/winkernel
|
pkg/proxy/winkernel
|
||||||
pkg/proxy/winuserspace
|
pkg/proxy/winuserspace
|
||||||
pkg/quota/v1/evaluator/core
|
pkg/quota/v1/evaluator/core
|
||||||
pkg/registry/admissionregistration/initializerconfiguration/storage
|
|
||||||
pkg/registry/admissionregistration/mutatingwebhookconfiguration/storage
|
pkg/registry/admissionregistration/mutatingwebhookconfiguration/storage
|
||||||
pkg/registry/admissionregistration/rest
|
pkg/registry/admissionregistration/rest
|
||||||
pkg/registry/admissionregistration/validatingwebhookconfiguration/storage
|
pkg/registry/admissionregistration/validatingwebhookconfiguration/storage
|
||||||
|
@ -423,7 +421,6 @@ plugin/pkg/auth/authorizer/node
|
||||||
plugin/pkg/auth/authorizer/rbac
|
plugin/pkg/auth/authorizer/rbac
|
||||||
plugin/pkg/auth/authorizer/rbac/bootstrappolicy
|
plugin/pkg/auth/authorizer/rbac/bootstrappolicy
|
||||||
staging/src/k8s.io/api/admission/v1beta1
|
staging/src/k8s.io/api/admission/v1beta1
|
||||||
staging/src/k8s.io/api/admissionregistration/v1alpha1
|
|
||||||
staging/src/k8s.io/api/admissionregistration/v1beta1
|
staging/src/k8s.io/api/admissionregistration/v1beta1
|
||||||
staging/src/k8s.io/api/apps/v1
|
staging/src/k8s.io/api/apps/v1
|
||||||
staging/src/k8s.io/api/apps/v1beta1
|
staging/src/k8s.io/api/apps/v1beta1
|
||||||
|
@ -520,7 +517,6 @@ staging/src/k8s.io/apimachinery/pkg/watch
|
||||||
staging/src/k8s.io/apiserver/pkg/admission
|
staging/src/k8s.io/apiserver/pkg/admission
|
||||||
staging/src/k8s.io/apiserver/pkg/admission/configuration
|
staging/src/k8s.io/apiserver/pkg/admission/configuration
|
||||||
staging/src/k8s.io/apiserver/pkg/admission/initializer
|
staging/src/k8s.io/apiserver/pkg/admission/initializer
|
||||||
staging/src/k8s.io/apiserver/pkg/admission/plugin/initialization
|
|
||||||
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission
|
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission
|
||||||
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission/v1alpha1
|
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission/v1alpha1
|
||||||
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts
|
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts
|
||||||
|
|
|
@ -56,7 +56,6 @@ KUBE_OUTPUT_HOSTBIN="${KUBE_OUTPUT_BINPATH}/$(kube::util::host_platform)"
|
||||||
# most preferred version for a group should appear first
|
# most preferred version for a group should appear first
|
||||||
KUBE_AVAILABLE_GROUP_VERSIONS="${KUBE_AVAILABLE_GROUP_VERSIONS:-\
|
KUBE_AVAILABLE_GROUP_VERSIONS="${KUBE_AVAILABLE_GROUP_VERSIONS:-\
|
||||||
v1 \
|
v1 \
|
||||||
admissionregistration.k8s.io/v1alpha1 \
|
|
||||||
admissionregistration.k8s.io/v1beta1 \
|
admissionregistration.k8s.io/v1beta1 \
|
||||||
admission.k8s.io/v1beta1 \
|
admission.k8s.io/v1beta1 \
|
||||||
apps/v1 \
|
apps/v1 \
|
||||||
|
|
|
@ -522,13 +522,6 @@ function start_apiserver {
|
||||||
priv_arg="--allow-privileged=${ALLOW_PRIVILEGED} "
|
priv_arg="--allow-privileged=${ALLOW_PRIVILEGED} "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${ENABLE_ADMISSION_PLUGINS} == *"Initializers"* ]]; then
|
|
||||||
if [[ -n "${RUNTIME_CONFIG}" ]]; then
|
|
||||||
RUNTIME_CONFIG+=","
|
|
||||||
fi
|
|
||||||
RUNTIME_CONFIG+="admissionregistration.k8s.io/v1alpha1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
runtime_config=""
|
runtime_config=""
|
||||||
if [[ -n "${RUNTIME_CONFIG}" ]]; then
|
if [[ -n "${RUNTIME_CONFIG}" ]]; then
|
||||||
runtime_config="--runtime-config=${RUNTIME_CONFIG}"
|
runtime_config="--runtime-config=${RUNTIME_CONFIG}"
|
||||||
|
|
|
@ -76,7 +76,6 @@ PACKAGES=(
|
||||||
k8s.io/api/storage/v1alpha1
|
k8s.io/api/storage/v1alpha1
|
||||||
k8s.io/api/storage/v1beta1
|
k8s.io/api/storage/v1beta1
|
||||||
k8s.io/api/storage/v1
|
k8s.io/api/storage/v1
|
||||||
k8s.io/api/admissionregistration/v1alpha1
|
|
||||||
k8s.io/api/admissionregistration/v1beta1
|
k8s.io/api/admissionregistration/v1beta1
|
||||||
k8s.io/api/admission/v1beta1
|
k8s.io/api/admission/v1beta1
|
||||||
k8s.io/api/auditregistration/v1alpha1
|
k8s.io/api/auditregistration/v1alpha1
|
||||||
|
|
|
@ -34,7 +34,6 @@ filegroup(
|
||||||
":package-srcs",
|
":package-srcs",
|
||||||
"//pkg/apis/admissionregistration/fuzzer:all-srcs",
|
"//pkg/apis/admissionregistration/fuzzer:all-srcs",
|
||||||
"//pkg/apis/admissionregistration/install:all-srcs",
|
"//pkg/apis/admissionregistration/install:all-srcs",
|
||||||
"//pkg/apis/admissionregistration/v1alpha1:all-srcs",
|
|
||||||
"//pkg/apis/admissionregistration/v1beta1:all-srcs",
|
"//pkg/apis/admissionregistration/v1beta1:all-srcs",
|
||||||
"//pkg/apis/admissionregistration/validation:all-srcs",
|
"//pkg/apis/admissionregistration/validation:all-srcs",
|
||||||
],
|
],
|
||||||
|
|
|
@ -19,6 +19,6 @@ limitations under the License.
|
||||||
|
|
||||||
// Package admissionregistration is the internal version of the API.
|
// Package admissionregistration is the internal version of the API.
|
||||||
// AdmissionConfiguration and AdmissionPluginConfiguration are legacy static admission plugin configuration
|
// AdmissionConfiguration and AdmissionPluginConfiguration are legacy static admission plugin configuration
|
||||||
// InitializerConfiguration, ValidatingWebhookConfiguration, and MutatingWebhookConfiguration are for the
|
// ValidatingWebhookConfiguration, and MutatingWebhookConfiguration are for the
|
||||||
// new dynamic admission controller configuration.
|
// new dynamic admission controller configuration.
|
||||||
package admissionregistration // import "k8s.io/kubernetes/pkg/apis/admissionregistration"
|
package admissionregistration // import "k8s.io/kubernetes/pkg/apis/admissionregistration"
|
||||||
|
|
|
@ -12,7 +12,6 @@ go_library(
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/api/legacyscheme:go_default_library",
|
"//pkg/api/legacyscheme:go_default_library",
|
||||||
"//pkg/apis/admissionregistration:go_default_library",
|
"//pkg/apis/admissionregistration:go_default_library",
|
||||||
"//pkg/apis/admissionregistration/v1alpha1:go_default_library",
|
|
||||||
"//pkg/apis/admissionregistration/v1beta1:go_default_library",
|
"//pkg/apis/admissionregistration/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||||
|
|
|
@ -21,7 +21,6 @@ import (
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration/v1alpha1"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration/v1beta1"
|
"k8s.io/kubernetes/pkg/apis/admissionregistration/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,7 +31,6 @@ func init() {
|
||||||
// Install registers the API group and adds types to a scheme
|
// Install registers the API group and adds types to a scheme
|
||||||
func Install(scheme *runtime.Scheme) {
|
func Install(scheme *runtime.Scheme) {
|
||||||
utilruntime.Must(admissionregistration.AddToScheme(scheme))
|
utilruntime.Must(admissionregistration.AddToScheme(scheme))
|
||||||
utilruntime.Must(v1alpha1.AddToScheme(scheme))
|
|
||||||
utilruntime.Must(v1beta1.AddToScheme(scheme))
|
utilruntime.Must(v1beta1.AddToScheme(scheme))
|
||||||
utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion, v1alpha1.SchemeGroupVersion))
|
utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion))
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,6 @@ var (
|
||||||
// Adds the list of known types to scheme.
|
// Adds the list of known types to scheme.
|
||||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
&InitializerConfiguration{},
|
|
||||||
&InitializerConfigurationList{},
|
|
||||||
&ValidatingWebhookConfiguration{},
|
&ValidatingWebhookConfiguration{},
|
||||||
&ValidatingWebhookConfigurationList{},
|
&ValidatingWebhookConfigurationList{},
|
||||||
&MutatingWebhookConfiguration{},
|
&MutatingWebhookConfiguration{},
|
||||||
|
|
|
@ -20,58 +20,6 @@ import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +genclient
|
|
||||||
// +genclient:nonNamespaced
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
|
||||||
|
|
||||||
// InitializerConfiguration describes the configuration of initializers.
|
|
||||||
type InitializerConfiguration struct {
|
|
||||||
metav1.TypeMeta
|
|
||||||
// Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata.
|
|
||||||
// +optional
|
|
||||||
metav1.ObjectMeta
|
|
||||||
|
|
||||||
// Initializers is a list of resources and their default initializers
|
|
||||||
// Order-sensitive.
|
|
||||||
// When merging multiple InitializerConfigurations, we sort the initializers
|
|
||||||
// from different InitializerConfigurations by the name of the
|
|
||||||
// InitializerConfigurations; the order of the initializers from the same
|
|
||||||
// InitializerConfiguration is preserved.
|
|
||||||
// +optional
|
|
||||||
Initializers []Initializer
|
|
||||||
}
|
|
||||||
|
|
||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
|
||||||
|
|
||||||
// InitializerConfigurationList is a list of InitializerConfiguration.
|
|
||||||
type InitializerConfigurationList struct {
|
|
||||||
metav1.TypeMeta
|
|
||||||
// Standard list metadata.
|
|
||||||
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
|
|
||||||
// +optional
|
|
||||||
metav1.ListMeta
|
|
||||||
|
|
||||||
// List of InitializerConfiguration.
|
|
||||||
Items []InitializerConfiguration
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initializer describes the name and the failure policy of an initializer, and
|
|
||||||
// what resources it applies to.
|
|
||||||
type Initializer struct {
|
|
||||||
// Name is the identifier of the initializer. It will be added to the
|
|
||||||
// object that needs to be initialized.
|
|
||||||
// Name should be fully qualified, e.g., alwayspullimages.kubernetes.io, where
|
|
||||||
// "alwayspullimages" is the name of the webhook, and kubernetes.io is the name
|
|
||||||
// of the organization.
|
|
||||||
// Required
|
|
||||||
Name string
|
|
||||||
|
|
||||||
// Rules describes what resources/subresources the initializer cares about.
|
|
||||||
// The initializer cares about an operation if it matches _any_ Rule.
|
|
||||||
// Rule.Resources must not include subresources.
|
|
||||||
Rules []Rule
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rule is a tuple of APIGroups, APIVersion, and Resources.It is recommended
|
// Rule is a tuple of APIGroups, APIVersion, and Resources.It is recommended
|
||||||
// to make sure that all the tuple expansions are valid.
|
// to make sure that all the tuple expansions are valid.
|
||||||
type Rule struct {
|
type Rule struct {
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"defaults.go",
|
|
||||||
"doc.go",
|
|
||||||
"register.go",
|
|
||||||
"zz_generated.conversion.go",
|
|
||||||
"zz_generated.defaults.go",
|
|
||||||
],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/apis/admissionregistration/v1alpha1",
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/admissionregistration:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/admissionregistration/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,25 +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/apimachinery/pkg/runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
|
||||||
return RegisterDefaults(scheme)
|
|
||||||
}
|
|
|
@ -1,27 +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/admissionregistration
|
|
||||||
// +k8s:conversion-gen-external-types=k8s.io/api/admissionregistration/v1alpha1
|
|
||||||
// +k8s:defaulter-gen=TypeMeta
|
|
||||||
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/admissionregistration/v1alpha1
|
|
||||||
// +groupName=admissionregistration.k8s.io
|
|
||||||
|
|
||||||
// Package v1alpha1 is the v1alpha1 version of the API.
|
|
||||||
// AdmissionConfiguration and AdmissionPluginConfiguration are legacy static admission plugin configuration
|
|
||||||
// InitializerConfiguration, ValidatingWebhookConfiguration, and MutatingWebhookConfiguration are for the
|
|
||||||
// new dynamic admission controller configuration.
|
|
||||||
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/admissionregistration/v1alpha1"
|
|
|
@ -1,44 +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 (
|
|
||||||
admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
)
|
|
||||||
|
|
||||||
const GroupName = "admissionregistration.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 = &admissionregistrationv1alpha1.SchemeBuilder
|
|
||||||
AddToScheme = localSchemeBuilder.AddToScheme
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
// We only register manually written functions here. The registration of the
|
|
||||||
// generated functions takes place in the generated files. The separation
|
|
||||||
// makes the code compile even when the generated files are missing.
|
|
||||||
localSchemeBuilder.Register(addDefaultingFuncs)
|
|
||||||
}
|
|
|
@ -1,170 +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"
|
|
||||||
|
|
||||||
v1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
|
|
||||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
admissionregistration "k8s.io/kubernetes/pkg/apis/admissionregistration"
|
|
||||||
)
|
|
||||||
|
|
||||||
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.Initializer)(nil), (*admissionregistration.Initializer)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_v1alpha1_Initializer_To_admissionregistration_Initializer(a.(*v1alpha1.Initializer), b.(*admissionregistration.Initializer), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*admissionregistration.Initializer)(nil), (*v1alpha1.Initializer)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_admissionregistration_Initializer_To_v1alpha1_Initializer(a.(*admissionregistration.Initializer), b.(*v1alpha1.Initializer), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.InitializerConfiguration)(nil), (*admissionregistration.InitializerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_v1alpha1_InitializerConfiguration_To_admissionregistration_InitializerConfiguration(a.(*v1alpha1.InitializerConfiguration), b.(*admissionregistration.InitializerConfiguration), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*admissionregistration.InitializerConfiguration)(nil), (*v1alpha1.InitializerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_admissionregistration_InitializerConfiguration_To_v1alpha1_InitializerConfiguration(a.(*admissionregistration.InitializerConfiguration), b.(*v1alpha1.InitializerConfiguration), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.InitializerConfigurationList)(nil), (*admissionregistration.InitializerConfigurationList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_v1alpha1_InitializerConfigurationList_To_admissionregistration_InitializerConfigurationList(a.(*v1alpha1.InitializerConfigurationList), b.(*admissionregistration.InitializerConfigurationList), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*admissionregistration.InitializerConfigurationList)(nil), (*v1alpha1.InitializerConfigurationList)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_admissionregistration_InitializerConfigurationList_To_v1alpha1_InitializerConfigurationList(a.(*admissionregistration.InitializerConfigurationList), b.(*v1alpha1.InitializerConfigurationList), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*v1alpha1.Rule)(nil), (*admissionregistration.Rule)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_v1alpha1_Rule_To_admissionregistration_Rule(a.(*v1alpha1.Rule), b.(*admissionregistration.Rule), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*admissionregistration.Rule)(nil), (*v1alpha1.Rule)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_admissionregistration_Rule_To_v1alpha1_Rule(a.(*admissionregistration.Rule), b.(*v1alpha1.Rule), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_v1alpha1_Initializer_To_admissionregistration_Initializer(in *v1alpha1.Initializer, out *admissionregistration.Initializer, s conversion.Scope) error {
|
|
||||||
out.Name = in.Name
|
|
||||||
out.Rules = *(*[]admissionregistration.Rule)(unsafe.Pointer(&in.Rules))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_v1alpha1_Initializer_To_admissionregistration_Initializer is an autogenerated conversion function.
|
|
||||||
func Convert_v1alpha1_Initializer_To_admissionregistration_Initializer(in *v1alpha1.Initializer, out *admissionregistration.Initializer, s conversion.Scope) error {
|
|
||||||
return autoConvert_v1alpha1_Initializer_To_admissionregistration_Initializer(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_admissionregistration_Initializer_To_v1alpha1_Initializer(in *admissionregistration.Initializer, out *v1alpha1.Initializer, s conversion.Scope) error {
|
|
||||||
out.Name = in.Name
|
|
||||||
out.Rules = *(*[]v1alpha1.Rule)(unsafe.Pointer(&in.Rules))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_admissionregistration_Initializer_To_v1alpha1_Initializer is an autogenerated conversion function.
|
|
||||||
func Convert_admissionregistration_Initializer_To_v1alpha1_Initializer(in *admissionregistration.Initializer, out *v1alpha1.Initializer, s conversion.Scope) error {
|
|
||||||
return autoConvert_admissionregistration_Initializer_To_v1alpha1_Initializer(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_v1alpha1_InitializerConfiguration_To_admissionregistration_InitializerConfiguration(in *v1alpha1.InitializerConfiguration, out *admissionregistration.InitializerConfiguration, s conversion.Scope) error {
|
|
||||||
out.ObjectMeta = in.ObjectMeta
|
|
||||||
out.Initializers = *(*[]admissionregistration.Initializer)(unsafe.Pointer(&in.Initializers))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_v1alpha1_InitializerConfiguration_To_admissionregistration_InitializerConfiguration is an autogenerated conversion function.
|
|
||||||
func Convert_v1alpha1_InitializerConfiguration_To_admissionregistration_InitializerConfiguration(in *v1alpha1.InitializerConfiguration, out *admissionregistration.InitializerConfiguration, s conversion.Scope) error {
|
|
||||||
return autoConvert_v1alpha1_InitializerConfiguration_To_admissionregistration_InitializerConfiguration(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_admissionregistration_InitializerConfiguration_To_v1alpha1_InitializerConfiguration(in *admissionregistration.InitializerConfiguration, out *v1alpha1.InitializerConfiguration, s conversion.Scope) error {
|
|
||||||
out.ObjectMeta = in.ObjectMeta
|
|
||||||
out.Initializers = *(*[]v1alpha1.Initializer)(unsafe.Pointer(&in.Initializers))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_admissionregistration_InitializerConfiguration_To_v1alpha1_InitializerConfiguration is an autogenerated conversion function.
|
|
||||||
func Convert_admissionregistration_InitializerConfiguration_To_v1alpha1_InitializerConfiguration(in *admissionregistration.InitializerConfiguration, out *v1alpha1.InitializerConfiguration, s conversion.Scope) error {
|
|
||||||
return autoConvert_admissionregistration_InitializerConfiguration_To_v1alpha1_InitializerConfiguration(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_v1alpha1_InitializerConfigurationList_To_admissionregistration_InitializerConfigurationList(in *v1alpha1.InitializerConfigurationList, out *admissionregistration.InitializerConfigurationList, s conversion.Scope) error {
|
|
||||||
out.ListMeta = in.ListMeta
|
|
||||||
out.Items = *(*[]admissionregistration.InitializerConfiguration)(unsafe.Pointer(&in.Items))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_v1alpha1_InitializerConfigurationList_To_admissionregistration_InitializerConfigurationList is an autogenerated conversion function.
|
|
||||||
func Convert_v1alpha1_InitializerConfigurationList_To_admissionregistration_InitializerConfigurationList(in *v1alpha1.InitializerConfigurationList, out *admissionregistration.InitializerConfigurationList, s conversion.Scope) error {
|
|
||||||
return autoConvert_v1alpha1_InitializerConfigurationList_To_admissionregistration_InitializerConfigurationList(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_admissionregistration_InitializerConfigurationList_To_v1alpha1_InitializerConfigurationList(in *admissionregistration.InitializerConfigurationList, out *v1alpha1.InitializerConfigurationList, s conversion.Scope) error {
|
|
||||||
out.ListMeta = in.ListMeta
|
|
||||||
out.Items = *(*[]v1alpha1.InitializerConfiguration)(unsafe.Pointer(&in.Items))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_admissionregistration_InitializerConfigurationList_To_v1alpha1_InitializerConfigurationList is an autogenerated conversion function.
|
|
||||||
func Convert_admissionregistration_InitializerConfigurationList_To_v1alpha1_InitializerConfigurationList(in *admissionregistration.InitializerConfigurationList, out *v1alpha1.InitializerConfigurationList, s conversion.Scope) error {
|
|
||||||
return autoConvert_admissionregistration_InitializerConfigurationList_To_v1alpha1_InitializerConfigurationList(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_v1alpha1_Rule_To_admissionregistration_Rule(in *v1alpha1.Rule, out *admissionregistration.Rule, s conversion.Scope) error {
|
|
||||||
out.APIGroups = *(*[]string)(unsafe.Pointer(&in.APIGroups))
|
|
||||||
out.APIVersions = *(*[]string)(unsafe.Pointer(&in.APIVersions))
|
|
||||||
out.Resources = *(*[]string)(unsafe.Pointer(&in.Resources))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_v1alpha1_Rule_To_admissionregistration_Rule is an autogenerated conversion function.
|
|
||||||
func Convert_v1alpha1_Rule_To_admissionregistration_Rule(in *v1alpha1.Rule, out *admissionregistration.Rule, s conversion.Scope) error {
|
|
||||||
return autoConvert_v1alpha1_Rule_To_admissionregistration_Rule(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_admissionregistration_Rule_To_v1alpha1_Rule(in *admissionregistration.Rule, out *v1alpha1.Rule, s conversion.Scope) error {
|
|
||||||
out.APIGroups = *(*[]string)(unsafe.Pointer(&in.APIGroups))
|
|
||||||
out.APIVersions = *(*[]string)(unsafe.Pointer(&in.APIVersions))
|
|
||||||
out.Resources = *(*[]string)(unsafe.Pointer(&in.Resources))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert_admissionregistration_Rule_To_v1alpha1_Rule is an autogenerated conversion function.
|
|
||||||
func Convert_admissionregistration_Rule_To_v1alpha1_Rule(in *admissionregistration.Rule, out *v1alpha1.Rule, s conversion.Scope) error {
|
|
||||||
return autoConvert_admissionregistration_Rule_To_v1alpha1_Rule(in, out, s)
|
|
||||||
}
|
|
|
@ -1,32 +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 (
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
// RegisterDefaults adds defaulters functions to the given scheme.
|
|
||||||
// Public to allow building arbitrary schemes.
|
|
||||||
// All generated defaulters are covering - they call all nested defaulters.
|
|
||||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -22,6 +22,6 @@ limitations under the License.
|
||||||
|
|
||||||
// Package v1beta1 is the v1beta1 version of the API.
|
// Package v1beta1 is the v1beta1 version of the API.
|
||||||
// AdmissionConfiguration and AdmissionPluginConfiguration are legacy static admission plugin configuration
|
// AdmissionConfiguration and AdmissionPluginConfiguration are legacy static admission plugin configuration
|
||||||
// InitializerConfiguration, ValidatingWebhookConfiguration, and MutatingWebhookConfiguration are for the
|
// ValidatingWebhookConfiguration, and MutatingWebhookConfiguration are for the
|
||||||
// new dynamic admission controller configuration.
|
// new dynamic admission controller configuration.
|
||||||
package v1beta1 // import "k8s.io/kubernetes/pkg/apis/admissionregistration/v1beta1"
|
package v1beta1 // import "k8s.io/kubernetes/pkg/apis/admissionregistration/v1beta1"
|
||||||
|
|
|
@ -29,26 +29,6 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ValidateInitializerConfiguration(ic *admissionregistration.InitializerConfiguration) field.ErrorList {
|
|
||||||
allErrors := genericvalidation.ValidateObjectMeta(&ic.ObjectMeta, false, genericvalidation.NameIsDNSSubdomain, field.NewPath("metadata"))
|
|
||||||
for i, initializer := range ic.Initializers {
|
|
||||||
allErrors = append(allErrors, validateInitializer(&initializer, field.NewPath("initializers").Index(i))...)
|
|
||||||
}
|
|
||||||
return allErrors
|
|
||||||
}
|
|
||||||
|
|
||||||
func validateInitializer(initializer *admissionregistration.Initializer, fldPath *field.Path) field.ErrorList {
|
|
||||||
var allErrors field.ErrorList
|
|
||||||
// initlializer.Name must be fully qualified
|
|
||||||
allErrors = append(allErrors, validation.IsFullyQualifiedName(fldPath.Child("name"), initializer.Name)...)
|
|
||||||
|
|
||||||
for i, rule := range initializer.Rules {
|
|
||||||
notAllowSubresources := false
|
|
||||||
allErrors = append(allErrors, validateRule(&rule, fldPath.Child("rules").Index(i), notAllowSubresources)...)
|
|
||||||
}
|
|
||||||
return allErrors
|
|
||||||
}
|
|
||||||
|
|
||||||
func hasWildcard(slice []string) bool {
|
func hasWildcard(slice []string) bool {
|
||||||
for _, s := range slice {
|
for _, s := range slice {
|
||||||
if s == "*" {
|
if s == "*" {
|
||||||
|
@ -161,10 +141,6 @@ func validateRule(rule *admissionregistration.Rule, fldPath *field.Path, allowSu
|
||||||
return allErrors
|
return allErrors
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateInitializerConfigurationUpdate(newIC, oldIC *admissionregistration.InitializerConfiguration) field.ErrorList {
|
|
||||||
return ValidateInitializerConfiguration(newIC)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ValidateValidatingWebhookConfiguration(e *admissionregistration.ValidatingWebhookConfiguration) field.ErrorList {
|
func ValidateValidatingWebhookConfiguration(e *admissionregistration.ValidatingWebhookConfiguration) field.ErrorList {
|
||||||
allErrors := genericvalidation.ValidateObjectMeta(&e.ObjectMeta, false, genericvalidation.NameIsDNSSubdomain, field.NewPath("metadata"))
|
allErrors := genericvalidation.ValidateObjectMeta(&e.ObjectMeta, false, genericvalidation.NameIsDNSSubdomain, field.NewPath("metadata"))
|
||||||
for i, hook := range e.Webhooks {
|
for i, hook := range e.Webhooks {
|
||||||
|
|
|
@ -24,213 +24,6 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getInitializerConfiguration(initializers []admissionregistration.Initializer) *admissionregistration.InitializerConfiguration {
|
|
||||||
return &admissionregistration.InitializerConfiguration{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "config",
|
|
||||||
},
|
|
||||||
Initializers: initializers,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestValidateInitializerConfiguration(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
config *admissionregistration.InitializerConfiguration
|
|
||||||
expectedError string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "0 rule is valid",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "all initializers must have a fully qualified name",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "k8s.io",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
expectedError: `initializers[1].name: Invalid value: "k8s.io": should be a domain with at least three segments separated by dots, initializers[2].name: Required value`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "APIGroups must not be empty or nil",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
Rules: []admissionregistration.Rule{
|
|
||||||
{
|
|
||||||
APIGroups: []string{},
|
|
||||||
APIVersions: []string{"a"},
|
|
||||||
Resources: []string{"a"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
APIGroups: nil,
|
|
||||||
APIVersions: []string{"a"},
|
|
||||||
Resources: []string{"a"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
expectedError: `initializers[0].rules[0].apiGroups: Required value, initializers[0].rules[1].apiGroups: Required value`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "APIVersions must not be empty or nil",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
Rules: []admissionregistration.Rule{
|
|
||||||
{
|
|
||||||
APIGroups: []string{"a"},
|
|
||||||
APIVersions: []string{},
|
|
||||||
Resources: []string{"a"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
APIGroups: []string{"a"},
|
|
||||||
APIVersions: nil,
|
|
||||||
Resources: []string{"a"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
expectedError: `initializers[0].rules[0].apiVersions: Required value, initializers[0].rules[1].apiVersions: Required value`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Resources must not be empty or nil",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
Rules: []admissionregistration.Rule{
|
|
||||||
{
|
|
||||||
APIGroups: []string{"a"},
|
|
||||||
APIVersions: []string{"a"},
|
|
||||||
Resources: []string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
APIGroups: []string{"a"},
|
|
||||||
APIVersions: []string{"a"},
|
|
||||||
Resources: nil,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
expectedError: `initializers[0].rules[0].resources: Required value, initializers[0].rules[1].resources: Required value`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "\"\" is a valid APIGroup",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
Rules: []admissionregistration.Rule{
|
|
||||||
{
|
|
||||||
APIGroups: []string{"a", ""},
|
|
||||||
APIVersions: []string{"a"},
|
|
||||||
Resources: []string{"a"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "\"\" is NOT a valid APIVersion",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
Rules: []admissionregistration.Rule{
|
|
||||||
{
|
|
||||||
APIGroups: []string{"a"},
|
|
||||||
APIVersions: []string{"a", ""},
|
|
||||||
Resources: []string{"a"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
expectedError: "apiVersions[1]: Required value",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "\"\" is NOT a valid Resource",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
Rules: []admissionregistration.Rule{
|
|
||||||
{
|
|
||||||
APIGroups: []string{"a"},
|
|
||||||
APIVersions: []string{"a"},
|
|
||||||
Resources: []string{"a", ""},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
expectedError: "resources[1]: Required value",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "wildcard cannot be mixed with other strings for APIGroups or APIVersions or Resources",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
Rules: []admissionregistration.Rule{
|
|
||||||
{
|
|
||||||
APIGroups: []string{"a", "*"},
|
|
||||||
APIVersions: []string{"a", "*"},
|
|
||||||
Resources: []string{"a", "*"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
expectedError: `[initializers[0].rules[0].apiGroups: Invalid value: []string{"a", "*"}: if '*' is present, must not specify other API groups, initializers[0].rules[0].apiVersions: Invalid value: []string{"a", "*"}: if '*' is present, must not specify other API versions, initializers[0].rules[0].resources: Invalid value: []string{"a", "*"}: if '*' is present, must not specify other resources]`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Subresource not allowed",
|
|
||||||
config: getInitializerConfiguration(
|
|
||||||
[]admissionregistration.Initializer{
|
|
||||||
{
|
|
||||||
Name: "initializer.k8s.io",
|
|
||||||
Rules: []admissionregistration.Rule{
|
|
||||||
{
|
|
||||||
APIGroups: []string{"a"},
|
|
||||||
APIVersions: []string{"a"},
|
|
||||||
Resources: []string{"a/b"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
expectedError: ` "a/b": must not specify subresources`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
errs := ValidateInitializerConfiguration(test.config)
|
|
||||||
err := errs.ToAggregate()
|
|
||||||
if err != nil {
|
|
||||||
if e, a := test.expectedError, err.Error(); !strings.Contains(a, e) || e == "" {
|
|
||||||
t.Errorf("test case %s, expected to contain %s, got %s", test.name, e, a)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if test.expectedError != "" {
|
|
||||||
t.Errorf("test case %s, unexpected no error, expected to contain %s", test.name, test.expectedError)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func strPtr(s string) *string { return &s }
|
func strPtr(s string) *string { return &s }
|
||||||
|
|
||||||
func newValidatingWebhookConfiguration(hooks []admissionregistration.Webhook) *admissionregistration.ValidatingWebhookConfiguration {
|
func newValidatingWebhookConfiguration(hooks []admissionregistration.Webhook) *admissionregistration.ValidatingWebhookConfiguration {
|
||||||
|
|
|
@ -25,95 +25,6 @@ import (
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
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 *Initializer) DeepCopyInto(out *Initializer) {
|
|
||||||
*out = *in
|
|
||||||
if in.Rules != nil {
|
|
||||||
in, out := &in.Rules, &out.Rules
|
|
||||||
*out = make([]Rule, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Initializer.
|
|
||||||
func (in *Initializer) DeepCopy() *Initializer {
|
|
||||||
if in == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
out := new(Initializer)
|
|
||||||
in.DeepCopyInto(out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
||||||
func (in *InitializerConfiguration) DeepCopyInto(out *InitializerConfiguration) {
|
|
||||||
*out = *in
|
|
||||||
out.TypeMeta = in.TypeMeta
|
|
||||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
|
||||||
if in.Initializers != nil {
|
|
||||||
in, out := &in.Initializers, &out.Initializers
|
|
||||||
*out = make([]Initializer, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InitializerConfiguration.
|
|
||||||
func (in *InitializerConfiguration) DeepCopy() *InitializerConfiguration {
|
|
||||||
if in == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
out := new(InitializerConfiguration)
|
|
||||||
in.DeepCopyInto(out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
||||||
func (in *InitializerConfiguration) 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 *InitializerConfigurationList) DeepCopyInto(out *InitializerConfigurationList) {
|
|
||||||
*out = *in
|
|
||||||
out.TypeMeta = in.TypeMeta
|
|
||||||
out.ListMeta = in.ListMeta
|
|
||||||
if in.Items != nil {
|
|
||||||
in, out := &in.Items, &out.Items
|
|
||||||
*out = make([]InitializerConfiguration, len(*in))
|
|
||||||
for i := range *in {
|
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InitializerConfigurationList.
|
|
||||||
func (in *InitializerConfigurationList) DeepCopy() *InitializerConfigurationList {
|
|
||||||
if in == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
out := new(InitializerConfigurationList)
|
|
||||||
in.DeepCopyInto(out)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
||||||
func (in *InitializerConfigurationList) 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.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *MutatingWebhookConfiguration) DeepCopyInto(out *MutatingWebhookConfiguration) {
|
func (in *MutatingWebhookConfiguration) DeepCopyInto(out *MutatingWebhookConfiguration) {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
|
|
@ -11,7 +11,6 @@ go_library(
|
||||||
"admissionregistration_client.go",
|
"admissionregistration_client.go",
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"generated_expansion.go",
|
"generated_expansion.go",
|
||||||
"initializerconfiguration.go",
|
|
||||||
"mutatingwebhookconfiguration.go",
|
"mutatingwebhookconfiguration.go",
|
||||||
"validatingwebhookconfiguration.go",
|
"validatingwebhookconfiguration.go",
|
||||||
],
|
],
|
||||||
|
|
|
@ -25,7 +25,6 @@ import (
|
||||||
|
|
||||||
type AdmissionregistrationInterface interface {
|
type AdmissionregistrationInterface interface {
|
||||||
RESTClient() rest.Interface
|
RESTClient() rest.Interface
|
||||||
InitializerConfigurationsGetter
|
|
||||||
MutatingWebhookConfigurationsGetter
|
MutatingWebhookConfigurationsGetter
|
||||||
ValidatingWebhookConfigurationsGetter
|
ValidatingWebhookConfigurationsGetter
|
||||||
}
|
}
|
||||||
|
@ -35,10 +34,6 @@ type AdmissionregistrationClient struct {
|
||||||
restClient rest.Interface
|
restClient rest.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AdmissionregistrationClient) InitializerConfigurations() InitializerConfigurationInterface {
|
|
||||||
return newInitializerConfigurations(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *AdmissionregistrationClient) MutatingWebhookConfigurations() MutatingWebhookConfigurationInterface {
|
func (c *AdmissionregistrationClient) MutatingWebhookConfigurations() MutatingWebhookConfigurationInterface {
|
||||||
return newMutatingWebhookConfigurations(c)
|
return newMutatingWebhookConfigurations(c)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ go_library(
|
||||||
srcs = [
|
srcs = [
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"fake_admissionregistration_client.go",
|
"fake_admissionregistration_client.go",
|
||||||
"fake_initializerconfiguration.go",
|
|
||||||
"fake_mutatingwebhookconfiguration.go",
|
"fake_mutatingwebhookconfiguration.go",
|
||||||
"fake_validatingwebhookconfiguration.go",
|
"fake_validatingwebhookconfiguration.go",
|
||||||
],
|
],
|
||||||
|
|
|
@ -28,10 +28,6 @@ type FakeAdmissionregistration struct {
|
||||||
*testing.Fake
|
*testing.Fake
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakeAdmissionregistration) InitializerConfigurations() internalversion.InitializerConfigurationInterface {
|
|
||||||
return &FakeInitializerConfigurations{c}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *FakeAdmissionregistration) MutatingWebhookConfigurations() internalversion.MutatingWebhookConfigurationInterface {
|
func (c *FakeAdmissionregistration) MutatingWebhookConfigurations() internalversion.MutatingWebhookConfigurationInterface {
|
||||||
return &FakeMutatingWebhookConfigurations{c}
|
return &FakeMutatingWebhookConfigurations{c}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,120 +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 (
|
|
||||||
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"
|
|
||||||
admissionregistration "k8s.io/kubernetes/pkg/apis/admissionregistration"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FakeInitializerConfigurations implements InitializerConfigurationInterface
|
|
||||||
type FakeInitializerConfigurations struct {
|
|
||||||
Fake *FakeAdmissionregistration
|
|
||||||
}
|
|
||||||
|
|
||||||
var initializerconfigurationsResource = schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "", Resource: "initializerconfigurations"}
|
|
||||||
|
|
||||||
var initializerconfigurationsKind = schema.GroupVersionKind{Group: "admissionregistration.k8s.io", Version: "", Kind: "InitializerConfiguration"}
|
|
||||||
|
|
||||||
// Get takes name of the initializerConfiguration, and returns the corresponding initializerConfiguration object, and an error if there is any.
|
|
||||||
func (c *FakeInitializerConfigurations) Get(name string, options v1.GetOptions) (result *admissionregistration.InitializerConfiguration, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootGetAction(initializerconfigurationsResource, name), &admissionregistration.InitializerConfiguration{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*admissionregistration.InitializerConfiguration), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// List takes label and field selectors, and returns the list of InitializerConfigurations that match those selectors.
|
|
||||||
func (c *FakeInitializerConfigurations) List(opts v1.ListOptions) (result *admissionregistration.InitializerConfigurationList, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootListAction(initializerconfigurationsResource, initializerconfigurationsKind, opts), &admissionregistration.InitializerConfigurationList{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
|
||||||
if label == nil {
|
|
||||||
label = labels.Everything()
|
|
||||||
}
|
|
||||||
list := &admissionregistration.InitializerConfigurationList{ListMeta: obj.(*admissionregistration.InitializerConfigurationList).ListMeta}
|
|
||||||
for _, item := range obj.(*admissionregistration.InitializerConfigurationList).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 initializerConfigurations.
|
|
||||||
func (c *FakeInitializerConfigurations) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
|
||||||
return c.Fake.
|
|
||||||
InvokesWatch(testing.NewRootWatchAction(initializerconfigurationsResource, opts))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create takes the representation of a initializerConfiguration and creates it. Returns the server's representation of the initializerConfiguration, and an error, if there is any.
|
|
||||||
func (c *FakeInitializerConfigurations) Create(initializerConfiguration *admissionregistration.InitializerConfiguration) (result *admissionregistration.InitializerConfiguration, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootCreateAction(initializerconfigurationsResource, initializerConfiguration), &admissionregistration.InitializerConfiguration{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*admissionregistration.InitializerConfiguration), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update takes the representation of a initializerConfiguration and updates it. Returns the server's representation of the initializerConfiguration, and an error, if there is any.
|
|
||||||
func (c *FakeInitializerConfigurations) Update(initializerConfiguration *admissionregistration.InitializerConfiguration) (result *admissionregistration.InitializerConfiguration, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootUpdateAction(initializerconfigurationsResource, initializerConfiguration), &admissionregistration.InitializerConfiguration{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*admissionregistration.InitializerConfiguration), err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete takes name of the initializerConfiguration and deletes it. Returns an error if one occurs.
|
|
||||||
func (c *FakeInitializerConfigurations) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
_, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootDeleteAction(initializerconfigurationsResource, name), &admissionregistration.InitializerConfiguration{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCollection deletes a collection of objects.
|
|
||||||
func (c *FakeInitializerConfigurations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
|
||||||
action := testing.NewRootDeleteCollectionAction(initializerconfigurationsResource, listOptions)
|
|
||||||
|
|
||||||
_, err := c.Fake.Invokes(action, &admissionregistration.InitializerConfigurationList{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched initializerConfiguration.
|
|
||||||
func (c *FakeInitializerConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *admissionregistration.InitializerConfiguration, err error) {
|
|
||||||
obj, err := c.Fake.
|
|
||||||
Invokes(testing.NewRootPatchSubresourceAction(initializerconfigurationsResource, name, pt, data, subresources...), &admissionregistration.InitializerConfiguration{})
|
|
||||||
if obj == nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return obj.(*admissionregistration.InitializerConfiguration), err
|
|
||||||
}
|
|
|
@ -18,8 +18,6 @@ limitations under the License.
|
||||||
|
|
||||||
package internalversion
|
package internalversion
|
||||||
|
|
||||||
type InitializerConfigurationExpansion interface{}
|
|
||||||
|
|
||||||
type MutatingWebhookConfigurationExpansion interface{}
|
type MutatingWebhookConfigurationExpansion interface{}
|
||||||
|
|
||||||
type ValidatingWebhookConfigurationExpansion interface{}
|
type ValidatingWebhookConfigurationExpansion interface{}
|
||||||
|
|
|
@ -1,164 +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 internalversion
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
|
||||||
watch "k8s.io/apimachinery/pkg/watch"
|
|
||||||
rest "k8s.io/client-go/rest"
|
|
||||||
admissionregistration "k8s.io/kubernetes/pkg/apis/admissionregistration"
|
|
||||||
scheme "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/scheme"
|
|
||||||
)
|
|
||||||
|
|
||||||
// InitializerConfigurationsGetter has a method to return a InitializerConfigurationInterface.
|
|
||||||
// A group's client should implement this interface.
|
|
||||||
type InitializerConfigurationsGetter interface {
|
|
||||||
InitializerConfigurations() InitializerConfigurationInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitializerConfigurationInterface has methods to work with InitializerConfiguration resources.
|
|
||||||
type InitializerConfigurationInterface interface {
|
|
||||||
Create(*admissionregistration.InitializerConfiguration) (*admissionregistration.InitializerConfiguration, error)
|
|
||||||
Update(*admissionregistration.InitializerConfiguration) (*admissionregistration.InitializerConfiguration, error)
|
|
||||||
Delete(name string, options *v1.DeleteOptions) error
|
|
||||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
|
||||||
Get(name string, options v1.GetOptions) (*admissionregistration.InitializerConfiguration, error)
|
|
||||||
List(opts v1.ListOptions) (*admissionregistration.InitializerConfigurationList, error)
|
|
||||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
|
||||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *admissionregistration.InitializerConfiguration, err error)
|
|
||||||
InitializerConfigurationExpansion
|
|
||||||
}
|
|
||||||
|
|
||||||
// initializerConfigurations implements InitializerConfigurationInterface
|
|
||||||
type initializerConfigurations struct {
|
|
||||||
client rest.Interface
|
|
||||||
}
|
|
||||||
|
|
||||||
// newInitializerConfigurations returns a InitializerConfigurations
|
|
||||||
func newInitializerConfigurations(c *AdmissionregistrationClient) *initializerConfigurations {
|
|
||||||
return &initializerConfigurations{
|
|
||||||
client: c.RESTClient(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get takes name of the initializerConfiguration, and returns the corresponding initializerConfiguration object, and an error if there is any.
|
|
||||||
func (c *initializerConfigurations) Get(name string, options v1.GetOptions) (result *admissionregistration.InitializerConfiguration, err error) {
|
|
||||||
result = &admissionregistration.InitializerConfiguration{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Resource("initializerconfigurations").
|
|
||||||
Name(name).
|
|
||||||
VersionedParams(&options, scheme.ParameterCodec).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// List takes label and field selectors, and returns the list of InitializerConfigurations that match those selectors.
|
|
||||||
func (c *initializerConfigurations) List(opts v1.ListOptions) (result *admissionregistration.InitializerConfigurationList, err error) {
|
|
||||||
var timeout time.Duration
|
|
||||||
if opts.TimeoutSeconds != nil {
|
|
||||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
|
||||||
}
|
|
||||||
result = &admissionregistration.InitializerConfigurationList{}
|
|
||||||
err = c.client.Get().
|
|
||||||
Resource("initializerconfigurations").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Timeout(timeout).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch returns a watch.Interface that watches the requested initializerConfigurations.
|
|
||||||
func (c *initializerConfigurations) 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().
|
|
||||||
Resource("initializerconfigurations").
|
|
||||||
VersionedParams(&opts, scheme.ParameterCodec).
|
|
||||||
Timeout(timeout).
|
|
||||||
Watch()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create takes the representation of a initializerConfiguration and creates it. Returns the server's representation of the initializerConfiguration, and an error, if there is any.
|
|
||||||
func (c *initializerConfigurations) Create(initializerConfiguration *admissionregistration.InitializerConfiguration) (result *admissionregistration.InitializerConfiguration, err error) {
|
|
||||||
result = &admissionregistration.InitializerConfiguration{}
|
|
||||||
err = c.client.Post().
|
|
||||||
Resource("initializerconfigurations").
|
|
||||||
Body(initializerConfiguration).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update takes the representation of a initializerConfiguration and updates it. Returns the server's representation of the initializerConfiguration, and an error, if there is any.
|
|
||||||
func (c *initializerConfigurations) Update(initializerConfiguration *admissionregistration.InitializerConfiguration) (result *admissionregistration.InitializerConfiguration, err error) {
|
|
||||||
result = &admissionregistration.InitializerConfiguration{}
|
|
||||||
err = c.client.Put().
|
|
||||||
Resource("initializerconfigurations").
|
|
||||||
Name(initializerConfiguration.Name).
|
|
||||||
Body(initializerConfiguration).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete takes name of the initializerConfiguration and deletes it. Returns an error if one occurs.
|
|
||||||
func (c *initializerConfigurations) Delete(name string, options *v1.DeleteOptions) error {
|
|
||||||
return c.client.Delete().
|
|
||||||
Resource("initializerconfigurations").
|
|
||||||
Name(name).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCollection deletes a collection of objects.
|
|
||||||
func (c *initializerConfigurations) 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().
|
|
||||||
Resource("initializerconfigurations").
|
|
||||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
|
||||||
Timeout(timeout).
|
|
||||||
Body(options).
|
|
||||||
Do().
|
|
||||||
Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch applies the patch and returns the patched initializerConfiguration.
|
|
||||||
func (c *initializerConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *admissionregistration.InitializerConfiguration, err error) {
|
|
||||||
result = &admissionregistration.InitializerConfiguration{}
|
|
||||||
err = c.client.Patch(pt).
|
|
||||||
Resource("initializerconfigurations").
|
|
||||||
SubResource(subresources...).
|
|
||||||
Name(name).
|
|
||||||
Body(data).
|
|
||||||
Do().
|
|
||||||
Into(result)
|
|
||||||
return
|
|
||||||
}
|
|
|
@ -80,14 +80,12 @@
|
||||||
"k8s.io/apiserver/pkg/storage",
|
"k8s.io/apiserver/pkg/storage",
|
||||||
"k8s.io/api/batch/v2alpha1",
|
"k8s.io/api/batch/v2alpha1",
|
||||||
"k8s.io/apiserver/pkg/registry/rest",
|
"k8s.io/apiserver/pkg/registry/rest",
|
||||||
"k8s.io/apimachinery/pkg/util/initialization",
|
|
||||||
"k8s.io/api/scheduling/v1alpha1",
|
"k8s.io/api/scheduling/v1alpha1",
|
||||||
"k8s.io/api/admissionregistration/v1beta1",
|
"k8s.io/api/admissionregistration/v1beta1",
|
||||||
"k8s.io/api/authorization/v1",
|
"k8s.io/api/authorization/v1",
|
||||||
"k8s.io/api/settings/v1alpha1",
|
"k8s.io/api/settings/v1alpha1",
|
||||||
"k8s.io/api/admission/v1beta1",
|
"k8s.io/api/admission/v1beta1",
|
||||||
"k8s.io/api/networking/v1",
|
"k8s.io/api/networking/v1",
|
||||||
"k8s.io/api/admissionregistration/v1alpha1",
|
|
||||||
"k8s.io/component-base/config",
|
"k8s.io/component-base/config",
|
||||||
"k8s.io/component-base/config/v1alpha1"
|
"k8s.io/component-base/config/v1alpha1"
|
||||||
]
|
]
|
||||||
|
@ -314,7 +312,6 @@
|
||||||
"k8s.io/kubernetes/pkg/util/net/sets",
|
"k8s.io/kubernetes/pkg/util/net/sets",
|
||||||
"k8s.io/kubernetes/pkg/util/parsers",
|
"k8s.io/kubernetes/pkg/util/parsers",
|
||||||
"k8s.io/kubernetes/pkg/fieldpath",
|
"k8s.io/kubernetes/pkg/fieldpath",
|
||||||
"k8s.io/kubernetes/pkg/kubeapiserver/admission/util",
|
|
||||||
"k8s.io/kubernetes/pkg/scheduler/volumebinder",
|
"k8s.io/kubernetes/pkg/scheduler/volumebinder",
|
||||||
"k8s.io/kubernetes/pkg/scheduler/internal/cache",
|
"k8s.io/kubernetes/pkg/scheduler/internal/cache",
|
||||||
"k8s.io/kubernetes/pkg/util/nsenter",
|
"k8s.io/kubernetes/pkg/util/nsenter",
|
||||||
|
|
|
@ -44,8 +44,6 @@ import (
|
||||||
volumeutil "k8s.io/kubernetes/pkg/volume/util"
|
volumeutil "k8s.io/kubernetes/pkg/volume/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const initializerName = "pvlabel.kubernetes.io"
|
|
||||||
|
|
||||||
// PersistentVolumeLabelController handles adding labels to persistent volumes when they are created
|
// PersistentVolumeLabelController handles adding labels to persistent volumes when they are created
|
||||||
type PersistentVolumeLabelController struct {
|
type PersistentVolumeLabelController struct {
|
||||||
cloud cloudprovider.Interface
|
cloud cloudprovider.Interface
|
||||||
|
@ -74,11 +72,9 @@ func NewPersistentVolumeLabelController(
|
||||||
pvlc.pvlIndexer, pvlc.pvlController = cache.NewIndexerInformer(
|
pvlc.pvlIndexer, pvlc.pvlController = cache.NewIndexerInformer(
|
||||||
&cache.ListWatch{
|
&cache.ListWatch{
|
||||||
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
|
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
|
||||||
options.IncludeUninitialized = true
|
|
||||||
return kubeClient.CoreV1().PersistentVolumes().List(options)
|
return kubeClient.CoreV1().PersistentVolumes().List(options)
|
||||||
},
|
},
|
||||||
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
|
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
|
||||||
options.IncludeUninitialized = true
|
|
||||||
return kubeClient.CoreV1().PersistentVolumes().Watch(options)
|
return kubeClient.CoreV1().PersistentVolumes().Watch(options)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -184,7 +180,7 @@ func (pvlc *PersistentVolumeLabelController) addLabelsAndAffinity(key string) er
|
||||||
func (pvlc *PersistentVolumeLabelController) addLabelsAndAffinityToVolume(vol *v1.PersistentVolume) error {
|
func (pvlc *PersistentVolumeLabelController) addLabelsAndAffinityToVolume(vol *v1.PersistentVolume) error {
|
||||||
var volumeLabels map[string]string
|
var volumeLabels map[string]string
|
||||||
// Only add labels if the next pending initializer.
|
// Only add labels if the next pending initializer.
|
||||||
if needsInitialization(vol.Initializers, initializerName) {
|
if needsInitialization(vol) {
|
||||||
if labeler, ok := (pvlc.cloud).(cloudprovider.PVLabeler); ok {
|
if labeler, ok := (pvlc.cloud).(cloudprovider.PVLabeler); ok {
|
||||||
labels, err := labeler.GetLabelsForVolume(context.TODO(), vol)
|
labels, err := labeler.GetLabelsForVolume(context.TODO(), vol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -249,8 +245,8 @@ func (pvlc *PersistentVolumeLabelController) createPatch(vol *v1.PersistentVolum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newVolume.Initializers = removeInitializer(newVolume.Initializers, initializerName)
|
markInitialized(newVolume)
|
||||||
klog.V(4).Infof("removed initializer on PersistentVolume %s", newVolume.Name)
|
klog.V(4).Infof("marked PersistentVolume %s initialized", newVolume.Name)
|
||||||
|
|
||||||
oldData, err := json.Marshal(vol)
|
oldData, err := json.Marshal(vol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -286,38 +282,13 @@ func (pvlc *PersistentVolumeLabelController) updateVolume(vol *v1.PersistentVolu
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeInitializer(initializers *metav1.Initializers, name string) *metav1.Initializers {
|
func markInitialized(vol *v1.PersistentVolume) {
|
||||||
if initializers == nil {
|
// TODO: mark initialized using a different field, since initializers are not being promoted past alpha, or convert to an admission plugin
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var updated []metav1.Initializer
|
|
||||||
for _, pending := range initializers.Pending {
|
|
||||||
if pending.Name != name {
|
|
||||||
updated = append(updated, pending)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(updated) == len(initializers.Pending) {
|
|
||||||
return initializers
|
|
||||||
}
|
|
||||||
if len(updated) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return &metav1.Initializers{Pending: updated}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// needsInitialization checks whether or not the PVL is the next pending initializer.
|
// needsInitialization checks whether or not the PVL is the next pending initializer.
|
||||||
func needsInitialization(initializers *metav1.Initializers, name string) bool {
|
func needsInitialization(vol *v1.PersistentVolume) bool {
|
||||||
if initializers == nil {
|
// TODO: determine whether initialization is required based on a different attribute,
|
||||||
return false
|
// since initializers are not being promoted past alpha, or convert to an admission plugin
|
||||||
}
|
return false
|
||||||
|
|
||||||
if len(initializers.Pending) == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is at least one initializer still pending so check to
|
|
||||||
// see if the PVL is the next in line.
|
|
||||||
return initializers.Pending[0].Name == name
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,13 +129,6 @@ func TestCreatePatch(t *testing.T) {
|
||||||
ignoredPV := v1.PersistentVolume{
|
ignoredPV := v1.PersistentVolume{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "noncloud",
|
Name: "noncloud",
|
||||||
Initializers: &metav1.Initializers{
|
|
||||||
Pending: []metav1.Initializer{
|
|
||||||
{
|
|
||||||
Name: initializerName,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
|
@ -148,13 +141,6 @@ func TestCreatePatch(t *testing.T) {
|
||||||
awsPV := v1.PersistentVolume{
|
awsPV := v1.PersistentVolume{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "awsPV",
|
Name: "awsPV",
|
||||||
Initializers: &metav1.Initializers{
|
|
||||||
Pending: []metav1.Initializer{
|
|
||||||
{
|
|
||||||
Name: initializerName,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
|
@ -217,13 +203,6 @@ func TestCreatePatch(t *testing.T) {
|
||||||
awsPVWithAffinity := v1.PersistentVolume{
|
awsPVWithAffinity := v1.PersistentVolume{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "awsPV",
|
Name: "awsPV",
|
||||||
Initializers: &metav1.Initializers{
|
|
||||||
Pending: []metav1.Initializer{
|
|
||||||
{
|
|
||||||
Name: initializerName,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
|
@ -458,9 +437,12 @@ func TestCreatePatch(t *testing.T) {
|
||||||
}
|
}
|
||||||
obj := &v1.PersistentVolume{}
|
obj := &v1.PersistentVolume{}
|
||||||
json.Unmarshal(patch, obj)
|
json.Unmarshal(patch, obj)
|
||||||
if obj.ObjectMeta.Initializers != nil {
|
|
||||||
t.Errorf("%s: initializer wasn't removed: %v", d, obj.ObjectMeta.Initializers)
|
// TODO: check if object was marked as initialized
|
||||||
}
|
// if ... object was not marked as initialized ... {
|
||||||
|
// t.Errorf("%s: wasn't marked as initialized: %#v", d, obj)
|
||||||
|
// }
|
||||||
|
|
||||||
if tc.labels == nil {
|
if tc.labels == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -491,29 +473,24 @@ func TestAddLabelsToVolume(t *testing.T) {
|
||||||
|
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
vol v1.PersistentVolume
|
vol v1.PersistentVolume
|
||||||
initializers *metav1.Initializers
|
|
||||||
shouldLabelAndSetAffinity bool
|
shouldLabelAndSetAffinity bool
|
||||||
}{
|
}{
|
||||||
"PV without initializer": {
|
"PV without initializer": {
|
||||||
vol: pv,
|
vol: pv,
|
||||||
initializers: nil,
|
|
||||||
shouldLabelAndSetAffinity: false,
|
|
||||||
},
|
|
||||||
"PV with initializer to remove": {
|
|
||||||
vol: pv,
|
|
||||||
initializers: &metav1.Initializers{Pending: []metav1.Initializer{{Name: initializerName}}},
|
|
||||||
shouldLabelAndSetAffinity: true,
|
|
||||||
},
|
|
||||||
"PV with other initializers only": {
|
|
||||||
vol: pv,
|
|
||||||
initializers: &metav1.Initializers{Pending: []metav1.Initializer{{Name: "OtherInit"}}},
|
|
||||||
shouldLabelAndSetAffinity: false,
|
|
||||||
},
|
|
||||||
"PV with other initializers first": {
|
|
||||||
vol: pv,
|
|
||||||
initializers: &metav1.Initializers{Pending: []metav1.Initializer{{Name: "OtherInit"}, {Name: initializerName}}},
|
|
||||||
shouldLabelAndSetAffinity: false,
|
shouldLabelAndSetAffinity: false,
|
||||||
},
|
},
|
||||||
|
// "PV with initializer to remove": {
|
||||||
|
// vol: pv,
|
||||||
|
// shouldLabelAndSetAffinity: true,
|
||||||
|
// },
|
||||||
|
// "PV with other initializers only": {
|
||||||
|
// vol: pv,
|
||||||
|
// shouldLabelAndSetAffinity: false,
|
||||||
|
// },
|
||||||
|
// "PV with other initializers first": {
|
||||||
|
// vol: pv,
|
||||||
|
// shouldLabelAndSetAffinity: false,
|
||||||
|
// },
|
||||||
}
|
}
|
||||||
|
|
||||||
for d, tc := range testCases {
|
for d, tc := range testCases {
|
||||||
|
@ -550,7 +527,6 @@ func TestAddLabelsToVolume(t *testing.T) {
|
||||||
VolumeLabelMap: map[string]map[string]string{"awsPV": {"a": "1"}},
|
VolumeLabelMap: map[string]map[string]string{"awsPV": {"a": "1"}},
|
||||||
}
|
}
|
||||||
pvlController := &PersistentVolumeLabelController{kubeClient: client, cloud: fakeCloud}
|
pvlController := &PersistentVolumeLabelController{kubeClient: client, cloud: fakeCloud}
|
||||||
tc.vol.ObjectMeta.Initializers = tc.initializers
|
|
||||||
pvlController.addLabelsAndAffinityToVolume(&tc.vol)
|
pvlController.addLabelsAndAffinityToVolume(&tc.vol)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -378,7 +378,7 @@ func (d *namespacedResourcesDeleter) listCollection(gvr schema.GroupVersionResou
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
unstructuredList, err := d.dynamicClient.Resource(gvr).Namespace(namespace).List(metav1.ListOptions{IncludeUninitialized: true})
|
unstructuredList, err := d.dynamicClient.Resource(gvr).Namespace(namespace).List(metav1.ListOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return unstructuredList, true, nil
|
return unstructuredList, true, nil
|
||||||
}
|
}
|
||||||
|
@ -543,7 +543,7 @@ func (d *namespacedResourcesDeleter) estimateGracefulTerminationForPods(ns strin
|
||||||
if podsGetter == nil || reflect.ValueOf(podsGetter).IsNil() {
|
if podsGetter == nil || reflect.ValueOf(podsGetter).IsNil() {
|
||||||
return estimate, fmt.Errorf("unexpected: podsGetter is nil. Cannot estimate grace period seconds for pods")
|
return estimate, fmt.Errorf("unexpected: podsGetter is nil. Cannot estimate grace period seconds for pods")
|
||||||
}
|
}
|
||||||
items, err := podsGetter.Pods(ns).List(metav1.ListOptions{IncludeUninitialized: true})
|
items, err := podsGetter.Pods(ns).List(metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return estimate, err
|
return estimate, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,7 +485,6 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
|
||||||
genericfeatures.AdvancedAuditing: {Default: true, PreRelease: utilfeature.GA},
|
genericfeatures.AdvancedAuditing: {Default: true, PreRelease: utilfeature.GA},
|
||||||
genericfeatures.DynamicAuditing: {Default: false, PreRelease: utilfeature.Alpha},
|
genericfeatures.DynamicAuditing: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
genericfeatures.APIResponseCompression: {Default: false, PreRelease: utilfeature.Alpha},
|
genericfeatures.APIResponseCompression: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
genericfeatures.Initializers: {Default: false, PreRelease: utilfeature.Alpha},
|
|
||||||
genericfeatures.APIListChunking: {Default: true, PreRelease: utilfeature.Beta},
|
genericfeatures.APIListChunking: {Default: true, PreRelease: utilfeature.Beta},
|
||||||
genericfeatures.DryRun: {Default: true, PreRelease: utilfeature.Beta},
|
genericfeatures.DryRun: {Default: true, PreRelease: utilfeature.Beta},
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ go_library(
|
||||||
importpath = "k8s.io/kubernetes/pkg/kubeapiserver",
|
importpath = "k8s.io/kubernetes/pkg/kubeapiserver",
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/api/legacyscheme:go_default_library",
|
"//pkg/api/legacyscheme:go_default_library",
|
||||||
"//pkg/apis/admissionregistration:go_default_library",
|
|
||||||
"//pkg/apis/apps:go_default_library",
|
"//pkg/apis/apps:go_default_library",
|
||||||
"//pkg/apis/batch:go_default_library",
|
"//pkg/apis/batch:go_default_library",
|
||||||
"//pkg/apis/core:go_default_library",
|
"//pkg/apis/core:go_default_library",
|
||||||
|
|
|
@ -43,10 +43,7 @@ filegroup(
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "all-srcs",
|
name = "all-srcs",
|
||||||
srcs = [
|
srcs = [":package-srcs"],
|
||||||
":package-srcs",
|
|
||||||
"//pkg/kubeapiserver/admission/util:all-srcs",
|
|
||||||
],
|
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = ["initializer.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/kubeapiserver/admission/util",
|
|
||||||
deps = [
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/initialization:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "package-srcs",
|
|
||||||
srcs = glob(["**"]),
|
|
||||||
tags = ["automanaged"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "all-srcs",
|
|
||||||
srcs = [":package-srcs"],
|
|
||||||
tags = ["automanaged"],
|
|
||||||
)
|
|
|
@ -1,79 +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 util
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
|
||||||
"k8s.io/apimachinery/pkg/util/initialization"
|
|
||||||
"k8s.io/apiserver/pkg/admission"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsUpdatingInitializedObject returns true if the operation is trying to update
|
|
||||||
// an already initialized object.
|
|
||||||
func IsUpdatingInitializedObject(a admission.Attributes) (bool, error) {
|
|
||||||
if a.GetOperation() != admission.Update {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
oldObj := a.GetOldObject()
|
|
||||||
accessor, err := meta.Accessor(oldObj)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
if initialization.IsInitialized(accessor.GetInitializers()) {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsUpdatingUninitializedObject returns true if the operation is trying to
|
|
||||||
// update an object that is not initialized yet.
|
|
||||||
func IsUpdatingUninitializedObject(a admission.Attributes) (bool, error) {
|
|
||||||
if a.GetOperation() != admission.Update {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
oldObj := a.GetOldObject()
|
|
||||||
accessor, err := meta.Accessor(oldObj)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
if initialization.IsInitialized(accessor.GetInitializers()) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsInitializationCompletion returns true if the operation removes all pending
|
|
||||||
// initializers.
|
|
||||||
func IsInitializationCompletion(a admission.Attributes) (bool, error) {
|
|
||||||
if a.GetOperation() != admission.Update {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
oldObj := a.GetOldObject()
|
|
||||||
oldInitialized, err := initialization.IsObjectInitialized(oldObj)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
if oldInitialized {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
newObj := a.GetObject()
|
|
||||||
newInitialized, err := initialization.IsObjectInitialized(newObj)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return newInitialized, nil
|
|
||||||
}
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
serveroptions "k8s.io/apiserver/pkg/server/options"
|
serveroptions "k8s.io/apiserver/pkg/server/options"
|
||||||
|
@ -28,7 +29,6 @@ import (
|
||||||
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
||||||
"k8s.io/apiserver/pkg/storage/storagebackend"
|
"k8s.io/apiserver/pkg/storage/storagebackend"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/apps"
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
"k8s.io/kubernetes/pkg/apis/batch"
|
"k8s.io/kubernetes/pkg/apis/batch"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
|
@ -58,7 +58,6 @@ func NewStorageFactoryConfig() *StorageFactoryConfig {
|
||||||
ResourceEncodingOverrides: []schema.GroupVersionResource{
|
ResourceEncodingOverrides: []schema.GroupVersionResource{
|
||||||
batch.Resource("cronjobs").WithVersion("v1beta1"),
|
batch.Resource("cronjobs").WithVersion("v1beta1"),
|
||||||
apisstorage.Resource("volumeattachments").WithVersion("v1beta1"),
|
apisstorage.Resource("volumeattachments").WithVersion("v1beta1"),
|
||||||
admissionregistration.Resource("initializerconfigurations").WithVersion("v1alpha1"),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ go_library(
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/initialization:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating:go_default_library",
|
||||||
|
|
|
@ -53,7 +53,6 @@ import (
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apiserver/pkg/admission"
|
"k8s.io/apiserver/pkg/admission"
|
||||||
"k8s.io/apiserver/pkg/admission/plugin/initialization"
|
|
||||||
"k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle"
|
"k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle"
|
||||||
mutatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/mutating"
|
mutatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/mutating"
|
||||||
validatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/validating"
|
validatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/validating"
|
||||||
|
@ -90,7 +89,6 @@ var AllOrderedPlugins = []string{
|
||||||
gc.PluginName, // OwnerReferencesPermissionEnforcement
|
gc.PluginName, // OwnerReferencesPermissionEnforcement
|
||||||
resize.PluginName, // PersistentVolumeClaimResize
|
resize.PluginName, // PersistentVolumeClaimResize
|
||||||
mutatingwebhook.PluginName, // MutatingAdmissionWebhook
|
mutatingwebhook.PluginName, // MutatingAdmissionWebhook
|
||||||
initialization.PluginName, // Initializers
|
|
||||||
validatingwebhook.PluginName, // ValidatingAdmissionWebhook
|
validatingwebhook.PluginName, // ValidatingAdmissionWebhook
|
||||||
resourcequota.PluginName, // ResourceQuota
|
resourcequota.PluginName, // ResourceQuota
|
||||||
deny.PluginName, // AlwaysDeny
|
deny.PluginName, // AlwaysDeny
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
"k8s.io/kubernetes/pkg/api/v1/service",
|
"k8s.io/kubernetes/pkg/api/v1/service",
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration",
|
"k8s.io/kubernetes/pkg/apis/admissionregistration",
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration/install",
|
"k8s.io/kubernetes/pkg/apis/admissionregistration/install",
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration/v1alpha1",
|
|
||||||
"k8s.io/kubernetes/pkg/apis/apps",
|
"k8s.io/kubernetes/pkg/apis/apps",
|
||||||
"k8s.io/kubernetes/pkg/apis/apps/install",
|
"k8s.io/kubernetes/pkg/apis/apps/install",
|
||||||
"k8s.io/kubernetes/pkg/apis/apps/v1",
|
"k8s.io/kubernetes/pkg/apis/apps/v1",
|
||||||
|
|
|
@ -69,7 +69,6 @@ type AnnotateOptions struct {
|
||||||
enforceNamespace bool
|
enforceNamespace bool
|
||||||
builder *resource.Builder
|
builder *resource.Builder
|
||||||
unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
||||||
includeUninitialized bool
|
|
||||||
|
|
||||||
genericclioptions.IOStreams
|
genericclioptions.IOStreams
|
||||||
}
|
}
|
||||||
|
@ -183,7 +182,6 @@ func (o *AnnotateOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
o.includeUninitialized = cmdutil.ShouldIncludeUninitialized(cmd, false)
|
|
||||||
o.builder = f.NewBuilder()
|
o.builder = f.NewBuilder()
|
||||||
o.unstructuredClientForMapping = f.UnstructuredClientForMapping
|
o.unstructuredClientForMapping = f.UnstructuredClientForMapping
|
||||||
|
|
||||||
|
@ -227,7 +225,6 @@ func (o AnnotateOptions) RunAnnotate() error {
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
NamespaceParam(o.namespace).DefaultNamespace().
|
NamespaceParam(o.namespace).DefaultNamespace().
|
||||||
FilenameParam(o.enforceNamespace, &o.FilenameOptions).
|
FilenameParam(o.enforceNamespace, &o.FilenameOptions).
|
||||||
IncludeUninitialized(o.includeUninitialized).
|
|
||||||
Flatten()
|
Flatten()
|
||||||
|
|
||||||
if !o.local {
|
if !o.local {
|
||||||
|
|
|
@ -65,17 +65,16 @@ type ApplyOptions struct {
|
||||||
DeleteFlags *delete.DeleteFlags
|
DeleteFlags *delete.DeleteFlags
|
||||||
DeleteOptions *delete.DeleteOptions
|
DeleteOptions *delete.DeleteOptions
|
||||||
|
|
||||||
Selector string
|
Selector string
|
||||||
DryRun bool
|
DryRun bool
|
||||||
ServerDryRun bool
|
ServerDryRun bool
|
||||||
Prune bool
|
Prune bool
|
||||||
PruneResources []pruneResource
|
PruneResources []pruneResource
|
||||||
cmdBaseName string
|
cmdBaseName string
|
||||||
All bool
|
All bool
|
||||||
Overwrite bool
|
Overwrite bool
|
||||||
OpenAPIPatch bool
|
OpenAPIPatch bool
|
||||||
PruneWhitelist []string
|
PruneWhitelist []string
|
||||||
ShouldIncludeUninitialized bool
|
|
||||||
|
|
||||||
Validator validation.Schema
|
Validator validation.Schema
|
||||||
Builder *resource.Builder
|
Builder *resource.Builder
|
||||||
|
@ -224,7 +223,6 @@ func (o *ApplyOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
o.DeleteOptions = o.DeleteFlags.ToOptions(dynamicClient, o.IOStreams)
|
o.DeleteOptions = o.DeleteFlags.ToOptions(dynamicClient, o.IOStreams)
|
||||||
o.ShouldIncludeUninitialized = cmdutil.ShouldIncludeUninitialized(cmd, o.Prune)
|
|
||||||
|
|
||||||
o.OpenAPISchema, _ = f.OpenAPISchema()
|
o.OpenAPISchema, _ = f.OpenAPISchema()
|
||||||
o.Validator, err = f.Validator(cmdutil.GetFlagBool(cmd, "validate"))
|
o.Validator, err = f.Validator(cmdutil.GetFlagBool(cmd, "validate"))
|
||||||
|
@ -315,7 +313,6 @@ func (o *ApplyOptions) Run() error {
|
||||||
NamespaceParam(o.Namespace).DefaultNamespace().
|
NamespaceParam(o.Namespace).DefaultNamespace().
|
||||||
FilenameParam(o.EnforceNamespace, &o.DeleteOptions.FilenameOptions).
|
FilenameParam(o.EnforceNamespace, &o.DeleteOptions.FilenameOptions).
|
||||||
LabelSelectorParam(o.Selector).
|
LabelSelectorParam(o.Selector).
|
||||||
IncludeUninitialized(o.ShouldIncludeUninitialized).
|
|
||||||
Flatten().
|
Flatten().
|
||||||
Do()
|
Do()
|
||||||
if err := r.Err(); err != nil {
|
if err := r.Err(); err != nil {
|
||||||
|
@ -535,13 +532,13 @@ func (o *ApplyOptions) Run() error {
|
||||||
|
|
||||||
for n := range visitedNamespaces {
|
for n := range visitedNamespaces {
|
||||||
for _, m := range namespacedRESTMappings {
|
for _, m := range namespacedRESTMappings {
|
||||||
if err := p.prune(n, m, o.ShouldIncludeUninitialized); err != nil {
|
if err := p.prune(n, m); err != nil {
|
||||||
return fmt.Errorf("error pruning namespaced object %v: %v", m.GroupVersionKind, err)
|
return fmt.Errorf("error pruning namespaced object %v: %v", m.GroupVersionKind, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, m := range nonNamespacedRESTMappings {
|
for _, m := range nonNamespacedRESTMappings {
|
||||||
if err := p.prune(metav1.NamespaceNone, m, o.ShouldIncludeUninitialized); err != nil {
|
if err := p.prune(metav1.NamespaceNone, m); err != nil {
|
||||||
return fmt.Errorf("error pruning nonNamespaced object %v: %v", m.GroupVersionKind, err)
|
return fmt.Errorf("error pruning nonNamespaced object %v: %v", m.GroupVersionKind, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -617,13 +614,12 @@ type pruner struct {
|
||||||
out io.Writer
|
out io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pruner) prune(namespace string, mapping *meta.RESTMapping, includeUninitialized bool) error {
|
func (p *pruner) prune(namespace string, mapping *meta.RESTMapping) error {
|
||||||
objList, err := p.dynamicClient.Resource(mapping.Resource).
|
objList, err := p.dynamicClient.Resource(mapping.Resource).
|
||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
List(metav1.ListOptions{
|
List(metav1.ListOptions{
|
||||||
LabelSelector: p.labelSelector,
|
LabelSelector: p.labelSelector,
|
||||||
FieldSelector: p.fieldSelector,
|
FieldSelector: p.fieldSelector,
|
||||||
IncludeUninitialized: includeUninitialized,
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -162,7 +162,6 @@ func (o *DeleteOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Co
|
||||||
o.GracePeriod = 1
|
o.GracePeriod = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
includeUninitialized := cmdutil.ShouldIncludeUninitialized(cmd, false)
|
|
||||||
r := f.NewBuilder().
|
r := f.NewBuilder().
|
||||||
Unstructured().
|
Unstructured().
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
|
@ -170,7 +169,6 @@ func (o *DeleteOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Co
|
||||||
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
||||||
LabelSelectorParam(o.LabelSelector).
|
LabelSelectorParam(o.LabelSelector).
|
||||||
FieldSelectorParam(o.FieldSelector).
|
FieldSelectorParam(o.FieldSelector).
|
||||||
IncludeUninitialized(includeUninitialized).
|
|
||||||
SelectAllParam(o.DeleteAll).
|
SelectAllParam(o.DeleteAll).
|
||||||
ResourceTypeOrNameArgs(false, args...).RequireObject(false).
|
ResourceTypeOrNameArgs(false, args...).RequireObject(false).
|
||||||
Flatten().
|
Flatten().
|
||||||
|
|
|
@ -79,9 +79,8 @@ type DescribeOptions struct {
|
||||||
|
|
||||||
BuilderArgs []string
|
BuilderArgs []string
|
||||||
|
|
||||||
EnforceNamespace bool
|
EnforceNamespace bool
|
||||||
AllNamespaces bool
|
AllNamespaces bool
|
||||||
IncludeUninitialized bool
|
|
||||||
|
|
||||||
DescriberSettings *describe.DescriberSettings
|
DescriberSettings *describe.DescriberSettings
|
||||||
FilenameOptions *resource.FilenameOptions
|
FilenameOptions *resource.FilenameOptions
|
||||||
|
@ -144,9 +143,6 @@ func (o *DescribeOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
|
||||||
|
|
||||||
o.NewBuilder = f.NewBuilder
|
o.NewBuilder = f.NewBuilder
|
||||||
|
|
||||||
// include the uninitialized objects by default
|
|
||||||
// unless user explicitly set --include-uninitialized=false
|
|
||||||
o.IncludeUninitialized = cmdutil.ShouldIncludeUninitialized(cmd, true)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +157,6 @@ func (o *DescribeOptions) Run() error {
|
||||||
NamespaceParam(o.Namespace).DefaultNamespace().AllNamespaces(o.AllNamespaces).
|
NamespaceParam(o.Namespace).DefaultNamespace().AllNamespaces(o.AllNamespaces).
|
||||||
FilenameParam(o.EnforceNamespace, o.FilenameOptions).
|
FilenameParam(o.EnforceNamespace, o.FilenameOptions).
|
||||||
LabelSelectorParam(o.Selector).
|
LabelSelectorParam(o.Selector).
|
||||||
IncludeUninitialized(o.IncludeUninitialized).
|
|
||||||
ResourceTypeOrNameArgs(true, o.BuilderArgs...).
|
ResourceTypeOrNameArgs(true, o.BuilderArgs...).
|
||||||
Flatten().
|
Flatten().
|
||||||
Do()
|
Do()
|
||||||
|
|
|
@ -79,8 +79,6 @@ type GetOptions struct {
|
||||||
IgnoreNotFound bool
|
IgnoreNotFound bool
|
||||||
Export bool
|
Export bool
|
||||||
|
|
||||||
IncludeUninitialized bool
|
|
||||||
|
|
||||||
genericclioptions.IOStreams
|
genericclioptions.IOStreams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,8 +222,6 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
|
||||||
o.IsHumanReadablePrinter = true
|
o.IsHumanReadablePrinter = true
|
||||||
}
|
}
|
||||||
|
|
||||||
o.IncludeUninitialized = cmdutil.ShouldIncludeUninitialized(cmd, false)
|
|
||||||
|
|
||||||
o.ToPrinter = func(mapping *meta.RESTMapping, withNamespace bool, withKind bool) (printers.ResourcePrinterFunc, error) {
|
o.ToPrinter = func(mapping *meta.RESTMapping, withNamespace bool, withKind bool) (printers.ResourcePrinterFunc, error) {
|
||||||
// make a new copy of current flags / opts before mutating
|
// make a new copy of current flags / opts before mutating
|
||||||
printFlags := o.PrintFlags.Copy()
|
printFlags := o.PrintFlags.Copy()
|
||||||
|
@ -256,9 +252,6 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case o.Watch || o.WatchOnly:
|
case o.Watch || o.WatchOnly:
|
||||||
// include uninitialized objects when watching on a single object
|
|
||||||
// unless explicitly set --include-uninitialized=false
|
|
||||||
o.IncludeUninitialized = cmdutil.ShouldIncludeUninitialized(cmd, len(args) == 2)
|
|
||||||
default:
|
default:
|
||||||
if len(args) == 0 && cmdutil.IsFilenameSliceEmpty(o.Filenames) {
|
if len(args) == 0 && cmdutil.IsFilenameSliceEmpty(o.Filenames) {
|
||||||
fmt.Fprintf(o.ErrOut, "You must specify the type of resource to get. %s\n\n", cmdutil.SuggestAPIResources(o.CmdParent))
|
fmt.Fprintf(o.ErrOut, "You must specify the type of resource to get. %s\n\n", cmdutil.SuggestAPIResources(o.CmdParent))
|
||||||
|
@ -428,7 +421,6 @@ func (o *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
|
||||||
FieldSelectorParam(o.FieldSelector).
|
FieldSelectorParam(o.FieldSelector).
|
||||||
ExportParam(o.Export).
|
ExportParam(o.Export).
|
||||||
RequestChunksOf(chunkSize).
|
RequestChunksOf(chunkSize).
|
||||||
IncludeUninitialized(o.IncludeUninitialized).
|
|
||||||
ResourceTypeOrNameArgs(true, args...).
|
ResourceTypeOrNameArgs(true, args...).
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
Latest().
|
Latest().
|
||||||
|
@ -613,7 +605,6 @@ func (o *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string)
|
||||||
FieldSelectorParam(o.FieldSelector).
|
FieldSelectorParam(o.FieldSelector).
|
||||||
ExportParam(o.Export).
|
ExportParam(o.Export).
|
||||||
RequestChunksOf(o.ChunkSize).
|
RequestChunksOf(o.ChunkSize).
|
||||||
IncludeUninitialized(o.IncludeUninitialized).
|
|
||||||
ResourceTypeOrNameArgs(true, args...).
|
ResourceTypeOrNameArgs(true, args...).
|
||||||
SingleResourceType().
|
SingleResourceType().
|
||||||
Latest().
|
Latest().
|
||||||
|
|
|
@ -72,7 +72,6 @@ type LabelOptions struct {
|
||||||
|
|
||||||
namespace string
|
namespace string
|
||||||
enforceNamespace bool
|
enforceNamespace bool
|
||||||
includeUninitialized bool
|
|
||||||
builder *resource.Builder
|
builder *resource.Builder
|
||||||
unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
||||||
|
|
||||||
|
@ -192,7 +191,6 @@ func (o *LabelOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
o.includeUninitialized = cmdutil.ShouldIncludeUninitialized(cmd, false)
|
|
||||||
o.builder = f.NewBuilder()
|
o.builder = f.NewBuilder()
|
||||||
o.unstructuredClientForMapping = f.UnstructuredClientForMapping
|
o.unstructuredClientForMapping = f.UnstructuredClientForMapping
|
||||||
|
|
||||||
|
@ -224,7 +222,6 @@ func (o *LabelOptions) RunLabel() error {
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
NamespaceParam(o.namespace).DefaultNamespace().
|
NamespaceParam(o.namespace).DefaultNamespace().
|
||||||
FilenameParam(o.enforceNamespace, &o.FilenameOptions).
|
FilenameParam(o.enforceNamespace, &o.FilenameOptions).
|
||||||
IncludeUninitialized(o.includeUninitialized).
|
|
||||||
Flatten()
|
Flatten()
|
||||||
|
|
||||||
if !o.local {
|
if !o.local {
|
||||||
|
|
|
@ -163,14 +163,12 @@ func (o *SetImageOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
includeUninitialized := cmdutil.ShouldIncludeUninitialized(cmd, false)
|
|
||||||
builder := f.NewBuilder().
|
builder := f.NewBuilder().
|
||||||
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
|
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
|
||||||
LocalParam(o.Local).
|
LocalParam(o.Local).
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
NamespaceParam(cmdNamespace).DefaultNamespace().
|
NamespaceParam(cmdNamespace).DefaultNamespace().
|
||||||
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
||||||
IncludeUninitialized(includeUninitialized).
|
|
||||||
Flatten()
|
Flatten()
|
||||||
|
|
||||||
if !o.Local {
|
if !o.Local {
|
||||||
|
|
|
@ -167,14 +167,12 @@ func (o *SetResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
includeUninitialized := cmdutil.ShouldIncludeUninitialized(cmd, false)
|
|
||||||
builder := f.NewBuilder().
|
builder := f.NewBuilder().
|
||||||
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
|
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
|
||||||
LocalParam(o.Local).
|
LocalParam(o.Local).
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
NamespaceParam(cmdNamespace).DefaultNamespace().
|
NamespaceParam(cmdNamespace).DefaultNamespace().
|
||||||
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
||||||
IncludeUninitialized(includeUninitialized).
|
|
||||||
Flatten()
|
Flatten()
|
||||||
|
|
||||||
if !o.Local {
|
if !o.Local {
|
||||||
|
|
|
@ -80,7 +80,6 @@ func NewSelectorOptions(streams genericclioptions.IOStreams) *SetSelectorOptions
|
||||||
WithScheme(scheme.Scheme).
|
WithScheme(scheme.Scheme).
|
||||||
WithAll(false).
|
WithAll(false).
|
||||||
WithLocal(false).
|
WithLocal(false).
|
||||||
WithUninitialized(false).
|
|
||||||
WithLatest(),
|
WithLatest(),
|
||||||
PrintFlags: genericclioptions.NewPrintFlags("selector updated").WithTypeSetter(scheme.Scheme),
|
PrintFlags: genericclioptions.NewPrintFlags("selector updated").WithTypeSetter(scheme.Scheme),
|
||||||
RecordFlags: genericclioptions.NewRecordFlags(),
|
RecordFlags: genericclioptions.NewRecordFlags(),
|
||||||
|
|
|
@ -151,14 +151,12 @@ func (o *SetServiceAccountOptions) Complete(f cmdutil.Factory, cmd *cobra.Comman
|
||||||
}
|
}
|
||||||
o.serviceAccountName = args[len(args)-1]
|
o.serviceAccountName = args[len(args)-1]
|
||||||
resources := args[:len(args)-1]
|
resources := args[:len(args)-1]
|
||||||
includeUninitialized := cmdutil.ShouldIncludeUninitialized(cmd, false)
|
|
||||||
builder := f.NewBuilder().
|
builder := f.NewBuilder().
|
||||||
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
|
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
|
||||||
LocalParam(o.local).
|
LocalParam(o.local).
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
NamespaceParam(cmdNamespace).DefaultNamespace().
|
NamespaceParam(cmdNamespace).DefaultNamespace().
|
||||||
FilenameParam(enforceNamespace, &o.fileNameOptions).
|
FilenameParam(enforceNamespace, &o.fileNameOptions).
|
||||||
IncludeUninitialized(includeUninitialized).
|
|
||||||
Flatten()
|
Flatten()
|
||||||
if !o.local {
|
if !o.local {
|
||||||
builder.ResourceTypeOrNameArgs(o.all, resources...).
|
builder.ResourceTypeOrNameArgs(o.all, resources...).
|
||||||
|
|
|
@ -138,14 +138,12 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
includeUninitialized := cmdutil.ShouldIncludeUninitialized(cmd, false)
|
|
||||||
builder := f.NewBuilder().
|
builder := f.NewBuilder().
|
||||||
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
|
WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
|
||||||
LocalParam(o.Local).
|
LocalParam(o.Local).
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
NamespaceParam(o.namespace).DefaultNamespace().
|
NamespaceParam(o.namespace).DefaultNamespace().
|
||||||
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
||||||
IncludeUninitialized(includeUninitialized).
|
|
||||||
Flatten()
|
Flatten()
|
||||||
|
|
||||||
if o.Local {
|
if o.Local {
|
||||||
|
|
|
@ -177,10 +177,8 @@ func (o *EditOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Comm
|
||||||
// when do normal edit or apply edit we need to always retrieve the latest resource from server
|
// when do normal edit or apply edit we need to always retrieve the latest resource from server
|
||||||
b = b.ResourceTypeOrNameArgs(true, args...).Latest()
|
b = b.ResourceTypeOrNameArgs(true, args...).Latest()
|
||||||
}
|
}
|
||||||
includeUninitialized := cmdutil.ShouldIncludeUninitialized(cmd, false)
|
|
||||||
r := b.NamespaceParam(cmdNamespace).DefaultNamespace().
|
r := b.NamespaceParam(cmdNamespace).DefaultNamespace().
|
||||||
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
FilenameParam(enforceNamespace, &o.FilenameOptions).
|
||||||
IncludeUninitialized(includeUninitialized).
|
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
Flatten().
|
Flatten().
|
||||||
Do()
|
Do()
|
||||||
|
@ -195,7 +193,6 @@ func (o *EditOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Comm
|
||||||
return f.NewBuilder().
|
return f.NewBuilder().
|
||||||
Unstructured().
|
Unstructured().
|
||||||
Stream(bytes.NewReader(data), "edited-file").
|
Stream(bytes.NewReader(data), "edited-file").
|
||||||
IncludeUninitialized(includeUninitialized).
|
|
||||||
ContinueOnError().
|
ContinueOnError().
|
||||||
Flatten().
|
Flatten().
|
||||||
Do()
|
Do()
|
||||||
|
|
|
@ -48,9 +48,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ApplyAnnotationsFlag = "save-config"
|
ApplyAnnotationsFlag = "save-config"
|
||||||
DefaultErrorExitCode = 1
|
DefaultErrorExitCode = 1
|
||||||
IncludeUninitializedFlag = "include-uninitialized"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type debugError interface {
|
type debugError interface {
|
||||||
|
@ -402,7 +401,8 @@ func AddDryRunFlag(cmd *cobra.Command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddIncludeUninitializedFlag(cmd *cobra.Command) {
|
func AddIncludeUninitializedFlag(cmd *cobra.Command) {
|
||||||
cmd.Flags().Bool(IncludeUninitializedFlag, false, `If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.`)
|
cmd.Flags().Bool("include-uninitialized", false, `If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.`)
|
||||||
|
cmd.Flags().MarkDeprecated("include-uninitialized", "The Initializers feature has been removed. This flag is now a no-op, and will be removed in v1.15")
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddPodRunningTimeoutFlag(cmd *cobra.Command, defaultTimeout time.Duration) {
|
func AddPodRunningTimeoutFlag(cmd *cobra.Command, defaultTimeout time.Duration) {
|
||||||
|
@ -594,28 +594,6 @@ func ManualStrip(file []byte) []byte {
|
||||||
return stripped
|
return stripped
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShouldIncludeUninitialized identifies whether to include uninitialized objects.
|
|
||||||
// includeUninitialized is the default value.
|
|
||||||
// Assume we can parse `all` and `selector` from cmd.
|
|
||||||
func ShouldIncludeUninitialized(cmd *cobra.Command, includeUninitialized bool) bool {
|
|
||||||
shouldIncludeUninitialized := includeUninitialized
|
|
||||||
if cmd.Flags().Lookup("all") != nil && GetFlagBool(cmd, "all") {
|
|
||||||
// include the uninitialized objects by default
|
|
||||||
// unless explicitly set --include-uninitialized=false
|
|
||||||
shouldIncludeUninitialized = true
|
|
||||||
}
|
|
||||||
if cmd.Flags().Lookup("selector") != nil && GetFlagString(cmd, "selector") != "" {
|
|
||||||
// does not include the uninitialized objects by default
|
|
||||||
// unless explicitly set --include-uninitialized=true
|
|
||||||
shouldIncludeUninitialized = false
|
|
||||||
}
|
|
||||||
if cmd.Flags().Changed(IncludeUninitializedFlag) {
|
|
||||||
// get explicit value
|
|
||||||
shouldIncludeUninitialized = GetFlagBool(cmd, IncludeUninitializedFlag)
|
|
||||||
}
|
|
||||||
return shouldIncludeUninitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
// ScaleClientFunc provides a ScalesGetter
|
// ScaleClientFunc provides a ScalesGetter
|
||||||
type ScaleClientFunc func(genericclioptions.RESTClientGetter) (scale.ScalesGetter, error)
|
type ScaleClientFunc func(genericclioptions.RESTClientGetter) (scale.ScalesGetter, error)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ go_library(
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/api/admission/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/admission/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
||||||
|
|
|
@ -18,7 +18,6 @@ package scheme
|
||||||
|
|
||||||
import (
|
import (
|
||||||
admissionv1alpha1 "k8s.io/api/admission/v1beta1"
|
admissionv1alpha1 "k8s.io/api/admission/v1beta1"
|
||||||
admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
|
|
||||||
admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1"
|
admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
||||||
|
@ -61,7 +60,7 @@ func init() {
|
||||||
|
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(corev1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(corev1.SchemeGroupVersion))
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(admissionv1alpha1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(admissionv1alpha1.SchemeGroupVersion))
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(admissionregistrationv1beta1.SchemeGroupVersion, admissionregistrationv1alpha1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(admissionregistrationv1beta1.SchemeGroupVersion))
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(appsv1beta1.SchemeGroupVersion, appsv1beta2.SchemeGroupVersion, appsv1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(appsv1beta1.SchemeGroupVersion, appsv1beta2.SchemeGroupVersion, appsv1.SchemeGroupVersion))
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(authenticationv1.SchemeGroupVersion, authenticationv1beta1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(authenticationv1.SchemeGroupVersion, authenticationv1beta1.SchemeGroupVersion))
|
||||||
utilruntime.Must(Scheme.SetVersionPriority(authorizationv1.SchemeGroupVersion, authorizationv1beta1.SchemeGroupVersion))
|
utilruntime.Must(Scheme.SetVersionPriority(authorizationv1.SchemeGroupVersion, authorizationv1beta1.SchemeGroupVersion))
|
||||||
|
|
|
@ -66,7 +66,6 @@ go_library(
|
||||||
"//pkg/serviceaccount:go_default_library",
|
"//pkg/serviceaccount:go_default_library",
|
||||||
"//pkg/util/async:go_default_library",
|
"//pkg/util/async:go_default_library",
|
||||||
"//pkg/util/node:go_default_library",
|
"//pkg/util/node:go_default_library",
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
|
|
||||||
admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1"
|
admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
||||||
|
@ -518,7 +517,6 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
|
||||||
// disable alpha versions explicitly so we have a full list of what's possible to serve
|
// disable alpha versions explicitly so we have a full list of what's possible to serve
|
||||||
ret.DisableVersions(
|
ret.DisableVersions(
|
||||||
auditregistrationv1alpha1.SchemeGroupVersion,
|
auditregistrationv1alpha1.SchemeGroupVersion,
|
||||||
admissionregistrationv1alpha1.SchemeGroupVersion,
|
|
||||||
batchapiv2alpha1.SchemeGroupVersion,
|
batchapiv2alpha1.SchemeGroupVersion,
|
||||||
rbacv1alpha1.SchemeGroupVersion,
|
rbacv1alpha1.SchemeGroupVersion,
|
||||||
schedulingv1alpha1.SchemeGroupVersion,
|
schedulingv1alpha1.SchemeGroupVersion,
|
||||||
|
|
|
@ -22,7 +22,6 @@ go_library(
|
||||||
"//pkg/apis/core/v1/helper:go_default_library",
|
"//pkg/apis/core/v1/helper:go_default_library",
|
||||||
"//pkg/apis/core/v1/helper/qos:go_default_library",
|
"//pkg/apis/core/v1/helper/qos:go_default_library",
|
||||||
"//pkg/features:go_default_library",
|
"//pkg/features:go_default_library",
|
||||||
"//pkg/kubeapiserver/admission/util:go_default_library",
|
|
||||||
"//pkg/quota/v1:go_default_library",
|
"//pkg/quota/v1:go_default_library",
|
||||||
"//pkg/quota/v1/generic:go_default_library",
|
"//pkg/quota/v1/generic:go_default_library",
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
|
@ -31,11 +30,8 @@ go_library(
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/initialization:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/features:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,16 +24,12 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/initialization"
|
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
|
||||||
"k8s.io/apiserver/pkg/admission"
|
"k8s.io/apiserver/pkg/admission"
|
||||||
"k8s.io/apiserver/pkg/features"
|
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
|
k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
|
||||||
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
|
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
|
||||||
k8sfeatures "k8s.io/kubernetes/pkg/features"
|
k8sfeatures "k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/kubeapiserver/admission/util"
|
|
||||||
quota "k8s.io/kubernetes/pkg/quota/v1"
|
quota "k8s.io/kubernetes/pkg/quota/v1"
|
||||||
"k8s.io/kubernetes/pkg/quota/v1/generic"
|
"k8s.io/kubernetes/pkg/quota/v1/generic"
|
||||||
)
|
)
|
||||||
|
@ -99,25 +95,9 @@ func (p *pvcEvaluator) Handles(a admission.Attributes) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if op == admission.Update && utilfeature.DefaultFeatureGate.Enabled(k8sfeatures.ExpandPersistentVolumes) {
|
if op == admission.Update && utilfeature.DefaultFeatureGate.Enabled(k8sfeatures.ExpandPersistentVolumes) {
|
||||||
initialized, err := initialization.IsObjectInitialized(a.GetObject())
|
|
||||||
if err != nil {
|
|
||||||
// fail closed, will try to give an evaluation.
|
|
||||||
utilruntime.HandleError(err)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
// only handle the update if the object is initialized after the update.
|
|
||||||
return initialized
|
|
||||||
}
|
|
||||||
// TODO: when the ExpandPersistentVolumes feature gate is removed, remove
|
|
||||||
// the initializationCompletion check as well, because it will become a
|
|
||||||
// subset of the "initialized" condition.
|
|
||||||
initializationCompletion, err := util.IsInitializationCompletion(a)
|
|
||||||
if err != nil {
|
|
||||||
// fail closed, will try to give an evaluation.
|
|
||||||
utilruntime.HandleError(err)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return initializationCompletion
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Matches returns true if the evaluator matches the specified quota with the provided input item
|
// Matches returns true if the evaluator matches the specified quota with the provided input item
|
||||||
|
@ -173,12 +153,6 @@ func (p *pvcEvaluator) Usage(item runtime.Object) (corev1.ResourceList, error) {
|
||||||
// charge for claim
|
// charge for claim
|
||||||
result[corev1.ResourcePersistentVolumeClaims] = *(resource.NewQuantity(1, resource.DecimalSI))
|
result[corev1.ResourcePersistentVolumeClaims] = *(resource.NewQuantity(1, resource.DecimalSI))
|
||||||
result[pvcObjectCountName] = *(resource.NewQuantity(1, resource.DecimalSI))
|
result[pvcObjectCountName] = *(resource.NewQuantity(1, resource.DecimalSI))
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.Initializers) {
|
|
||||||
if !initialization.IsInitialized(pvc.Initializers) {
|
|
||||||
// Only charge pvc count for uninitialized pvc.
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
storageClassRef := helper.GetPersistentVolumeClaimClass(pvc)
|
storageClassRef := helper.GetPersistentVolumeClaimClass(pvc)
|
||||||
if len(storageClassRef) > 0 {
|
if len(storageClassRef) > 0 {
|
||||||
storageClassClaim := corev1.ResourceName(storageClassRef + storageClassSuffix + string(corev1.ResourcePersistentVolumeClaims))
|
storageClassClaim := corev1.ResourceName(storageClassRef + storageClassSuffix + string(corev1.ResourcePersistentVolumeClaims))
|
||||||
|
|
|
@ -28,14 +28,12 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/clock"
|
"k8s.io/apimachinery/pkg/util/clock"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apiserver/pkg/admission"
|
"k8s.io/apiserver/pkg/admission"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
|
k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
|
||||||
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
|
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
|
||||||
"k8s.io/kubernetes/pkg/apis/core/v1/helper/qos"
|
"k8s.io/kubernetes/pkg/apis/core/v1/helper/qos"
|
||||||
"k8s.io/kubernetes/pkg/kubeapiserver/admission/util"
|
|
||||||
quota "k8s.io/kubernetes/pkg/quota/v1"
|
quota "k8s.io/kubernetes/pkg/quota/v1"
|
||||||
"k8s.io/kubernetes/pkg/quota/v1/generic"
|
"k8s.io/kubernetes/pkg/quota/v1/generic"
|
||||||
)
|
)
|
||||||
|
@ -150,14 +148,7 @@ func (p *podEvaluator) Handles(a admission.Attributes) bool {
|
||||||
if op == admission.Create {
|
if op == admission.Create {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
initializationCompletion, err := util.IsInitializationCompletion(a)
|
return false
|
||||||
if err != nil {
|
|
||||||
// fail closed, will try to give an evaluation.
|
|
||||||
utilruntime.HandleError(err)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
// only uninitialized pods might be updated.
|
|
||||||
return initializationCompletion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Matches returns true if the evaluator matches the specified quota with the provided input item
|
// Matches returns true if the evaluator matches the specified quota with the provided input item
|
||||||
|
|
|
@ -22,7 +22,6 @@ filegroup(
|
||||||
name = "all-srcs",
|
name = "all-srcs",
|
||||||
srcs = [
|
srcs = [
|
||||||
":package-srcs",
|
":package-srcs",
|
||||||
"//pkg/registry/admissionregistration/initializerconfiguration:all-srcs",
|
|
||||||
"//pkg/registry/admissionregistration/mutatingwebhookconfiguration:all-srcs",
|
"//pkg/registry/admissionregistration/mutatingwebhookconfiguration:all-srcs",
|
||||||
"//pkg/registry/admissionregistration/rest:all-srcs",
|
"//pkg/registry/admissionregistration/rest:all-srcs",
|
||||||
"//pkg/registry/admissionregistration/validatingwebhookconfiguration:all-srcs",
|
"//pkg/registry/admissionregistration/validatingwebhookconfiguration:all-srcs",
|
||||||
|
|
|
@ -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/admissionregistration/initializerconfiguration",
|
|
||||||
deps = [
|
|
||||||
"//pkg/api/legacyscheme:go_default_library",
|
|
||||||
"//pkg/apis/admissionregistration:go_default_library",
|
|
||||||
"//pkg/apis/admissionregistration/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/admissionregistration/initializerconfiguration/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 initializerconfiguration // import "k8s.io/kubernetes/pkg/registry/admissionregistration/initializerconfiguration"
|
|
|
@ -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 = ["storage.go"],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/registry/admissionregistration/initializerconfiguration/storage",
|
|
||||||
deps = [
|
|
||||||
"//pkg/apis/admissionregistration:go_default_library",
|
|
||||||
"//pkg/registry/admissionregistration/initializerconfiguration: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"],
|
|
||||||
)
|
|
|
@ -1,51 +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"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
|
||||||
"k8s.io/kubernetes/pkg/registry/admissionregistration/initializerconfiguration"
|
|
||||||
)
|
|
||||||
|
|
||||||
// rest implements a RESTStorage for pod disruption budgets against etcd
|
|
||||||
type REST struct {
|
|
||||||
*genericregistry.Store
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against pod disruption budgets.
|
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
|
|
||||||
store := &genericregistry.Store{
|
|
||||||
NewFunc: func() runtime.Object { return &admissionregistration.InitializerConfiguration{} },
|
|
||||||
NewListFunc: func() runtime.Object { return &admissionregistration.InitializerConfigurationList{} },
|
|
||||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
|
||||||
return obj.(*admissionregistration.InitializerConfiguration).Name, nil
|
|
||||||
},
|
|
||||||
DefaultQualifiedResource: admissionregistration.Resource("initializerconfigurations"),
|
|
||||||
|
|
||||||
CreateStrategy: initializerconfiguration.Strategy,
|
|
||||||
UpdateStrategy: initializerconfiguration.Strategy,
|
|
||||||
DeleteStrategy: initializerconfiguration.Strategy,
|
|
||||||
}
|
|
||||||
options := &generic.StoreOptions{RESTOptions: optsGetter}
|
|
||||||
if err := store.CompleteWithOptions(options); err != nil {
|
|
||||||
panic(err) // TODO: Propagate error up
|
|
||||||
}
|
|
||||||
return &REST{store}
|
|
||||||
}
|
|
|
@ -1,90 +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 initializerconfiguration
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"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/admissionregistration"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration/validation"
|
|
||||||
)
|
|
||||||
|
|
||||||
// initializerConfigurationStrategy implements verification logic for InitializerConfigurations.
|
|
||||||
type initializerConfigurationStrategy struct {
|
|
||||||
runtime.ObjectTyper
|
|
||||||
names.NameGenerator
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strategy is the default logic that applies when creating and updating InitializerConfiguration objects.
|
|
||||||
var Strategy = initializerConfigurationStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
|
|
||||||
|
|
||||||
// NamespaceScoped returns true because all InitializerConfiguration' need to be within a namespace.
|
|
||||||
func (initializerConfigurationStrategy) NamespaceScoped() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// PrepareForCreate clears the status of an InitializerConfiguration before creation.
|
|
||||||
func (initializerConfigurationStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
|
||||||
ic := obj.(*admissionregistration.InitializerConfiguration)
|
|
||||||
ic.Generation = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
|
||||||
func (initializerConfigurationStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
|
||||||
newIC := obj.(*admissionregistration.InitializerConfiguration)
|
|
||||||
oldIC := old.(*admissionregistration.InitializerConfiguration)
|
|
||||||
|
|
||||||
// Any changes to the spec increment the generation number, any changes to the
|
|
||||||
// status should reflect the generation number of the corresponding object.
|
|
||||||
// See metav1.ObjectMeta description for more information on Generation.
|
|
||||||
if !reflect.DeepEqual(oldIC.Initializers, newIC.Initializers) {
|
|
||||||
newIC.Generation = oldIC.Generation + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate validates a new InitializerConfiguration.
|
|
||||||
func (initializerConfigurationStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
|
||||||
ic := obj.(*admissionregistration.InitializerConfiguration)
|
|
||||||
return validation.ValidateInitializerConfiguration(ic)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Canonicalize normalizes the object after validation.
|
|
||||||
func (initializerConfigurationStrategy) Canonicalize(obj runtime.Object) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllowCreateOnUpdate is true for InitializerConfiguration; this means you may create one with a PUT request.
|
|
||||||
func (initializerConfigurationStrategy) AllowCreateOnUpdate() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidateUpdate is the default update validation for an end user.
|
|
||||||
func (initializerConfigurationStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
|
||||||
validationErrorList := validation.ValidateInitializerConfiguration(obj.(*admissionregistration.InitializerConfiguration))
|
|
||||||
updateErrorList := validation.ValidateInitializerConfigurationUpdate(obj.(*admissionregistration.InitializerConfiguration), old.(*admissionregistration.InitializerConfiguration))
|
|
||||||
return append(validationErrorList, updateErrorList...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllowUnconditionalUpdate is the default update policy for InitializerConfiguration objects. Status update should
|
|
||||||
// only be allowed if version match.
|
|
||||||
func (initializerConfigurationStrategy) AllowUnconditionalUpdate() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
|
@ -12,10 +12,8 @@ go_library(
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/api/legacyscheme:go_default_library",
|
"//pkg/api/legacyscheme:go_default_library",
|
||||||
"//pkg/apis/admissionregistration:go_default_library",
|
"//pkg/apis/admissionregistration:go_default_library",
|
||||||
"//pkg/registry/admissionregistration/initializerconfiguration/storage:go_default_library",
|
|
||||||
"//pkg/registry/admissionregistration/mutatingwebhookconfiguration/storage:go_default_library",
|
"//pkg/registry/admissionregistration/mutatingwebhookconfiguration/storage:go_default_library",
|
||||||
"//pkg/registry/admissionregistration/validatingwebhookconfiguration/storage:go_default_library",
|
"//pkg/registry/admissionregistration/validatingwebhookconfiguration/storage:go_default_library",
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic: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/registry/rest:go_default_library",
|
||||||
|
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
||||||
package rest
|
package rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
|
|
||||||
admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1"
|
admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
|
@ -25,7 +24,6 @@ import (
|
||||||
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
serverstorage "k8s.io/apiserver/pkg/server/storage"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
||||||
initializerconfigurationstorage "k8s.io/kubernetes/pkg/registry/admissionregistration/initializerconfiguration/storage"
|
|
||||||
mutatingwebhookconfigurationstorage "k8s.io/kubernetes/pkg/registry/admissionregistration/mutatingwebhookconfiguration/storage"
|
mutatingwebhookconfigurationstorage "k8s.io/kubernetes/pkg/registry/admissionregistration/mutatingwebhookconfiguration/storage"
|
||||||
validatingwebhookconfigurationstorage "k8s.io/kubernetes/pkg/registry/admissionregistration/validatingwebhookconfiguration/storage"
|
validatingwebhookconfigurationstorage "k8s.io/kubernetes/pkg/registry/admissionregistration/validatingwebhookconfiguration/storage"
|
||||||
)
|
)
|
||||||
|
@ -37,24 +35,12 @@ func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource serverstorag
|
||||||
// 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.
|
// 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
|
// TODO refactor the plumbing to provide the information in the APIGroupInfo
|
||||||
|
|
||||||
if apiResourceConfigSource.VersionEnabled(admissionregistrationv1alpha1.SchemeGroupVersion) {
|
|
||||||
apiGroupInfo.VersionedResourcesStorageMap[admissionregistrationv1alpha1.SchemeGroupVersion.Version] = p.v1alpha1Storage(apiResourceConfigSource, restOptionsGetter)
|
|
||||||
}
|
|
||||||
if apiResourceConfigSource.VersionEnabled(admissionregistrationv1beta1.SchemeGroupVersion) {
|
if apiResourceConfigSource.VersionEnabled(admissionregistrationv1beta1.SchemeGroupVersion) {
|
||||||
apiGroupInfo.VersionedResourcesStorageMap[admissionregistrationv1beta1.SchemeGroupVersion.Version] = p.v1beta1Storage(apiResourceConfigSource, restOptionsGetter)
|
apiGroupInfo.VersionedResourcesStorageMap[admissionregistrationv1beta1.SchemeGroupVersion.Version] = p.v1beta1Storage(apiResourceConfigSource, restOptionsGetter)
|
||||||
}
|
}
|
||||||
return apiGroupInfo, true
|
return apiGroupInfo, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p RESTStorageProvider) v1alpha1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) map[string]rest.Storage {
|
|
||||||
storage := map[string]rest.Storage{}
|
|
||||||
// initializerconfigurations
|
|
||||||
s := initializerconfigurationstorage.NewREST(restOptionsGetter)
|
|
||||||
storage["initializerconfigurations"] = s
|
|
||||||
|
|
||||||
return storage
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) map[string]rest.Storage {
|
func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) map[string]rest.Storage {
|
||||||
storage := map[string]rest.Storage{}
|
storage := map[string]rest.Storage{}
|
||||||
// validatingwebhookconfigurations
|
// validatingwebhookconfigurations
|
||||||
|
|
|
@ -160,12 +160,12 @@ func ReplicaSetToSelectableFields(rs *apps.ReplicaSet) fields.Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
rs, ok := obj.(*apps.ReplicaSet)
|
rs, ok := obj.(*apps.ReplicaSet)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("given object is not a ReplicaSet.")
|
return nil, nil, fmt.Errorf("given object is not a ReplicaSet.")
|
||||||
}
|
}
|
||||||
return labels.Set(rs.ObjectMeta.Labels), ReplicaSetToSelectableFields(rs), rs.Initializers != nil, nil
|
return labels.Set(rs.ObjectMeta.Labels), ReplicaSetToSelectableFields(rs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchReplicaSet is the filter used by the generic etcd backend to route
|
// MatchReplicaSet is the filter used by the generic etcd backend to route
|
||||||
|
|
|
@ -202,12 +202,12 @@ func JobToSelectableFields(job *batch.Job) fields.Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
job, ok := obj.(*batch.Job)
|
job, ok := obj.(*batch.Job)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("given object is not a job.")
|
return nil, nil, fmt.Errorf("given object is not a job.")
|
||||||
}
|
}
|
||||||
return labels.Set(job.ObjectMeta.Labels), JobToSelectableFields(job), job.Initializers != nil, nil
|
return labels.Set(job.ObjectMeta.Labels), JobToSelectableFields(job), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchJob is the filter used by the generic etcd backend to route
|
// MatchJob is the filter used by the generic etcd backend to route
|
||||||
|
|
|
@ -79,12 +79,12 @@ func (eventStrategy) AllowUnconditionalUpdate() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
event, ok := obj.(*api.Event)
|
event, ok := obj.(*api.Event)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("not an event")
|
return nil, nil, fmt.Errorf("not an event")
|
||||||
}
|
}
|
||||||
return labels.Set(event.Labels), EventToSelectableFields(event), event.Initializers != nil, nil
|
return labels.Set(event.Labels), EventToSelectableFields(event), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func MatchEvent(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
|
func MatchEvent(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
|
||||||
|
|
|
@ -139,12 +139,12 @@ func (namespaceFinalizeStrategy) PrepareForUpdate(ctx context.Context, obj, old
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
namespaceObj, ok := obj.(*api.Namespace)
|
namespaceObj, ok := obj.(*api.Namespace)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("not a namespace")
|
return nil, nil, fmt.Errorf("not a namespace")
|
||||||
}
|
}
|
||||||
return labels.Set(namespaceObj.Labels), NamespaceToSelectableFields(namespaceObj), namespaceObj.Initializers != nil, nil
|
return labels.Set(namespaceObj.Labels), NamespaceToSelectableFields(namespaceObj), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchNamespace returns a generic matcher for a given label and field selector.
|
// MatchNamespace returns a generic matcher for a given label and field selector.
|
||||||
|
|
|
@ -181,12 +181,12 @@ func NodeToSelectableFields(node *api.Node) fields.Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
nodeObj, ok := obj.(*api.Node)
|
nodeObj, ok := obj.(*api.Node)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("not a node")
|
return nil, nil, fmt.Errorf("not a node")
|
||||||
}
|
}
|
||||||
return labels.Set(nodeObj.ObjectMeta.Labels), NodeToSelectableFields(nodeObj), nodeObj.Initializers != nil, nil
|
return labels.Set(nodeObj.ObjectMeta.Labels), NodeToSelectableFields(nodeObj), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchNode returns a generic matcher for a given label and field selector.
|
// MatchNode returns a generic matcher for a given label and field selector.
|
||||||
|
|
|
@ -108,12 +108,12 @@ func (persistentvolumeStatusStrategy) ValidateUpdate(ctx context.Context, obj, o
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
persistentvolumeObj, ok := obj.(*api.PersistentVolume)
|
persistentvolumeObj, ok := obj.(*api.PersistentVolume)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("not a persistentvolume")
|
return nil, nil, fmt.Errorf("not a persistentvolume")
|
||||||
}
|
}
|
||||||
return labels.Set(persistentvolumeObj.Labels), PersistentVolumeToSelectableFields(persistentvolumeObj), persistentvolumeObj.Initializers != nil, nil
|
return labels.Set(persistentvolumeObj.Labels), PersistentVolumeToSelectableFields(persistentvolumeObj), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchPersistentVolume returns a generic matcher for a given label and field selector.
|
// MatchPersistentVolume returns a generic matcher for a given label and field selector.
|
||||||
|
|
|
@ -109,12 +109,12 @@ func (persistentvolumeclaimStatusStrategy) ValidateUpdate(ctx context.Context, o
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
persistentvolumeclaimObj, ok := obj.(*api.PersistentVolumeClaim)
|
persistentvolumeclaimObj, ok := obj.(*api.PersistentVolumeClaim)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("not a persistentvolumeclaim")
|
return nil, nil, fmt.Errorf("not a persistentvolumeclaim")
|
||||||
}
|
}
|
||||||
return labels.Set(persistentvolumeclaimObj.Labels), PersistentVolumeClaimToSelectableFields(persistentvolumeclaimObj), persistentvolumeclaimObj.Initializers != nil, nil
|
return labels.Set(persistentvolumeclaimObj.Labels), PersistentVolumeClaimToSelectableFields(persistentvolumeclaimObj), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchPersistentVolumeClaim returns a generic matcher for a given label and field selector.
|
// MatchPersistentVolumeClaim returns a generic matcher for a given label and field selector.
|
||||||
|
|
|
@ -22,20 +22,16 @@ go_library(
|
||||||
"//pkg/kubelet/client:go_default_library",
|
"//pkg/kubelet/client:go_default_library",
|
||||||
"//pkg/proxy/util:go_default_library",
|
"//pkg/proxy/util:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/validation:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/fields: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/labels:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/features:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/storage:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/storage:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ go_test(
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/features:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic: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",
|
"//staging/src/k8s.io/apiserver/pkg/registry/generic/registry:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/registry/generic/testing:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/registry/generic/testing:go_default_library",
|
||||||
|
@ -32,8 +31,6 @@ go_test(
|
||||||
"//staging/src/k8s.io/apiserver/pkg/storage:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/storage:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/storage/errors:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/storage/errors:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/storage/etcd/testing:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/storage/etcd/testing:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apiserver/pkg/util/feature/testing:go_default_library",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
"k8s.io/apimachinery/pkg/util/diff"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/features"
|
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
|
@ -40,8 +39,6 @@ import (
|
||||||
"k8s.io/apiserver/pkg/storage"
|
"k8s.io/apiserver/pkg/storage"
|
||||||
storeerr "k8s.io/apiserver/pkg/storage/errors"
|
storeerr "k8s.io/apiserver/pkg/storage/errors"
|
||||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
utilfeaturetesting "k8s.io/apiserver/pkg/util/feature/testing"
|
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
"k8s.io/kubernetes/pkg/securitycontext"
|
"k8s.io/kubernetes/pkg/securitycontext"
|
||||||
|
@ -729,76 +726,6 @@ func TestEtcdCreateBinding(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEtcdUpdateUninitialized(t *testing.T) {
|
|
||||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.Initializers, true)()
|
|
||||||
storage, _, _, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
ctx := genericapirequest.NewDefaultContext()
|
|
||||||
|
|
||||||
pod := validNewPod()
|
|
||||||
// add pending initializers to the pod
|
|
||||||
pod.ObjectMeta.Initializers = &metav1.Initializers{Pending: []metav1.Initializer{{Name: "init.k8s.io"}}}
|
|
||||||
if _, err := storage.Create(ctx, pod, rest.ValidateAllObjectFunc, &metav1.CreateOptions{IncludeUninitialized: true}); err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
podIn := *pod
|
|
||||||
// only uninitialized pod is allowed to add containers via update
|
|
||||||
podIn.Spec.Containers = append(podIn.Spec.Containers, api.Container{
|
|
||||||
Name: "foo2",
|
|
||||||
Image: "test",
|
|
||||||
ImagePullPolicy: api.PullAlways,
|
|
||||||
TerminationMessagePath: api.TerminationMessagePathDefault,
|
|
||||||
TerminationMessagePolicy: api.TerminationMessageReadFile,
|
|
||||||
SecurityContext: securitycontext.ValidInternalSecurityContextWithContainerDefaults(),
|
|
||||||
})
|
|
||||||
podIn.ObjectMeta.Initializers = nil
|
|
||||||
|
|
||||||
_, _, err := storage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc, false, &metav1.UpdateOptions{})
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
obj, err := storage.Get(ctx, podIn.ObjectMeta.Name, &metav1.GetOptions{})
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
podOut := obj.(*api.Pod)
|
|
||||||
if podOut.GetInitializers() != nil {
|
|
||||||
t.Errorf("expect nil initializers, got %v", podOut.ObjectMeta.Initializers)
|
|
||||||
}
|
|
||||||
if !apiequality.Semantic.DeepEqual(podIn.Spec.Containers, podOut.Spec.Containers) {
|
|
||||||
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, &podIn))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEtcdStatusUpdateUninitialized(t *testing.T) {
|
|
||||||
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.Initializers, true)()
|
|
||||||
storage, _, statusStorage, server := newStorage(t)
|
|
||||||
defer server.Terminate(t)
|
|
||||||
defer storage.Store.DestroyFunc()
|
|
||||||
ctx := genericapirequest.NewDefaultContext()
|
|
||||||
|
|
||||||
pod := validNewPod()
|
|
||||||
// add pending initializers to the pod
|
|
||||||
pod.ObjectMeta.Initializers = &metav1.Initializers{Pending: []metav1.Initializer{{Name: "init.k8s.io"}}}
|
|
||||||
if _, err := storage.Create(ctx, pod, rest.ValidateAllObjectFunc, &metav1.CreateOptions{IncludeUninitialized: true}); err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
podIn := *pod
|
|
||||||
// only uninitialized pod is allowed to add containers via update
|
|
||||||
podIn.Status.Phase = api.PodRunning
|
|
||||||
podIn.ObjectMeta.Initializers = nil
|
|
||||||
|
|
||||||
_, _, err := statusStorage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc, false, &metav1.UpdateOptions{})
|
|
||||||
expected := "Forbidden: must not update status when the object is uninitialized"
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Unexpected no err, expected %q", expected)
|
|
||||||
}
|
|
||||||
if !strings.Contains(err.Error(), expected) {
|
|
||||||
t.Errorf("unexpected error: %v, expected %q", err, expected)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEtcdUpdateNotScheduled(t *testing.T) {
|
func TestEtcdUpdateNotScheduled(t *testing.T) {
|
||||||
storage, _, _, server := newStorage(t)
|
storage, _, _, server := newStorage(t)
|
||||||
defer server.Terminate(t)
|
defer server.Terminate(t)
|
||||||
|
|
|
@ -27,20 +27,16 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
apimachineryvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
utilnet "k8s.io/apimachinery/pkg/util/net"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
"k8s.io/apiserver/pkg/features"
|
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
"k8s.io/apiserver/pkg/storage"
|
"k8s.io/apiserver/pkg/storage"
|
||||||
"k8s.io/apiserver/pkg/storage/names"
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
podutil "k8s.io/kubernetes/pkg/api/pod"
|
podutil "k8s.io/kubernetes/pkg/api/pod"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
|
@ -100,31 +96,9 @@ func (podStrategy) AllowCreateOnUpdate() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isUpdatingUninitializedPod(old runtime.Object) (bool, error) {
|
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.Initializers) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
oldMeta, err := meta.Accessor(old)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
oldInitializers := oldMeta.GetInitializers()
|
|
||||||
if oldInitializers != nil && len(oldInitializers.Pending) != 0 {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (podStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (podStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
errorList := validation.ValidatePod(obj.(*api.Pod))
|
errorList := validation.ValidatePod(obj.(*api.Pod))
|
||||||
uninitializedUpdate, err := isUpdatingUninitializedPod(old)
|
|
||||||
if err != nil {
|
|
||||||
return append(errorList, field.InternalError(field.NewPath("metadata"), err))
|
|
||||||
}
|
|
||||||
if uninitializedUpdate {
|
|
||||||
return errorList
|
|
||||||
}
|
|
||||||
return append(errorList, validation.ValidatePodUpdate(obj.(*api.Pod), old.(*api.Pod))...)
|
return append(errorList, validation.ValidatePodUpdate(obj.(*api.Pod), old.(*api.Pod))...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,25 +167,16 @@ func (podStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (podStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (podStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
var errorList field.ErrorList
|
|
||||||
uninitializedUpdate, err := isUpdatingUninitializedPod(old)
|
|
||||||
if err != nil {
|
|
||||||
return append(errorList, field.InternalError(field.NewPath("metadata"), err))
|
|
||||||
}
|
|
||||||
if uninitializedUpdate {
|
|
||||||
return append(errorList, field.Forbidden(field.NewPath("status"), apimachineryvalidation.UninitializedStatusUpdateErrorMsg))
|
|
||||||
}
|
|
||||||
// TODO: merge valid fields after update
|
|
||||||
return validation.ValidatePodStatusUpdate(obj.(*api.Pod), old.(*api.Pod))
|
return validation.ValidatePodStatusUpdate(obj.(*api.Pod), old.(*api.Pod))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
pod, ok := obj.(*api.Pod)
|
pod, ok := obj.(*api.Pod)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("not a pod")
|
return nil, nil, fmt.Errorf("not a pod")
|
||||||
}
|
}
|
||||||
return labels.Set(pod.ObjectMeta.Labels), PodToSelectableFields(pod), pod.Initializers != nil, nil
|
return labels.Set(pod.ObjectMeta.Labels), PodToSelectableFields(pod), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchPod returns a generic matcher for a given label and field selector.
|
// MatchPod returns a generic matcher for a given label and field selector.
|
||||||
|
|
|
@ -164,12 +164,12 @@ func ControllerToSelectableFields(controller *api.ReplicationController) fields.
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
rc, ok := obj.(*api.ReplicationController)
|
rc, ok := obj.(*api.ReplicationController)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("given object is not a replication controller.")
|
return nil, nil, fmt.Errorf("given object is not a replication controller.")
|
||||||
}
|
}
|
||||||
return labels.Set(rc.ObjectMeta.Labels), ControllerToSelectableFields(rc), rc.Initializers != nil, nil
|
return labels.Set(rc.ObjectMeta.Labels), ControllerToSelectableFields(rc), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchController is the filter used by the generic etcd backend to route
|
// MatchController is the filter used by the generic etcd backend to route
|
||||||
|
|
|
@ -98,12 +98,12 @@ func (s strategy) Export(ctx context.Context, obj runtime.Object, exact bool) er
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
secret, ok := obj.(*api.Secret)
|
secret, ok := obj.(*api.Secret)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("not a secret")
|
return nil, nil, fmt.Errorf("not a secret")
|
||||||
}
|
}
|
||||||
return labels.Set(secret.Labels), SelectableFields(secret), secret.Initializers != nil, nil
|
return labels.Set(secret.Labels), SelectableFields(secret), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Matcher returns a generic matcher for a given label and field selector.
|
// Matcher returns a generic matcher for a given label and field selector.
|
||||||
|
|
|
@ -85,12 +85,12 @@ func SelectableFields(pip *api.Event) fields.Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||||
pip, ok := obj.(*api.Event)
|
pip, ok := obj.(*api.Event)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("given object is not a Event")
|
return nil, nil, fmt.Errorf("given object is not a Event")
|
||||||
}
|
}
|
||||||
return labels.Set(pip.ObjectMeta.Labels), SelectableFields(pip), pip.Initializers != nil, nil
|
return labels.Set(pip.ObjectMeta.Labels), SelectableFields(pip), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Matcher is the filter used by the generic etcd backend to watch events
|
// Matcher is the filter used by the generic etcd backend to watch events
|
||||||
|
|
|
@ -12,7 +12,6 @@ go_library(
|
||||||
importpath = "k8s.io/kubernetes/plugin/pkg/admission/podnodeselector",
|
importpath = "k8s.io/kubernetes/plugin/pkg/admission/podnodeselector",
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/apis/core:go_default_library",
|
"//pkg/apis/core:go_default_library",
|
||||||
"//pkg/kubeapiserver/admission/util:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors: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/apis/meta/v1:go_default_library",
|
||||||
|
|
|
@ -34,7 +34,6 @@ import (
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
corev1listers "k8s.io/client-go/listers/core/v1"
|
corev1listers "k8s.io/client-go/listers/core/v1"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/kubeapiserver/admission/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// The annotation key scheduler.alpha.kubernetes.io/node-selector is for assigning
|
// The annotation key scheduler.alpha.kubernetes.io/node-selector is for assigning
|
||||||
|
@ -99,14 +98,6 @@ func (p *podNodeSelector) Admit(a admission.Attributes) error {
|
||||||
if shouldIgnore(a) {
|
if shouldIgnore(a) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
updateInitialized, err := util.IsUpdatingInitializedObject(a)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if updateInitialized {
|
|
||||||
// node selector of an initialized pod is immutable
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if !p.WaitForReady() {
|
if !p.WaitForReady() {
|
||||||
return admission.NewForbidden(a, fmt.Errorf("not yet ready to handle request"))
|
return admission.NewForbidden(a, fmt.Errorf("not yet ready to handle request"))
|
||||||
}
|
}
|
||||||
|
@ -199,7 +190,7 @@ func shouldIgnore(a admission.Attributes) bool {
|
||||||
|
|
||||||
func NewPodNodeSelector(clusterNodeSelectors map[string]string) *podNodeSelector {
|
func NewPodNodeSelector(clusterNodeSelectors map[string]string) *podNodeSelector {
|
||||||
return &podNodeSelector{
|
return &podNodeSelector{
|
||||||
Handler: admission.NewHandler(admission.Create, admission.Update),
|
Handler: admission.NewHandler(admission.Create),
|
||||||
clusterNodeSelectors: clusterNodeSelectors,
|
clusterNodeSelectors: clusterNodeSelectors,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,12 +53,6 @@ func TestPodAdmission(t *testing.T) {
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "testPod", Namespace: "testNamespace"},
|
ObjectMeta: metav1.ObjectMeta{Name: "testPod", Namespace: "testNamespace"},
|
||||||
}
|
}
|
||||||
|
|
||||||
oldPod := *pod
|
|
||||||
oldPod.Initializers = &metav1.Initializers{Pending: []metav1.Initializer{{Name: "init"}}}
|
|
||||||
oldPod.Spec.NodeSelector = map[string]string{
|
|
||||||
"old": "true",
|
|
||||||
}
|
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
defaultNodeSelector string
|
defaultNodeSelector string
|
||||||
namespaceNodeSelector string
|
namespaceNodeSelector string
|
||||||
|
@ -182,30 +176,13 @@ func TestPodAdmission(t *testing.T) {
|
||||||
} else if !test.admit && err == nil {
|
} else if !test.admit && err == nil {
|
||||||
t.Errorf("Test: %s, expected an error", test.testName)
|
t.Errorf("Test: %s, expected an error", test.testName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handles update of uninitialized pod like it's newly created.
|
|
||||||
err = handler.Admit(admission.NewAttributesRecord(pod, &oldPod, api.Kind("Pod").WithVersion("version"), "testNamespace", namespace.ObjectMeta.Name, api.Resource("pods").WithVersion("version"), "", admission.Update, false, nil))
|
|
||||||
if test.admit && err != nil {
|
|
||||||
t.Errorf("Test: %s, expected no error but got: %s", test.testName, err)
|
|
||||||
} else if !test.admit && err == nil {
|
|
||||||
t.Errorf("Test: %s, expected an error", test.testName)
|
|
||||||
}
|
|
||||||
if test.admit && !labels.Equals(test.mergedNodeSelector, labels.Set(pod.Spec.NodeSelector)) {
|
|
||||||
t.Errorf("Test: %s, expected: %s but got: %s", test.testName, test.mergedNodeSelector, pod.Spec.NodeSelector)
|
|
||||||
}
|
|
||||||
err = handler.Validate(admission.NewAttributesRecord(pod, &oldPod, api.Kind("Pod").WithVersion("version"), "testNamespace", namespace.ObjectMeta.Name, api.Resource("pods").WithVersion("version"), "", admission.Update, false, nil))
|
|
||||||
if test.admit && err != nil {
|
|
||||||
t.Errorf("Test: %s, expected no error but got: %s", test.testName, err)
|
|
||||||
} else if !test.admit && err == nil {
|
|
||||||
t.Errorf("Test: %s, expected an error", test.testName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHandles(t *testing.T) {
|
func TestHandles(t *testing.T) {
|
||||||
for op, shouldHandle := range map[admission.Operation]bool{
|
for op, shouldHandle := range map[admission.Operation]bool{
|
||||||
admission.Create: true,
|
admission.Create: true,
|
||||||
admission.Update: true,
|
admission.Update: false,
|
||||||
admission.Connect: false,
|
admission.Connect: false,
|
||||||
admission.Delete: false,
|
admission.Delete: false,
|
||||||
} {
|
} {
|
||||||
|
@ -216,40 +193,6 @@ func TestHandles(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIgnoreUpdatingInitializedPod(t *testing.T) {
|
|
||||||
namespaceNodeSelector := "infra=true"
|
|
||||||
namespace := &corev1.Namespace{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "testNamespace",
|
|
||||||
Namespace: "",
|
|
||||||
Annotations: map[string]string{"scheduler.alpha.kubernetes.io/node-selector": namespaceNodeSelector},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
mockClient := fake.NewSimpleClientset(namespace)
|
|
||||||
handler, informerFactory, err := newHandlerForTest(mockClient)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unexpected error initializing handler: %v", err)
|
|
||||||
}
|
|
||||||
handler.SetReadyFunc(func() bool { return true })
|
|
||||||
|
|
||||||
podNodeSelector := map[string]string{"infra": "false"}
|
|
||||||
pod := &api.Pod{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "testPod", Namespace: "testNamespace"},
|
|
||||||
Spec: api.PodSpec{NodeSelector: podNodeSelector},
|
|
||||||
}
|
|
||||||
// this conflicts with podNodeSelector
|
|
||||||
err = informerFactory.Core().V1().Namespaces().Informer().GetStore().Update(namespace)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the update of initialized pod is not ignored, an error will be returned because the pod's nodeSelector conflicts with namespace's nodeSelector.
|
|
||||||
err = handler.Admit(admission.NewAttributesRecord(pod, pod, api.Kind("Pod").WithVersion("version"), "testNamespace", namespace.ObjectMeta.Name, api.Resource("pods").WithVersion("version"), "", admission.Update, false, nil))
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("expected no error, got: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// newHandlerForTest returns the admission controller configured for testing.
|
// newHandlerForTest returns the admission controller configured for testing.
|
||||||
func newHandlerForTest(c kubernetes.Interface) (*podNodeSelector, informers.SharedInformerFactory, error) {
|
func newHandlerForTest(c kubernetes.Interface) (*podNodeSelector, informers.SharedInformerFactory, error) {
|
||||||
f := informers.NewSharedInformerFactory(c, 5*time.Minute)
|
f := informers.NewSharedInformerFactory(c, 5*time.Minute)
|
||||||
|
|
|
@ -40,7 +40,6 @@ go_library(
|
||||||
"//pkg/apis/core:go_default_library",
|
"//pkg/apis/core:go_default_library",
|
||||||
"//pkg/apis/core/helper/qos:go_default_library",
|
"//pkg/apis/core/helper/qos:go_default_library",
|
||||||
"//pkg/apis/core/v1:go_default_library",
|
"//pkg/apis/core/v1:go_default_library",
|
||||||
"//pkg/kubeapiserver/admission/util:go_default_library",
|
|
||||||
"//pkg/scheduler/api:go_default_library",
|
"//pkg/scheduler/api:go_default_library",
|
||||||
"//pkg/util/tolerations:go_default_library",
|
"//pkg/util/tolerations:go_default_library",
|
||||||
"//plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction:go_default_library",
|
"//plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction:go_default_library",
|
||||||
|
|
|
@ -35,7 +35,6 @@ import (
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
qoshelper "k8s.io/kubernetes/pkg/apis/core/helper/qos"
|
qoshelper "k8s.io/kubernetes/pkg/apis/core/helper/qos"
|
||||||
k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
|
k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
|
||||||
"k8s.io/kubernetes/pkg/kubeapiserver/admission/util"
|
|
||||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
||||||
"k8s.io/kubernetes/pkg/util/tolerations"
|
"k8s.io/kubernetes/pkg/util/tolerations"
|
||||||
pluginapi "k8s.io/kubernetes/plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction"
|
pluginapi "k8s.io/kubernetes/plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction"
|
||||||
|
@ -93,11 +92,7 @@ func (p *podTolerationsPlugin) Admit(a admission.Attributes) error {
|
||||||
|
|
||||||
pod := a.GetObject().(*api.Pod)
|
pod := a.GetObject().(*api.Pod)
|
||||||
var finalTolerations []api.Toleration
|
var finalTolerations []api.Toleration
|
||||||
updateUninitialized, err := util.IsUpdatingUninitializedObject(a)
|
if a.GetOperation() == admission.Create {
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if a.GetOperation() == admission.Create || updateUninitialized {
|
|
||||||
ts, err := p.getNamespaceDefaultTolerations(a.GetNamespace())
|
ts, err := p.getNamespaceDefaultTolerations(a.GetNamespace())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -254,11 +254,6 @@ func TestPodAdmission(t *testing.T) {
|
||||||
pod := test.pod
|
pod := test.pod
|
||||||
pod.Spec.Tolerations = test.podTolerations
|
pod.Spec.Tolerations = test.podTolerations
|
||||||
|
|
||||||
// copy the original pod for tests of uninitialized pod updates.
|
|
||||||
oldPod := *pod
|
|
||||||
oldPod.Initializers = &metav1.Initializers{Pending: []metav1.Initializer{{Name: "init"}}}
|
|
||||||
oldPod.Spec.Tolerations = []api.Toleration{{Key: "testKey", Operator: "Equal", Value: "testValue1", Effect: "NoSchedule", TolerationSeconds: nil}}
|
|
||||||
|
|
||||||
err = handler.Admit(admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "testNamespace", namespace.ObjectMeta.Name, api.Resource("pods").WithVersion("version"), "", admission.Create, false, nil))
|
err = handler.Admit(admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "testNamespace", namespace.ObjectMeta.Name, api.Resource("pods").WithVersion("version"), "", admission.Create, false, nil))
|
||||||
if test.admit && err != nil {
|
if test.admit && err != nil {
|
||||||
t.Errorf("Test: %s, expected no error but got: %s", test.testName, err)
|
t.Errorf("Test: %s, expected no error but got: %s", test.testName, err)
|
||||||
|
@ -270,19 +265,6 @@ func TestPodAdmission(t *testing.T) {
|
||||||
if test.admit && !tolerations.EqualTolerations(updatedPodTolerations, test.mergedTolerations) {
|
if test.admit && !tolerations.EqualTolerations(updatedPodTolerations, test.mergedTolerations) {
|
||||||
t.Errorf("Test: %s, expected: %#v but got: %#v", test.testName, test.mergedTolerations, updatedPodTolerations)
|
t.Errorf("Test: %s, expected: %#v but got: %#v", test.testName, test.mergedTolerations, updatedPodTolerations)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handles update of uninitialized pod like it's newly created.
|
|
||||||
err = handler.Admit(admission.NewAttributesRecord(pod, &oldPod, api.Kind("Pod").WithVersion("version"), "testNamespace", namespace.ObjectMeta.Name, api.Resource("pods").WithVersion("version"), "", admission.Update, false, nil))
|
|
||||||
if test.admit && err != nil {
|
|
||||||
t.Errorf("Test: %s, expected no error but got: %s", test.testName, err)
|
|
||||||
} else if !test.admit && err == nil {
|
|
||||||
t.Errorf("Test: %s, expected an error", test.testName)
|
|
||||||
}
|
|
||||||
|
|
||||||
updatedPodTolerations = pod.Spec.Tolerations
|
|
||||||
if test.admit && !tolerations.EqualTolerations(updatedPodTolerations, test.mergedTolerations) {
|
|
||||||
t.Errorf("Test: %s, expected: %#v but got: %#v", test.testName, test.mergedTolerations, updatedPodTolerations)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ go_library(
|
||||||
"//pkg/api/pod:go_default_library",
|
"//pkg/api/pod:go_default_library",
|
||||||
"//pkg/apis/core:go_default_library",
|
"//pkg/apis/core:go_default_library",
|
||||||
"//pkg/features:go_default_library",
|
"//pkg/features:go_default_library",
|
||||||
"//pkg/kubeapiserver/admission/util:go_default_library",
|
|
||||||
"//pkg/serviceaccount:go_default_library",
|
"//pkg/serviceaccount:go_default_library",
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||||
|
|
|
@ -40,7 +40,6 @@ import (
|
||||||
podutil "k8s.io/kubernetes/pkg/api/pod"
|
podutil "k8s.io/kubernetes/pkg/api/pod"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
kubefeatures "k8s.io/kubernetes/pkg/features"
|
kubefeatures "k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/kubeapiserver/admission/util"
|
|
||||||
"k8s.io/kubernetes/pkg/serviceaccount"
|
"k8s.io/kubernetes/pkg/serviceaccount"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ var _ = genericadmissioninitializer.WantsExternalKubeInformerFactory(&serviceAcc
|
||||||
// 5. If MountServiceAccountToken is true, it adds a VolumeMount with the pod's ServiceAccount's api token secret to containers
|
// 5. If MountServiceAccountToken is true, it adds a VolumeMount with the pod's ServiceAccount's api token secret to containers
|
||||||
func NewServiceAccount() *serviceAccount {
|
func NewServiceAccount() *serviceAccount {
|
||||||
return &serviceAccount{
|
return &serviceAccount{
|
||||||
Handler: admission.NewHandler(admission.Create, admission.Update),
|
Handler: admission.NewHandler(admission.Create),
|
||||||
// TODO: enable this once we've swept secret usage to account for adding secret references to service accounts
|
// TODO: enable this once we've swept secret usage to account for adding secret references to service accounts
|
||||||
LimitSecretReferences: false,
|
LimitSecretReferences: false,
|
||||||
// Auto mount service account API token secrets
|
// Auto mount service account API token secrets
|
||||||
|
@ -153,14 +152,6 @@ func (s *serviceAccount) Admit(a admission.Attributes) (err error) {
|
||||||
if shouldIgnore(a) {
|
if shouldIgnore(a) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
updateInitialized, err := util.IsUpdatingInitializedObject(a)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if updateInitialized {
|
|
||||||
// related pod spec fields are immutable after the pod is initialized
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
pod := a.GetObject().(*api.Pod)
|
pod := a.GetObject().(*api.Pod)
|
||||||
|
|
||||||
|
@ -202,14 +193,6 @@ func (s *serviceAccount) Validate(a admission.Attributes) (err error) {
|
||||||
if shouldIgnore(a) {
|
if shouldIgnore(a) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
updateInitialized, err := util.IsUpdatingInitializedObject(a)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if updateInitialized {
|
|
||||||
// related pod spec fields are immutable after the pod is initialized
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
pod := a.GetObject().(*api.Pod)
|
pod := a.GetObject().(*api.Pod)
|
||||||
|
|
||||||
|
@ -257,6 +240,9 @@ func shouldIgnore(a admission.Attributes) bool {
|
||||||
if a.GetResource().GroupResource() != api.Resource("pods") {
|
if a.GetResource().GroupResource() != api.Resource("pods") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if a.GetSubresource() != "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
obj := a.GetObject()
|
obj := a.GetObject()
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -62,17 +62,6 @@ func TestIgnoresNonCreate(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIgnoresUpdateOfInitializedPod(t *testing.T) {
|
|
||||||
pod := &api.Pod{}
|
|
||||||
oldPod := &api.Pod{}
|
|
||||||
attrs := admission.NewAttributesRecord(pod, oldPod, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", admission.Update, false, nil)
|
|
||||||
handler := NewServiceAccount()
|
|
||||||
err := handler.Admit(attrs)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Expected update of initialized pod allowed, got err: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestIgnoresNonPodResource(t *testing.T) {
|
func TestIgnoresNonPodResource(t *testing.T) {
|
||||||
pod := &api.Pod{}
|
pod := &api.Pod{}
|
||||||
attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("CustomResource").WithVersion("version"), "", admission.Create, false, nil)
|
attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("CustomResource").WithVersion("version"), "", admission.Create, false, nil)
|
||||||
|
@ -362,54 +351,6 @@ func TestAutomountsAPIToken(t *testing.T) {
|
||||||
t.Fatalf("Expected\n\t%#v\ngot\n\t%#v", expectedVolumeMount, pod.Spec.Containers[0].VolumeMounts[0])
|
t.Fatalf("Expected\n\t%#v\ngot\n\t%#v", expectedVolumeMount, pod.Spec.Containers[0].VolumeMounts[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test ServiceAccount admission plugin applies the same changes if the
|
|
||||||
// operation is an update to an uninitialized pod.
|
|
||||||
oldPod := &api.Pod{
|
|
||||||
Spec: api.PodSpec{
|
|
||||||
Containers: []api.Container{
|
|
||||||
{
|
|
||||||
// the volumeMount in the oldPod shouldn't affect the result.
|
|
||||||
VolumeMounts: []api.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "wrong-" + tokenName,
|
|
||||||
ReadOnly: true,
|
|
||||||
MountPath: DefaultAPITokenMountPath,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
// oldPod is not intialized.
|
|
||||||
oldPod.Initializers = &metav1.Initializers{Pending: []metav1.Initializer{{Name: "init"}}}
|
|
||||||
pod = &api.Pod{
|
|
||||||
Spec: api.PodSpec{
|
|
||||||
Containers: []api.Container{
|
|
||||||
{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
attrs = admission.NewAttributesRecord(pod, oldPod, api.Kind("Pod").WithVersion("version"), ns, "myname", api.Resource("pods").WithVersion("version"), "", admission.Update, false, nil)
|
|
||||||
err = admit.Admit(attrs)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if pod.Spec.ServiceAccountName != DefaultServiceAccountName {
|
|
||||||
t.Errorf("Expected service account %s assigned, got %s", DefaultServiceAccountName, pod.Spec.ServiceAccountName)
|
|
||||||
}
|
|
||||||
if len(pod.Spec.Volumes) != 1 {
|
|
||||||
t.Fatalf("Expected 1 volume, got %d", len(pod.Spec.Volumes))
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(expectedVolume, pod.Spec.Volumes[0]) {
|
|
||||||
t.Fatalf("Expected\n\t%#v\ngot\n\t%#v", expectedVolume, pod.Spec.Volumes[0])
|
|
||||||
}
|
|
||||||
if len(pod.Spec.Containers[0].VolumeMounts) != 1 {
|
|
||||||
t.Fatalf("Expected 1 volume mount, got %d", len(pod.Spec.Containers[0].VolumeMounts))
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(expectedVolumeMount, pod.Spec.Containers[0].VolumeMounts[0]) {
|
|
||||||
t.Fatalf("Expected\n\t%#v\ngot\n\t%#v", expectedVolumeMount, pod.Spec.Containers[0].VolumeMounts[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
// testing InitContainers
|
// testing InitContainers
|
||||||
pod = &api.Pod{
|
pod = &api.Pod{
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
|
|
|
@ -42,7 +42,6 @@ filegroup(
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/errors:all-srcs",
|
"//staging/src/k8s.io/apimachinery/pkg/util/errors:all-srcs",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/framer:all-srcs",
|
"//staging/src/k8s.io/apimachinery/pkg/util/framer:all-srcs",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/httpstream:all-srcs",
|
"//staging/src/k8s.io/apimachinery/pkg/util/httpstream:all-srcs",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/initialization:all-srcs",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:all-srcs",
|
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:all-srcs",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/json:all-srcs",
|
"//staging/src/k8s.io/apimachinery/pkg/util/json:all-srcs",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/jsonmergepatch:all-srcs",
|
"//staging/src/k8s.io/apimachinery/pkg/util/jsonmergepatch:all-srcs",
|
||||||
|
@ -123,7 +122,6 @@ filegroup(
|
||||||
"//staging/src/k8s.io/client-go/informers:all-srcs",
|
"//staging/src/k8s.io/client-go/informers:all-srcs",
|
||||||
"//staging/src/k8s.io/client-go/kubernetes:all-srcs",
|
"//staging/src/k8s.io/client-go/kubernetes:all-srcs",
|
||||||
"//staging/src/k8s.io/client-go/kubernetes_test:all-srcs",
|
"//staging/src/k8s.io/client-go/kubernetes_test:all-srcs",
|
||||||
"//staging/src/k8s.io/client-go/listers/admissionregistration/v1alpha1:all-srcs",
|
|
||||||
"//staging/src/k8s.io/client-go/listers/admissionregistration/v1beta1:all-srcs",
|
"//staging/src/k8s.io/client-go/listers/admissionregistration/v1beta1:all-srcs",
|
||||||
"//staging/src/k8s.io/client-go/listers/apps/v1:all-srcs",
|
"//staging/src/k8s.io/client-go/listers/apps/v1:all-srcs",
|
||||||
"//staging/src/k8s.io/client-go/listers/apps/v1beta1:all-srcs",
|
"//staging/src/k8s.io/client-go/listers/apps/v1beta1:all-srcs",
|
||||||
|
|
|
@ -5,7 +5,6 @@ go_test(
|
||||||
srcs = ["roundtrip_test.go"],
|
srcs = ["roundtrip_test.go"],
|
||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/api/admission/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/admission/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1alpha1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/admissionregistration/v1beta1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
||||||
|
@ -58,7 +57,6 @@ filegroup(
|
||||||
srcs = [
|
srcs = [
|
||||||
":package-srcs",
|
":package-srcs",
|
||||||
"//staging/src/k8s.io/api/admission/v1beta1:all-srcs",
|
"//staging/src/k8s.io/api/admission/v1beta1:all-srcs",
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1alpha1:all-srcs",
|
|
||||||
"//staging/src/k8s.io/api/admissionregistration/v1beta1:all-srcs",
|
"//staging/src/k8s.io/api/admissionregistration/v1beta1:all-srcs",
|
||||||
"//staging/src/k8s.io/api/apps/v1:all-srcs",
|
"//staging/src/k8s.io/api/apps/v1:all-srcs",
|
||||||
"//staging/src/k8s.io/api/apps/v1beta1:all-srcs",
|
"//staging/src/k8s.io/api/apps/v1beta1:all-srcs",
|
||||||
|
|
|
@ -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",
|
|
||||||
"generated.pb.go",
|
|
||||||
"register.go",
|
|
||||||
"types.go",
|
|
||||||
"types_swagger_doc_generated.go",
|
|
||||||
"zz_generated.deepcopy.go",
|
|
||||||
],
|
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/api/admissionregistration/v1alpha1",
|
|
||||||
importpath = "k8s.io/api/admissionregistration/v1alpha1",
|
|
||||||
deps = [
|
|
||||||
"//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,25 +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:openapi-gen=true
|
|
||||||
// +groupName=admissionregistration.k8s.io
|
|
||||||
|
|
||||||
// Package v1alpha1 is the v1alpha1 version of the API.
|
|
||||||
// AdmissionConfiguration and AdmissionPluginConfiguration are legacy static admission plugin configuration
|
|
||||||
// InitializerConfiguration and validatingWebhookConfiguration is for the
|
|
||||||
// new dynamic admission controller configuration.
|
|
||||||
package v1alpha1 // import "k8s.io/api/admissionregistration/v1alpha1"
|
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue