Switch to github.com/golang/dep for vendoring
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
d6ab91be27
commit
8e5b17cf13
15431 changed files with 3971413 additions and 8881 deletions
56
vendor/k8s.io/kubernetes/pkg/apis/extensions/BUILD
generated
vendored
Normal file
56
vendor/k8s.io/kubernetes/pkg/apis/extensions/BUILD
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"helpers.go",
|
||||
"register.go",
|
||||
"types.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/resource:go_default_library",
|
||||
"//pkg/apis/autoscaling:go_default_library",
|
||||
"//pkg/util/intstr:go_default_library",
|
||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"//vendor:k8s.io/apimachinery/pkg/conversion",
|
||||
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
||||
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["helpers_test.go"],
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//pkg/apis/extensions/install:all-srcs",
|
||||
"//pkg/apis/extensions/v1beta1:all-srcs",
|
||||
"//pkg/apis/extensions/validation:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
41
vendor/k8s.io/kubernetes/pkg/apis/extensions/OWNERS
generated
vendored
Executable file
41
vendor/k8s.io/kubernetes/pkg/apis/extensions/OWNERS
generated
vendored
Executable file
|
@ -0,0 +1,41 @@
|
|||
reviewers:
|
||||
- thockin
|
||||
- lavalamp
|
||||
- smarterclayton
|
||||
- wojtek-t
|
||||
- deads2k
|
||||
- brendandburns
|
||||
- derekwaynecarr
|
||||
- caesarxuchao
|
||||
- mikedanese
|
||||
- liggitt
|
||||
- nikhiljindal
|
||||
- bprashanth
|
||||
- erictune
|
||||
- pmorie
|
||||
- sttts
|
||||
- kargakis
|
||||
- saad-ali
|
||||
- janetkuo
|
||||
- justinsb
|
||||
- ncdc
|
||||
- timstclair
|
||||
- mwielgus
|
||||
- timothysc
|
||||
- soltysh
|
||||
- piosz
|
||||
- dims
|
||||
- errordeveloper
|
||||
- madhusudancs
|
||||
- rootfs
|
||||
- jszczepkowski
|
||||
- mml
|
||||
- resouer
|
||||
- mbohlool
|
||||
- david-mcmahon
|
||||
- therc
|
||||
- pweil-
|
||||
- tmrts
|
||||
- mqliang
|
||||
- lukaszo
|
||||
- jianhuiz
|
19
vendor/k8s.io/kubernetes/pkg/apis/extensions/doc.go
generated
vendored
Normal file
19
vendor/k8s.io/kubernetes/pkg/apis/extensions/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
|
||||
package extensions // import "k8s.io/kubernetes/pkg/apis/extensions"
|
37
vendor/k8s.io/kubernetes/pkg/apis/extensions/helpers.go
generated
vendored
Normal file
37
vendor/k8s.io/kubernetes/pkg/apis/extensions/helpers.go
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package extensions
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// SysctlsFromPodSecurityPolicyAnnotation parses an annotation value of the key
|
||||
// SysctlsSecurityPolocyAnnotationKey into a slice of sysctls. An empty slice
|
||||
// is returned if annotation is the empty string.
|
||||
func SysctlsFromPodSecurityPolicyAnnotation(annotation string) ([]string, error) {
|
||||
if len(annotation) == 0 {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
return strings.Split(annotation, ","), nil
|
||||
}
|
||||
|
||||
// PodAnnotationsFromSysctls creates an annotation value for a slice of Sysctls.
|
||||
func PodAnnotationsFromSysctls(sysctls []string) string {
|
||||
return strings.Join(sysctls, ",")
|
||||
}
|
62
vendor/k8s.io/kubernetes/pkg/apis/extensions/helpers_test.go
generated
vendored
Normal file
62
vendor/k8s.io/kubernetes/pkg/apis/extensions/helpers_test.go
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package extensions
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPodAnnotationsFromSysctls(t *testing.T) {
|
||||
type Test struct {
|
||||
sysctls []string
|
||||
expectedValue string
|
||||
}
|
||||
for _, test := range []Test{
|
||||
{sysctls: []string{"a.b"}, expectedValue: "a.b"},
|
||||
{sysctls: []string{"a.b", "c.d"}, expectedValue: "a.b,c.d"},
|
||||
{sysctls: []string{"a.b", "a.b"}, expectedValue: "a.b,a.b"},
|
||||
{sysctls: []string{}, expectedValue: ""},
|
||||
{sysctls: nil, expectedValue: ""},
|
||||
} {
|
||||
a := PodAnnotationsFromSysctls(test.sysctls)
|
||||
if a != test.expectedValue {
|
||||
t.Errorf("wrong value for %v: got=%q wanted=%q", test.sysctls, a, test.expectedValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSysctlsFromPodSecurityPolicyAnnotation(t *testing.T) {
|
||||
type Test struct {
|
||||
expectedValue []string
|
||||
annotation string
|
||||
}
|
||||
for _, test := range []Test{
|
||||
{annotation: "a.b", expectedValue: []string{"a.b"}},
|
||||
{annotation: "a.b,c.d", expectedValue: []string{"a.b", "c.d"}},
|
||||
{annotation: "a.b,a.b", expectedValue: []string{"a.b", "a.b"}},
|
||||
{annotation: "", expectedValue: []string{}},
|
||||
} {
|
||||
sysctls, err := SysctlsFromPodSecurityPolicyAnnotation(test.annotation)
|
||||
if err != nil {
|
||||
t.Errorf("error for %q: %v", test.annotation, err)
|
||||
}
|
||||
if !reflect.DeepEqual(sysctls, test.expectedValue) {
|
||||
t.Errorf("wrong value for %q: got=%v wanted=%v", test.annotation, sysctls, test.expectedValue)
|
||||
}
|
||||
}
|
||||
}
|
33
vendor/k8s.io/kubernetes/pkg/apis/extensions/install/BUILD
generated
vendored
Normal file
33
vendor/k8s.io/kubernetes/pkg/apis/extensions/install/BUILD
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["install.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/apimachinery/announced:go_default_library",
|
||||
"//pkg/apis/extensions:go_default_library",
|
||||
"//pkg/apis/extensions/v1beta1:go_default_library",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/sets",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
43
vendor/k8s.io/kubernetes/pkg/apis/extensions/install/install.go
generated
vendored
Normal file
43
vendor/k8s.io/kubernetes/pkg/apis/extensions/install/install.go
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
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 install installs the experimental API group, making it available as
|
||||
// an option to all of the API encoding/decoding machinery.
|
||||
package install
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/kubernetes/pkg/apimachinery/announced"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
if err := announced.NewGroupMetaFactory(
|
||||
&announced.GroupMetaFactoryArgs{
|
||||
GroupName: extensions.GroupName,
|
||||
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version},
|
||||
ImportPrefix: "k8s.io/kubernetes/pkg/apis/extensions",
|
||||
RootScopedKinds: sets.NewString("PodSecurityPolicy", "ThirdPartyResource"),
|
||||
AddInternalObjectsToScheme: extensions.AddToScheme,
|
||||
},
|
||||
announced.VersionToSchemeFunc{
|
||||
v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme,
|
||||
},
|
||||
).Announce().RegisterAndEnable(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
79
vendor/k8s.io/kubernetes/pkg/apis/extensions/register.go
generated
vendored
Normal file
79
vendor/k8s.io/kubernetes/pkg/apis/extensions/register.go
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
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 extensions
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
)
|
||||
|
||||
// GroupName is the group name use in this package
|
||||
const GroupName = "extensions"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
|
||||
|
||||
// Kind takes an unqualified kind and returns a Group qualified GroupKind
|
||||
func Kind(kind string) schema.GroupKind {
|
||||
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||
}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
var (
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to api.Scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
// TODO this gets cleaned up when the types are fixed
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&Deployment{},
|
||||
&DeploymentList{},
|
||||
&DeploymentRollback{},
|
||||
&autoscaling.HorizontalPodAutoscaler{},
|
||||
&autoscaling.HorizontalPodAutoscalerList{},
|
||||
&ReplicationControllerDummy{},
|
||||
&Scale{},
|
||||
&ThirdPartyResource{},
|
||||
&ThirdPartyResourceList{},
|
||||
&DaemonSetList{},
|
||||
&DaemonSet{},
|
||||
&ThirdPartyResourceData{},
|
||||
&ThirdPartyResourceDataList{},
|
||||
&Ingress{},
|
||||
&IngressList{},
|
||||
&api.ListOptions{},
|
||||
&api.DeleteOptions{},
|
||||
&ReplicaSet{},
|
||||
&ReplicaSetList{},
|
||||
&metav1.ExportOptions{},
|
||||
&metav1.GetOptions{},
|
||||
&PodSecurityPolicy{},
|
||||
&PodSecurityPolicyList{},
|
||||
&NetworkPolicy{},
|
||||
&NetworkPolicyList{},
|
||||
)
|
||||
return nil
|
||||
}
|
1111
vendor/k8s.io/kubernetes/pkg/apis/extensions/types.go
generated
vendored
Normal file
1111
vendor/k8s.io/kubernetes/pkg/apis/extensions/types.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
73
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/BUILD
generated
vendored
Normal file
73
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/BUILD
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"conversion.go",
|
||||
"defaults.go",
|
||||
"doc.go",
|
||||
"generated.pb.go",
|
||||
"register.go",
|
||||
"types.generated.go",
|
||||
"types.go",
|
||||
"types_swagger_doc_generated.go",
|
||||
"zz_generated.conversion.go",
|
||||
"zz_generated.deepcopy.go",
|
||||
"zz_generated.defaults.go",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/resource:go_default_library",
|
||||
"//pkg/api/v1:go_default_library",
|
||||
"//pkg/apis/autoscaling:go_default_library",
|
||||
"//pkg/apis/extensions:go_default_library",
|
||||
"//pkg/util/intstr:go_default_library",
|
||||
"//vendor:github.com/gogo/protobuf/proto",
|
||||
"//vendor:github.com/gogo/protobuf/sortkeys",
|
||||
"//vendor:github.com/ugorji/go/codec",
|
||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"//vendor:k8s.io/apimachinery/pkg/conversion",
|
||||
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
||||
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
|
||||
"//vendor:k8s.io/apimachinery/pkg/types",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["defaults_test.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/install:go_default_library",
|
||||
"//pkg/api/resource:go_default_library",
|
||||
"//pkg/api/v1:go_default_library",
|
||||
"//pkg/apis/extensions/install:go_default_library",
|
||||
"//pkg/apis/extensions/v1beta1:go_default_library",
|
||||
"//pkg/util/intstr:go_default_library",
|
||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
300
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/conversion.go
generated
vendored
Normal file
300
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/conversion.go
generated
vendored
Normal file
|
@ -0,0 +1,300 @@
|
|||
/*
|
||||
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 v1beta1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
v1 "k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func addConversionFuncs(scheme *runtime.Scheme) error {
|
||||
// Add non-generated conversion functions
|
||||
err := scheme.AddConversionFuncs(
|
||||
Convert_extensions_ScaleStatus_To_v1beta1_ScaleStatus,
|
||||
Convert_v1beta1_ScaleStatus_To_extensions_ScaleStatus,
|
||||
Convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec,
|
||||
Convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec,
|
||||
Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy,
|
||||
Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy,
|
||||
Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment,
|
||||
Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment,
|
||||
Convert_extensions_ReplicaSetSpec_To_v1beta1_ReplicaSetSpec,
|
||||
Convert_v1beta1_ReplicaSetSpec_To_extensions_ReplicaSetSpec,
|
||||
// autoscaling
|
||||
Convert_autoscaling_CrossVersionObjectReference_To_v1beta1_SubresourceReference,
|
||||
Convert_v1beta1_SubresourceReference_To_autoscaling_CrossVersionObjectReference,
|
||||
Convert_autoscaling_HorizontalPodAutoscalerSpec_To_v1beta1_HorizontalPodAutoscalerSpec,
|
||||
Convert_v1beta1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
|
||||
for _, k := range []string{"DaemonSet", "Deployment", "Ingress"} {
|
||||
kind := k // don't close over range variables
|
||||
err = api.Scheme.AddFieldLabelConversionFunc("extensions/v1beta1", kind,
|
||||
func(label, value string) (string, string, error) {
|
||||
switch label {
|
||||
case "metadata.name", "metadata.namespace":
|
||||
return label, value, nil
|
||||
default:
|
||||
return "", "", fmt.Errorf("field label %q not supported for %q", label, kind)
|
||||
}
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_extensions_ScaleStatus_To_v1beta1_ScaleStatus(in *extensions.ScaleStatus, out *ScaleStatus, s conversion.Scope) error {
|
||||
out.Replicas = int32(in.Replicas)
|
||||
|
||||
out.Selector = nil
|
||||
out.TargetSelector = ""
|
||||
if in.Selector != nil {
|
||||
if in.Selector.MatchExpressions == nil || len(in.Selector.MatchExpressions) == 0 {
|
||||
out.Selector = in.Selector.MatchLabels
|
||||
}
|
||||
|
||||
selector, err := metav1.LabelSelectorAsSelector(in.Selector)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid label selector: %v", err)
|
||||
}
|
||||
out.TargetSelector = selector.String()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1beta1_ScaleStatus_To_extensions_ScaleStatus(in *ScaleStatus, out *extensions.ScaleStatus, s conversion.Scope) error {
|
||||
out.Replicas = in.Replicas
|
||||
|
||||
// Normally when 2 fields map to the same internal value we favor the old field, since
|
||||
// old clients can't be expected to know about new fields but clients that know about the
|
||||
// new field can be expected to know about the old field (though that's not quite true, due
|
||||
// to kubectl apply). However, these fields are readonly, so any non-nil value should work.
|
||||
if in.TargetSelector != "" {
|
||||
labelSelector, err := metav1.ParseToLabelSelector(in.TargetSelector)
|
||||
if err != nil {
|
||||
out.Selector = nil
|
||||
return fmt.Errorf("failed to parse target selector: %v", err)
|
||||
}
|
||||
out.Selector = labelSelector
|
||||
} else if in.Selector != nil {
|
||||
out.Selector = new(metav1.LabelSelector)
|
||||
selector := make(map[string]string)
|
||||
for key, val := range in.Selector {
|
||||
selector[key] = val
|
||||
}
|
||||
out.Selector.MatchLabels = selector
|
||||
} else {
|
||||
out.Selector = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensions.DeploymentSpec, out *DeploymentSpec, s conversion.Scope) error {
|
||||
out.Replicas = &in.Replicas
|
||||
out.Selector = in.Selector
|
||||
if err := v1.Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.RevisionHistoryLimit != nil {
|
||||
out.RevisionHistoryLimit = new(int32)
|
||||
*out.RevisionHistoryLimit = int32(*in.RevisionHistoryLimit)
|
||||
}
|
||||
out.MinReadySeconds = int32(in.MinReadySeconds)
|
||||
out.Paused = in.Paused
|
||||
if in.RollbackTo != nil {
|
||||
out.RollbackTo = new(RollbackConfig)
|
||||
out.RollbackTo.Revision = int64(in.RollbackTo.Revision)
|
||||
} else {
|
||||
out.RollbackTo = nil
|
||||
}
|
||||
if in.ProgressDeadlineSeconds != nil {
|
||||
out.ProgressDeadlineSeconds = new(int32)
|
||||
*out.ProgressDeadlineSeconds = *in.ProgressDeadlineSeconds
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *DeploymentSpec, out *extensions.DeploymentSpec, s conversion.Scope) error {
|
||||
if in.Replicas != nil {
|
||||
out.Replicas = *in.Replicas
|
||||
}
|
||||
out.Selector = in.Selector
|
||||
if err := v1.Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.RevisionHistoryLimit = in.RevisionHistoryLimit
|
||||
out.MinReadySeconds = in.MinReadySeconds
|
||||
out.Paused = in.Paused
|
||||
if in.RollbackTo != nil {
|
||||
out.RollbackTo = new(extensions.RollbackConfig)
|
||||
out.RollbackTo.Revision = in.RollbackTo.Revision
|
||||
} else {
|
||||
out.RollbackTo = nil
|
||||
}
|
||||
if in.ProgressDeadlineSeconds != nil {
|
||||
out.ProgressDeadlineSeconds = new(int32)
|
||||
*out.ProgressDeadlineSeconds = *in.ProgressDeadlineSeconds
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(in *extensions.DeploymentStrategy, out *DeploymentStrategy, s conversion.Scope) error {
|
||||
out.Type = DeploymentStrategyType(in.Type)
|
||||
if in.RollingUpdate != nil {
|
||||
out.RollingUpdate = new(RollingUpdateDeployment)
|
||||
if err := Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.RollingUpdate = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(in *DeploymentStrategy, out *extensions.DeploymentStrategy, s conversion.Scope) error {
|
||||
out.Type = extensions.DeploymentStrategyType(in.Type)
|
||||
if in.RollingUpdate != nil {
|
||||
out.RollingUpdate = new(extensions.RollingUpdateDeployment)
|
||||
if err := Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.RollingUpdate = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in *extensions.RollingUpdateDeployment, out *RollingUpdateDeployment, s conversion.Scope) error {
|
||||
if out.MaxUnavailable == nil {
|
||||
out.MaxUnavailable = &intstr.IntOrString{}
|
||||
}
|
||||
if err := s.Convert(&in.MaxUnavailable, out.MaxUnavailable, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if out.MaxSurge == nil {
|
||||
out.MaxSurge = &intstr.IntOrString{}
|
||||
}
|
||||
if err := s.Convert(&in.MaxSurge, out.MaxSurge, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in *RollingUpdateDeployment, out *extensions.RollingUpdateDeployment, s conversion.Scope) error {
|
||||
if err := s.Convert(in.MaxUnavailable, &out.MaxUnavailable, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Convert(in.MaxSurge, &out.MaxSurge, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_extensions_ReplicaSetSpec_To_v1beta1_ReplicaSetSpec(in *extensions.ReplicaSetSpec, out *ReplicaSetSpec, s conversion.Scope) error {
|
||||
out.Replicas = new(int32)
|
||||
*out.Replicas = int32(in.Replicas)
|
||||
out.MinReadySeconds = in.MinReadySeconds
|
||||
out.Selector = in.Selector
|
||||
if err := v1.Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1beta1_ReplicaSetSpec_To_extensions_ReplicaSetSpec(in *ReplicaSetSpec, out *extensions.ReplicaSetSpec, s conversion.Scope) error {
|
||||
if in.Replicas != nil {
|
||||
out.Replicas = *in.Replicas
|
||||
}
|
||||
out.MinReadySeconds = in.MinReadySeconds
|
||||
out.Selector = in.Selector
|
||||
if err := v1.Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_CrossVersionObjectReference_To_v1beta1_SubresourceReference(in *autoscaling.CrossVersionObjectReference, out *SubresourceReference, s conversion.Scope) error {
|
||||
out.Kind = in.Kind
|
||||
out.Name = in.Name
|
||||
out.APIVersion = in.APIVersion
|
||||
out.Subresource = "scale"
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1beta1_SubresourceReference_To_autoscaling_CrossVersionObjectReference(in *SubresourceReference, out *autoscaling.CrossVersionObjectReference, s conversion.Scope) error {
|
||||
out.Kind = in.Kind
|
||||
out.Name = in.Name
|
||||
out.APIVersion = in.APIVersion
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_HorizontalPodAutoscalerSpec_To_v1beta1_HorizontalPodAutoscalerSpec(in *autoscaling.HorizontalPodAutoscalerSpec, out *HorizontalPodAutoscalerSpec, s conversion.Scope) error {
|
||||
if err := Convert_autoscaling_CrossVersionObjectReference_To_v1beta1_SubresourceReference(&in.ScaleTargetRef, &out.ScaleRef, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.MinReplicas != nil {
|
||||
out.MinReplicas = new(int32)
|
||||
*out.MinReplicas = *in.MinReplicas
|
||||
} else {
|
||||
out.MinReplicas = nil
|
||||
}
|
||||
out.MaxReplicas = in.MaxReplicas
|
||||
if in.TargetCPUUtilizationPercentage != nil {
|
||||
out.CPUUtilization = &CPUTargetUtilization{TargetPercentage: *in.TargetCPUUtilizationPercentage}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1beta1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec(in *HorizontalPodAutoscalerSpec, out *autoscaling.HorizontalPodAutoscalerSpec, s conversion.Scope) error {
|
||||
if err := Convert_v1beta1_SubresourceReference_To_autoscaling_CrossVersionObjectReference(&in.ScaleRef, &out.ScaleTargetRef, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.MinReplicas != nil {
|
||||
out.MinReplicas = new(int32)
|
||||
*out.MinReplicas = int32(*in.MinReplicas)
|
||||
} else {
|
||||
out.MinReplicas = nil
|
||||
}
|
||||
out.MaxReplicas = int32(in.MaxReplicas)
|
||||
if in.CPUUtilization != nil {
|
||||
out.TargetCPUUtilizationPercentage = new(int32)
|
||||
*out.TargetCPUUtilizationPercentage = int32(in.CPUUtilization.TargetPercentage)
|
||||
}
|
||||
return nil
|
||||
}
|
134
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/defaults.go
generated
vendored
Normal file
134
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/defaults.go
generated
vendored
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
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 v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
RegisterDefaults(scheme)
|
||||
return scheme.AddDefaultingFuncs(
|
||||
SetDefaults_DaemonSet,
|
||||
SetDefaults_Deployment,
|
||||
SetDefaults_HorizontalPodAutoscaler,
|
||||
SetDefaults_ReplicaSet,
|
||||
SetDefaults_NetworkPolicy,
|
||||
)
|
||||
}
|
||||
|
||||
func SetDefaults_DaemonSet(obj *DaemonSet) {
|
||||
labels := obj.Spec.Template.Labels
|
||||
|
||||
// TODO: support templates defined elsewhere when we support them in the API
|
||||
if labels != nil {
|
||||
if obj.Spec.Selector == nil {
|
||||
obj.Spec.Selector = &metav1.LabelSelector{
|
||||
MatchLabels: labels,
|
||||
}
|
||||
}
|
||||
if len(obj.Labels) == 0 {
|
||||
obj.Labels = labels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetDefaults_Deployment(obj *Deployment) {
|
||||
// Default labels and selector to labels from pod template spec.
|
||||
labels := obj.Spec.Template.Labels
|
||||
|
||||
if labels != nil {
|
||||
if obj.Spec.Selector == nil {
|
||||
obj.Spec.Selector = &metav1.LabelSelector{MatchLabels: labels}
|
||||
}
|
||||
if len(obj.Labels) == 0 {
|
||||
obj.Labels = labels
|
||||
}
|
||||
}
|
||||
// Set DeploymentSpec.Replicas to 1 if it is not set.
|
||||
if obj.Spec.Replicas == nil {
|
||||
obj.Spec.Replicas = new(int32)
|
||||
*obj.Spec.Replicas = 1
|
||||
}
|
||||
strategy := &obj.Spec.Strategy
|
||||
// Set default DeploymentStrategyType as RollingUpdate.
|
||||
if strategy.Type == "" {
|
||||
strategy.Type = RollingUpdateDeploymentStrategyType
|
||||
}
|
||||
if strategy.Type == RollingUpdateDeploymentStrategyType || strategy.RollingUpdate != nil {
|
||||
if strategy.RollingUpdate == nil {
|
||||
rollingUpdate := RollingUpdateDeployment{}
|
||||
strategy.RollingUpdate = &rollingUpdate
|
||||
}
|
||||
if strategy.RollingUpdate.MaxUnavailable == nil {
|
||||
// Set default MaxUnavailable as 1 by default.
|
||||
maxUnavailable := intstr.FromInt(1)
|
||||
strategy.RollingUpdate.MaxUnavailable = &maxUnavailable
|
||||
}
|
||||
if strategy.RollingUpdate.MaxSurge == nil {
|
||||
// Set default MaxSurge as 1 by default.
|
||||
maxSurge := intstr.FromInt(1)
|
||||
strategy.RollingUpdate.MaxSurge = &maxSurge
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetDefaults_HorizontalPodAutoscaler(obj *HorizontalPodAutoscaler) {
|
||||
if obj.Spec.MinReplicas == nil {
|
||||
minReplicas := int32(1)
|
||||
obj.Spec.MinReplicas = &minReplicas
|
||||
}
|
||||
if obj.Spec.CPUUtilization == nil {
|
||||
obj.Spec.CPUUtilization = &CPUTargetUtilization{TargetPercentage: 80}
|
||||
}
|
||||
}
|
||||
|
||||
func SetDefaults_ReplicaSet(obj *ReplicaSet) {
|
||||
labels := obj.Spec.Template.Labels
|
||||
|
||||
// TODO: support templates defined elsewhere when we support them in the API
|
||||
if labels != nil {
|
||||
if obj.Spec.Selector == nil {
|
||||
obj.Spec.Selector = &metav1.LabelSelector{
|
||||
MatchLabels: labels,
|
||||
}
|
||||
}
|
||||
if len(obj.Labels) == 0 {
|
||||
obj.Labels = labels
|
||||
}
|
||||
}
|
||||
if obj.Spec.Replicas == nil {
|
||||
obj.Spec.Replicas = new(int32)
|
||||
*obj.Spec.Replicas = 1
|
||||
}
|
||||
}
|
||||
|
||||
func SetDefaults_NetworkPolicy(obj *NetworkPolicy) {
|
||||
// Default any undefined Protocol fields to TCP.
|
||||
for _, i := range obj.Spec.Ingress {
|
||||
// TODO: Update Ports to be a pointer to slice as soon as auto-generation supports it.
|
||||
for _, p := range i.Ports {
|
||||
if p.Protocol == nil {
|
||||
proto := v1.ProtocolTCP
|
||||
p.Protocol = &proto
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
607
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/defaults_test.go
generated
vendored
Normal file
607
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/defaults_test.go
generated
vendored
Normal file
|
@ -0,0 +1,607 @@
|
|||
/*
|
||||
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 v1beta1_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
_ "k8s.io/kubernetes/pkg/api/install"
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
||||
. "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
||||
"k8s.io/kubernetes/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func TestSetDefaultDaemonSet(t *testing.T) {
|
||||
defaultLabels := map[string]string{"foo": "bar"}
|
||||
period := int64(v1.DefaultTerminationGracePeriodSeconds)
|
||||
defaultTemplate := v1.PodTemplateSpec{
|
||||
Spec: v1.PodSpec{
|
||||
DNSPolicy: v1.DNSClusterFirst,
|
||||
RestartPolicy: v1.RestartPolicyAlways,
|
||||
SecurityContext: &v1.PodSecurityContext{},
|
||||
TerminationGracePeriodSeconds: &period,
|
||||
},
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: defaultLabels,
|
||||
},
|
||||
}
|
||||
templateNoLabel := v1.PodTemplateSpec{
|
||||
Spec: v1.PodSpec{
|
||||
DNSPolicy: v1.DNSClusterFirst,
|
||||
RestartPolicy: v1.RestartPolicyAlways,
|
||||
SecurityContext: &v1.PodSecurityContext{},
|
||||
TerminationGracePeriodSeconds: &period,
|
||||
},
|
||||
}
|
||||
tests := []struct {
|
||||
original *DaemonSet
|
||||
expected *DaemonSet
|
||||
}{
|
||||
{ // Labels change/defaulting test.
|
||||
original: &DaemonSet{
|
||||
Spec: DaemonSetSpec{
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
expected: &DaemonSet{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: defaultLabels,
|
||||
},
|
||||
Spec: DaemonSetSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: defaultLabels,
|
||||
},
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ // Labels change/defaulting test.
|
||||
original: &DaemonSet{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
},
|
||||
},
|
||||
Spec: DaemonSetSpec{
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
expected: &DaemonSet{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
},
|
||||
},
|
||||
Spec: DaemonSetSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: defaultLabels,
|
||||
},
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ // Update strategy.
|
||||
original: &DaemonSet{},
|
||||
expected: &DaemonSet{
|
||||
Spec: DaemonSetSpec{
|
||||
Template: templateNoLabel,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ // Update strategy.
|
||||
original: &DaemonSet{
|
||||
Spec: DaemonSetSpec{},
|
||||
},
|
||||
expected: &DaemonSet{
|
||||
Spec: DaemonSetSpec{
|
||||
Template: templateNoLabel,
|
||||
},
|
||||
},
|
||||
},
|
||||
{ // Custom unique label key.
|
||||
original: &DaemonSet{
|
||||
Spec: DaemonSetSpec{},
|
||||
},
|
||||
expected: &DaemonSet{
|
||||
Spec: DaemonSetSpec{
|
||||
Template: templateNoLabel,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
original := test.original
|
||||
expected := test.expected
|
||||
obj2 := roundTrip(t, runtime.Object(original))
|
||||
got, ok := obj2.(*DaemonSet)
|
||||
if !ok {
|
||||
t.Errorf("(%d) unexpected object: %v", i, got)
|
||||
t.FailNow()
|
||||
}
|
||||
if !reflect.DeepEqual(got.Spec, expected.Spec) {
|
||||
t.Errorf("(%d) got different than expected\ngot:\n\t%+v\nexpected:\n\t%+v", i, got.Spec, expected.Spec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDefaultDeployment(t *testing.T) {
|
||||
defaultIntOrString := intstr.FromInt(1)
|
||||
differentIntOrString := intstr.FromInt(5)
|
||||
period := int64(v1.DefaultTerminationGracePeriodSeconds)
|
||||
defaultTemplate := v1.PodTemplateSpec{
|
||||
Spec: v1.PodSpec{
|
||||
DNSPolicy: v1.DNSClusterFirst,
|
||||
RestartPolicy: v1.RestartPolicyAlways,
|
||||
SecurityContext: &v1.PodSecurityContext{},
|
||||
TerminationGracePeriodSeconds: &period,
|
||||
},
|
||||
}
|
||||
tests := []struct {
|
||||
original *Deployment
|
||||
expected *Deployment
|
||||
}{
|
||||
{
|
||||
original: &Deployment{},
|
||||
expected: &Deployment{
|
||||
Spec: DeploymentSpec{
|
||||
Replicas: newInt32(1),
|
||||
Strategy: DeploymentStrategy{
|
||||
Type: RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &RollingUpdateDeployment{
|
||||
MaxSurge: &defaultIntOrString,
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
original: &Deployment{
|
||||
Spec: DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Strategy: DeploymentStrategy{
|
||||
RollingUpdate: &RollingUpdateDeployment{
|
||||
MaxSurge: &differentIntOrString,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: &Deployment{
|
||||
Spec: DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Strategy: DeploymentStrategy{
|
||||
Type: RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &RollingUpdateDeployment{
|
||||
MaxSurge: &differentIntOrString,
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
original: &Deployment{
|
||||
Spec: DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Strategy: DeploymentStrategy{
|
||||
Type: RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: &Deployment{
|
||||
Spec: DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Strategy: DeploymentStrategy{
|
||||
Type: RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &RollingUpdateDeployment{
|
||||
MaxSurge: &defaultIntOrString,
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
original: &Deployment{
|
||||
Spec: DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Strategy: DeploymentStrategy{
|
||||
Type: RecreateDeploymentStrategyType,
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: &Deployment{
|
||||
Spec: DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Strategy: DeploymentStrategy{
|
||||
Type: RecreateDeploymentStrategyType,
|
||||
},
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
original: &Deployment{
|
||||
Spec: DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Strategy: DeploymentStrategy{
|
||||
Type: RecreateDeploymentStrategyType,
|
||||
},
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
},
|
||||
},
|
||||
expected: &Deployment{
|
||||
Spec: DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Strategy: DeploymentStrategy{
|
||||
Type: RecreateDeploymentStrategyType,
|
||||
},
|
||||
Template: defaultTemplate,
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
original := test.original
|
||||
expected := test.expected
|
||||
obj2 := roundTrip(t, runtime.Object(original))
|
||||
got, ok := obj2.(*Deployment)
|
||||
if !ok {
|
||||
t.Errorf("unexpected object: %v", got)
|
||||
t.FailNow()
|
||||
}
|
||||
if !reflect.DeepEqual(got.Spec, expected.Spec) {
|
||||
t.Errorf("object mismatch!\nexpected:\n\t%+v\ngot:\n\t%+v", got.Spec, expected.Spec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDefaultReplicaSet(t *testing.T) {
|
||||
tests := []struct {
|
||||
rs *ReplicaSet
|
||||
expectLabels bool
|
||||
expectSelector bool
|
||||
}{
|
||||
{
|
||||
rs: &ReplicaSet{
|
||||
Spec: ReplicaSetSpec{
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectLabels: true,
|
||||
expectSelector: true,
|
||||
},
|
||||
{
|
||||
rs: &ReplicaSet{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
},
|
||||
},
|
||||
Spec: ReplicaSetSpec{
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectLabels: false,
|
||||
expectSelector: true,
|
||||
},
|
||||
{
|
||||
rs: &ReplicaSet{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
},
|
||||
},
|
||||
Spec: ReplicaSetSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"some": "other",
|
||||
},
|
||||
},
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectLabels: false,
|
||||
expectSelector: false,
|
||||
},
|
||||
{
|
||||
rs: &ReplicaSet{
|
||||
Spec: ReplicaSetSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"some": "other",
|
||||
},
|
||||
},
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectLabels: true,
|
||||
expectSelector: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
rs := test.rs
|
||||
obj2 := roundTrip(t, runtime.Object(rs))
|
||||
rs2, ok := obj2.(*ReplicaSet)
|
||||
if !ok {
|
||||
t.Errorf("unexpected object: %v", rs2)
|
||||
t.FailNow()
|
||||
}
|
||||
if test.expectSelector != reflect.DeepEqual(rs2.Spec.Selector.MatchLabels, rs2.Spec.Template.Labels) {
|
||||
if test.expectSelector {
|
||||
t.Errorf("expected: %v, got: %v", rs2.Spec.Template.Labels, rs2.Spec.Selector)
|
||||
} else {
|
||||
t.Errorf("unexpected equality: %v", rs.Spec.Selector)
|
||||
}
|
||||
}
|
||||
if test.expectLabels != reflect.DeepEqual(rs2.Labels, rs2.Spec.Template.Labels) {
|
||||
if test.expectLabels {
|
||||
t.Errorf("expected: %v, got: %v", rs2.Spec.Template.Labels, rs2.Labels)
|
||||
} else {
|
||||
t.Errorf("unexpected equality: %v", rs.Labels)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDefaultReplicaSetReplicas(t *testing.T) {
|
||||
tests := []struct {
|
||||
rs ReplicaSet
|
||||
expectReplicas int32
|
||||
}{
|
||||
{
|
||||
rs: ReplicaSet{
|
||||
Spec: ReplicaSetSpec{
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectReplicas: 1,
|
||||
},
|
||||
{
|
||||
rs: ReplicaSet{
|
||||
Spec: ReplicaSetSpec{
|
||||
Replicas: newInt32(0),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectReplicas: 0,
|
||||
},
|
||||
{
|
||||
rs: ReplicaSet{
|
||||
Spec: ReplicaSetSpec{
|
||||
Replicas: newInt32(3),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectReplicas: 3,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
rs := &test.rs
|
||||
obj2 := roundTrip(t, runtime.Object(rs))
|
||||
rs2, ok := obj2.(*ReplicaSet)
|
||||
if !ok {
|
||||
t.Errorf("unexpected object: %v", rs2)
|
||||
t.FailNow()
|
||||
}
|
||||
if rs2.Spec.Replicas == nil {
|
||||
t.Errorf("unexpected nil Replicas")
|
||||
} else if test.expectReplicas != *rs2.Spec.Replicas {
|
||||
t.Errorf("expected: %d replicas, got: %d", test.expectReplicas, *rs2.Spec.Replicas)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
|
||||
s := v1.PodSpec{}
|
||||
s.Containers = []v1.Container{
|
||||
{
|
||||
Resources: v1.ResourceRequirements{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceCPU: resource.MustParse("100m"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
rs := &ReplicaSet{
|
||||
Spec: ReplicaSetSpec{
|
||||
Replicas: newInt32(3),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
Spec: s,
|
||||
},
|
||||
},
|
||||
}
|
||||
output := roundTrip(t, runtime.Object(rs))
|
||||
rs2 := output.(*ReplicaSet)
|
||||
defaultRequest := rs2.Spec.Template.Spec.Containers[0].Resources.Requests
|
||||
requestValue := defaultRequest[v1.ResourceCPU]
|
||||
if requestValue.String() != "0" {
|
||||
t.Errorf("Expected 0 request value, got: %s", requestValue.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDefaultHorizontalPodAutoscalerMinReplicas(t *testing.T) {
|
||||
tests := []struct {
|
||||
hpa HorizontalPodAutoscaler
|
||||
expectReplicas int32
|
||||
}{
|
||||
{
|
||||
hpa: HorizontalPodAutoscaler{},
|
||||
expectReplicas: 1,
|
||||
},
|
||||
{
|
||||
hpa: HorizontalPodAutoscaler{
|
||||
Spec: HorizontalPodAutoscalerSpec{
|
||||
MinReplicas: newInt32(3),
|
||||
},
|
||||
},
|
||||
expectReplicas: 3,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
hpa := &test.hpa
|
||||
obj2 := roundTrip(t, runtime.Object(hpa))
|
||||
hpa2, ok := obj2.(*HorizontalPodAutoscaler)
|
||||
if !ok {
|
||||
t.Errorf("unexpected object: %v", hpa2)
|
||||
t.FailNow()
|
||||
}
|
||||
if hpa2.Spec.MinReplicas == nil {
|
||||
t.Errorf("unexpected nil MinReplicas")
|
||||
} else if test.expectReplicas != *hpa2.Spec.MinReplicas {
|
||||
t.Errorf("expected: %d MinReplicas, got: %d", test.expectReplicas, *hpa2.Spec.MinReplicas)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetDefaultHorizontalPodAutoscalerCpuUtilization(t *testing.T) {
|
||||
tests := []struct {
|
||||
hpa HorizontalPodAutoscaler
|
||||
expectUtilization int32
|
||||
}{
|
||||
{
|
||||
hpa: HorizontalPodAutoscaler{},
|
||||
expectUtilization: 80,
|
||||
},
|
||||
{
|
||||
hpa: HorizontalPodAutoscaler{
|
||||
Spec: HorizontalPodAutoscalerSpec{
|
||||
CPUUtilization: &CPUTargetUtilization{
|
||||
TargetPercentage: int32(50),
|
||||
},
|
||||
},
|
||||
},
|
||||
expectUtilization: 50,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
hpa := &test.hpa
|
||||
obj2 := roundTrip(t, runtime.Object(hpa))
|
||||
hpa2, ok := obj2.(*HorizontalPodAutoscaler)
|
||||
if !ok {
|
||||
t.Errorf("unexpected object: %v", hpa2)
|
||||
t.FailNow()
|
||||
}
|
||||
if hpa2.Spec.CPUUtilization == nil {
|
||||
t.Errorf("unexpected nil CPUUtilization")
|
||||
} else if test.expectUtilization != hpa2.Spec.CPUUtilization.TargetPercentage {
|
||||
t.Errorf("expected: %d CPUUtilization, got: %d", test.expectUtilization, hpa2.Spec.CPUUtilization.TargetPercentage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
|
||||
data, err := runtime.Encode(api.Codecs.LegacyCodec(SchemeGroupVersion), obj)
|
||||
if err != nil {
|
||||
t.Errorf("%v\n %#v", err, obj)
|
||||
return nil
|
||||
}
|
||||
obj2, err := runtime.Decode(api.Codecs.UniversalDecoder(), data)
|
||||
if err != nil {
|
||||
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
|
||||
return nil
|
||||
}
|
||||
obj3 := reflect.New(reflect.TypeOf(obj).Elem()).Interface().(runtime.Object)
|
||||
err = api.Scheme.Convert(obj2, obj3, nil)
|
||||
if err != nil {
|
||||
t.Errorf("%v\nSource: %#v", err, obj2)
|
||||
return nil
|
||||
}
|
||||
return obj3
|
||||
}
|
||||
|
||||
func newInt32(val int32) *int32 {
|
||||
p := new(int32)
|
||||
*p = val
|
||||
return p
|
||||
}
|
||||
|
||||
func newString(val string) *string {
|
||||
p := new(string)
|
||||
*p = val
|
||||
return p
|
||||
}
|
||||
|
||||
func newBool(val bool) *bool {
|
||||
b := new(bool)
|
||||
*b = val
|
||||
return b
|
||||
}
|
24
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/doc.go
generated
vendored
Normal file
24
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/extensions
|
||||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/autoscaling
|
||||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/batch
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
|
||||
package v1beta1 // import "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
12754
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/generated.pb.go
generated
vendored
Normal file
12754
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/generated.pb.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1029
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/generated.proto
generated
vendored
Normal file
1029
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/generated.proto
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
74
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/register.go
generated
vendored
Normal file
74
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/register.go
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
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 v1beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
)
|
||||
|
||||
// GroupName is the group name use in this package
|
||||
const GroupName = "extensions"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}
|
||||
|
||||
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
|
||||
var (
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addDefaultingFuncs, addConversionFuncs)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to api.Scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&Deployment{},
|
||||
&DeploymentList{},
|
||||
&DeploymentRollback{},
|
||||
&HorizontalPodAutoscaler{},
|
||||
&HorizontalPodAutoscalerList{},
|
||||
&ReplicationControllerDummy{},
|
||||
&Scale{},
|
||||
&ThirdPartyResource{},
|
||||
&ThirdPartyResourceList{},
|
||||
&DaemonSetList{},
|
||||
&DaemonSet{},
|
||||
&ThirdPartyResourceData{},
|
||||
&ThirdPartyResourceDataList{},
|
||||
&Ingress{},
|
||||
&IngressList{},
|
||||
&v1.ListOptions{},
|
||||
&v1.DeleteOptions{},
|
||||
&metav1.ExportOptions{},
|
||||
&metav1.GetOptions{},
|
||||
&ReplicaSet{},
|
||||
&ReplicaSetList{},
|
||||
&PodSecurityPolicy{},
|
||||
&PodSecurityPolicyList{},
|
||||
&NetworkPolicy{},
|
||||
&NetworkPolicyList{},
|
||||
)
|
||||
// Add the watch version that applies
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
}
|
22946
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/types.generated.go
generated
vendored
Normal file
22946
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/types.generated.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1225
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/types.go
generated
vendored
Normal file
1225
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/types.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
669
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/types_swagger_doc_generated.go
generated
vendored
Normal file
669
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/types_swagger_doc_generated.go
generated
vendored
Normal file
|
@ -0,0 +1,669 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
// This file contains a collection of methods that can be used from go-restful to
|
||||
// generate Swagger API documentation for its models. Please read this PR for more
|
||||
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
|
||||
//
|
||||
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
|
||||
// they are on one line! For multiple line or blocks that you want to ignore use ---.
|
||||
// Any context after a --- is ignored.
|
||||
//
|
||||
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
|
||||
|
||||
// AUTO-GENERATED FUNCTIONS START HERE
|
||||
var map_APIVersion = map[string]string{
|
||||
"": "An APIVersion represents a single concrete version of an object model.",
|
||||
"name": "Name of this version (e.g. 'v1').",
|
||||
}
|
||||
|
||||
func (APIVersion) SwaggerDoc() map[string]string {
|
||||
return map_APIVersion
|
||||
}
|
||||
|
||||
var map_CPUTargetUtilization = map[string]string{
|
||||
"targetPercentage": "fraction of the requested CPU that should be utilized/used, e.g. 70 means that 70% of the requested CPU should be in use.",
|
||||
}
|
||||
|
||||
func (CPUTargetUtilization) SwaggerDoc() map[string]string {
|
||||
return map_CPUTargetUtilization
|
||||
}
|
||||
|
||||
var map_CustomMetricCurrentStatus = map[string]string{
|
||||
"name": "Custom Metric name.",
|
||||
"value": "Custom Metric value (average).",
|
||||
}
|
||||
|
||||
func (CustomMetricCurrentStatus) SwaggerDoc() map[string]string {
|
||||
return map_CustomMetricCurrentStatus
|
||||
}
|
||||
|
||||
var map_CustomMetricTarget = map[string]string{
|
||||
"": "Alpha-level support for Custom Metrics in HPA (as annotations).",
|
||||
"name": "Custom Metric name.",
|
||||
"value": "Custom Metric value (average).",
|
||||
}
|
||||
|
||||
func (CustomMetricTarget) SwaggerDoc() map[string]string {
|
||||
return map_CustomMetricTarget
|
||||
}
|
||||
|
||||
var map_DaemonSet = map[string]string{
|
||||
"": "DaemonSet represents the configuration of a daemon set.",
|
||||
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"spec": "Spec defines the desired behavior of this daemon set. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
|
||||
"status": "Status is the current status of this daemon set. This data may be out of date by some window of time. Populated by the system. Read-only. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
|
||||
}
|
||||
|
||||
func (DaemonSet) SwaggerDoc() map[string]string {
|
||||
return map_DaemonSet
|
||||
}
|
||||
|
||||
var map_DaemonSetList = map[string]string{
|
||||
"": "DaemonSetList is a collection of daemon sets.",
|
||||
"metadata": "Standard list metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"items": "Items is a list of daemon sets.",
|
||||
}
|
||||
|
||||
func (DaemonSetList) SwaggerDoc() map[string]string {
|
||||
return map_DaemonSetList
|
||||
}
|
||||
|
||||
var map_DaemonSetSpec = map[string]string{
|
||||
"": "DaemonSetSpec is the specification of a daemon set.",
|
||||
"selector": "Selector is a label query over pods that are managed by the daemon set. Must match in order to be controlled. If empty, defaulted to labels on Pod template. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors",
|
||||
"template": "Template is the object that describes the pod that will be created. The DaemonSet will create exactly one copy of this pod on every node that matches the template's node selector (or on every node if no node selector is specified). More info: http://kubernetes.io/docs/user-guide/replication-controller#pod-template",
|
||||
}
|
||||
|
||||
func (DaemonSetSpec) SwaggerDoc() map[string]string {
|
||||
return map_DaemonSetSpec
|
||||
}
|
||||
|
||||
var map_DaemonSetStatus = map[string]string{
|
||||
"": "DaemonSetStatus represents the current status of a daemon set.",
|
||||
"currentNumberScheduled": "CurrentNumberScheduled is the number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod. More info: http://releases.k8s.io/HEAD/docs/admin/daemons.md",
|
||||
"numberMisscheduled": "NumberMisscheduled is the number of nodes that are running the daemon pod, but are not supposed to run the daemon pod. More info: http://releases.k8s.io/HEAD/docs/admin/daemons.md",
|
||||
"desiredNumberScheduled": "DesiredNumberScheduled is the total number of nodes that should be running the daemon pod (including nodes correctly running the daemon pod). More info: http://releases.k8s.io/HEAD/docs/admin/daemons.md",
|
||||
"numberReady": "NumberReady is the number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready.",
|
||||
"observedGeneration": "ObservedGeneration is the most recent generation observed by the daemon set controller.",
|
||||
}
|
||||
|
||||
func (DaemonSetStatus) SwaggerDoc() map[string]string {
|
||||
return map_DaemonSetStatus
|
||||
}
|
||||
|
||||
var map_Deployment = map[string]string{
|
||||
"": "Deployment enables declarative updates for Pods and ReplicaSets.",
|
||||
"metadata": "Standard object metadata.",
|
||||
"spec": "Specification of the desired behavior of the Deployment.",
|
||||
"status": "Most recently observed status of the Deployment.",
|
||||
}
|
||||
|
||||
func (Deployment) SwaggerDoc() map[string]string {
|
||||
return map_Deployment
|
||||
}
|
||||
|
||||
var map_DeploymentCondition = map[string]string{
|
||||
"": "DeploymentCondition describes the state of a deployment at a certain point.",
|
||||
"type": "Type of deployment condition.",
|
||||
"status": "Status of the condition, one of True, False, Unknown.",
|
||||
"lastUpdateTime": "The last time this condition was updated.",
|
||||
"lastTransitionTime": "Last time the condition transitioned from one status to another.",
|
||||
"reason": "The reason for the condition's last transition.",
|
||||
"message": "A human readable message indicating details about the transition.",
|
||||
}
|
||||
|
||||
func (DeploymentCondition) SwaggerDoc() map[string]string {
|
||||
return map_DeploymentCondition
|
||||
}
|
||||
|
||||
var map_DeploymentList = map[string]string{
|
||||
"": "DeploymentList is a list of Deployments.",
|
||||
"metadata": "Standard list metadata.",
|
||||
"items": "Items is the list of Deployments.",
|
||||
}
|
||||
|
||||
func (DeploymentList) SwaggerDoc() map[string]string {
|
||||
return map_DeploymentList
|
||||
}
|
||||
|
||||
var map_DeploymentRollback = map[string]string{
|
||||
"": "DeploymentRollback stores the information required to rollback a deployment.",
|
||||
"name": "Required: This must match the Name of a deployment.",
|
||||
"updatedAnnotations": "The annotations to be updated to a deployment",
|
||||
"rollbackTo": "The config of this deployment rollback.",
|
||||
}
|
||||
|
||||
func (DeploymentRollback) SwaggerDoc() map[string]string {
|
||||
return map_DeploymentRollback
|
||||
}
|
||||
|
||||
var map_DeploymentSpec = map[string]string{
|
||||
"": "DeploymentSpec is the specification of the desired behavior of the Deployment.",
|
||||
"replicas": "Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.",
|
||||
"selector": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment.",
|
||||
"template": "Template describes the pods that will be created.",
|
||||
"strategy": "The deployment strategy to use to replace existing pods with new ones.",
|
||||
"minReadySeconds": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
|
||||
"revisionHistoryLimit": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified.",
|
||||
"paused": "Indicates that the deployment is paused and will not be processed by the deployment controller.",
|
||||
"rollbackTo": "The config this deployment is rolling back to. Will be cleared after rollback is done.",
|
||||
"progressDeadlineSeconds": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Once autoRollback is implemented, the deployment controller will automatically rollback failed deployments. Note that progress will not be estimated during the time a deployment is paused. This is not set by default.",
|
||||
}
|
||||
|
||||
func (DeploymentSpec) SwaggerDoc() map[string]string {
|
||||
return map_DeploymentSpec
|
||||
}
|
||||
|
||||
var map_DeploymentStatus = map[string]string{
|
||||
"": "DeploymentStatus is the most recently observed status of the Deployment.",
|
||||
"observedGeneration": "The generation observed by the deployment controller.",
|
||||
"replicas": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).",
|
||||
"updatedReplicas": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.",
|
||||
"readyReplicas": "Total number of ready pods targeted by this deployment.",
|
||||
"availableReplicas": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.",
|
||||
"unavailableReplicas": "Total number of unavailable pods targeted by this deployment.",
|
||||
"conditions": "Represents the latest available observations of a deployment's current state.",
|
||||
}
|
||||
|
||||
func (DeploymentStatus) SwaggerDoc() map[string]string {
|
||||
return map_DeploymentStatus
|
||||
}
|
||||
|
||||
var map_DeploymentStrategy = map[string]string{
|
||||
"": "DeploymentStrategy describes how to replace existing pods with new ones.",
|
||||
"type": "Type of deployment. Can be \"Recreate\" or \"RollingUpdate\". Default is RollingUpdate.",
|
||||
"rollingUpdate": "Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate.",
|
||||
}
|
||||
|
||||
func (DeploymentStrategy) SwaggerDoc() map[string]string {
|
||||
return map_DeploymentStrategy
|
||||
}
|
||||
|
||||
var map_FSGroupStrategyOptions = map[string]string{
|
||||
"": "FSGroupStrategyOptions defines the strategy type and options used to create the strategy.",
|
||||
"rule": "Rule is the strategy that will dictate what FSGroup is used in the SecurityContext.",
|
||||
"ranges": "Ranges are the allowed ranges of fs groups. If you would like to force a single fs group then supply a single range with the same start and end.",
|
||||
}
|
||||
|
||||
func (FSGroupStrategyOptions) SwaggerDoc() map[string]string {
|
||||
return map_FSGroupStrategyOptions
|
||||
}
|
||||
|
||||
var map_HTTPIngressPath = map[string]string{
|
||||
"": "HTTPIngressPath associates a path regex with a backend. Incoming urls matching the path are forwarded to the backend.",
|
||||
"path": "Path is an extended POSIX regex as defined by IEEE Std 1003.1, (i.e this follows the egrep/unix syntax, not the perl syntax) matched against the path of an incoming request. Currently it can contain characters disallowed from the conventional \"path\" part of a URL as defined by RFC 3986. Paths must begin with a '/'. If unspecified, the path defaults to a catch all sending traffic to the backend.",
|
||||
"backend": "Backend defines the referenced service endpoint to which the traffic will be forwarded to.",
|
||||
}
|
||||
|
||||
func (HTTPIngressPath) SwaggerDoc() map[string]string {
|
||||
return map_HTTPIngressPath
|
||||
}
|
||||
|
||||
var map_HTTPIngressRuleValue = map[string]string{
|
||||
"": "HTTPIngressRuleValue is a list of http selectors pointing to backends. In the example: http://<host>/<path>?<searchpart> -> backend where where parts of the url correspond to RFC 3986, this resource will be used to match against everything after the last '/' and before the first '?' or '#'.",
|
||||
"paths": "A collection of paths that map requests to backends.",
|
||||
}
|
||||
|
||||
func (HTTPIngressRuleValue) SwaggerDoc() map[string]string {
|
||||
return map_HTTPIngressRuleValue
|
||||
}
|
||||
|
||||
var map_HorizontalPodAutoscaler = map[string]string{
|
||||
"": "configuration of a horizontal pod autoscaler.",
|
||||
"metadata": "Standard object metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"spec": "behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.",
|
||||
"status": "current information about the autoscaler.",
|
||||
}
|
||||
|
||||
func (HorizontalPodAutoscaler) SwaggerDoc() map[string]string {
|
||||
return map_HorizontalPodAutoscaler
|
||||
}
|
||||
|
||||
var map_HorizontalPodAutoscalerList = map[string]string{
|
||||
"": "list of horizontal pod autoscaler objects.",
|
||||
"metadata": "Standard list metadata.",
|
||||
"items": "list of horizontal pod autoscaler objects.",
|
||||
}
|
||||
|
||||
func (HorizontalPodAutoscalerList) SwaggerDoc() map[string]string {
|
||||
return map_HorizontalPodAutoscalerList
|
||||
}
|
||||
|
||||
var map_HorizontalPodAutoscalerSpec = map[string]string{
|
||||
"": "specification of a horizontal pod autoscaler.",
|
||||
"scaleRef": "reference to Scale subresource; horizontal pod autoscaler will learn the current resource consumption from its status, and will set the desired number of pods by modifying its spec.",
|
||||
"minReplicas": "lower limit for the number of pods that can be set by the autoscaler, default 1.",
|
||||
"maxReplicas": "upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas.",
|
||||
"cpuUtilization": "target average CPU utilization (represented as a percentage of requested CPU) over all the pods; if not specified it defaults to the target CPU utilization at 80% of the requested resources.",
|
||||
}
|
||||
|
||||
func (HorizontalPodAutoscalerSpec) SwaggerDoc() map[string]string {
|
||||
return map_HorizontalPodAutoscalerSpec
|
||||
}
|
||||
|
||||
var map_HorizontalPodAutoscalerStatus = map[string]string{
|
||||
"": "current status of a horizontal pod autoscaler",
|
||||
"observedGeneration": "most recent generation observed by this autoscaler.",
|
||||
"lastScaleTime": "last time the HorizontalPodAutoscaler scaled the number of pods; used by the autoscaler to control how often the number of pods is changed.",
|
||||
"currentReplicas": "current number of replicas of pods managed by this autoscaler.",
|
||||
"desiredReplicas": "desired number of replicas of pods managed by this autoscaler.",
|
||||
"currentCPUUtilizationPercentage": "current average CPU utilization over all pods, represented as a percentage of requested CPU, e.g. 70 means that an average pod is using now 70% of its requested CPU.",
|
||||
}
|
||||
|
||||
func (HorizontalPodAutoscalerStatus) SwaggerDoc() map[string]string {
|
||||
return map_HorizontalPodAutoscalerStatus
|
||||
}
|
||||
|
||||
var map_HostPortRange = map[string]string{
|
||||
"": "Host Port Range defines a range of host ports that will be enabled by a policy for pods to use. It requires both the start and end to be defined.",
|
||||
"min": "min is the start of the range, inclusive.",
|
||||
"max": "max is the end of the range, inclusive.",
|
||||
}
|
||||
|
||||
func (HostPortRange) SwaggerDoc() map[string]string {
|
||||
return map_HostPortRange
|
||||
}
|
||||
|
||||
var map_IDRange = map[string]string{
|
||||
"": "ID Range provides a min/max of an allowed range of IDs.",
|
||||
"min": "Min is the start of the range, inclusive.",
|
||||
"max": "Max is the end of the range, inclusive.",
|
||||
}
|
||||
|
||||
func (IDRange) SwaggerDoc() map[string]string {
|
||||
return map_IDRange
|
||||
}
|
||||
|
||||
var map_Ingress = map[string]string{
|
||||
"": "Ingress is a collection of rules that allow inbound connections to reach the endpoints defined by a backend. An Ingress can be configured to give services externally-reachable urls, load balance traffic, terminate SSL, offer name based virtual hosting etc.",
|
||||
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"spec": "Spec is the desired state of the Ingress. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
|
||||
"status": "Status is the current state of the Ingress. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
|
||||
}
|
||||
|
||||
func (Ingress) SwaggerDoc() map[string]string {
|
||||
return map_Ingress
|
||||
}
|
||||
|
||||
var map_IngressBackend = map[string]string{
|
||||
"": "IngressBackend describes all endpoints for a given service and port.",
|
||||
"serviceName": "Specifies the name of the referenced service.",
|
||||
"servicePort": "Specifies the port of the referenced service.",
|
||||
}
|
||||
|
||||
func (IngressBackend) SwaggerDoc() map[string]string {
|
||||
return map_IngressBackend
|
||||
}
|
||||
|
||||
var map_IngressList = map[string]string{
|
||||
"": "IngressList is a collection of Ingress.",
|
||||
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"items": "Items is the list of Ingress.",
|
||||
}
|
||||
|
||||
func (IngressList) SwaggerDoc() map[string]string {
|
||||
return map_IngressList
|
||||
}
|
||||
|
||||
var map_IngressRule = map[string]string{
|
||||
"": "IngressRule represents the rules mapping the paths under a specified host to the related backend services. Incoming requests are first evaluated for a host match, then routed to the backend associated with the matching IngressRuleValue.",
|
||||
"host": "Host is the fully qualified domain name of a network host, as defined by RFC 3986. Note the following deviations from the \"host\" part of the URI as defined in the RFC: 1. IPs are not allowed. Currently an IngressRuleValue can only apply to the\n\t IP in the Spec of the parent Ingress.\n2. The `:` delimiter is not respected because ports are not allowed.\n\t Currently the port of an Ingress is implicitly :80 for http and\n\t :443 for https.\nBoth these may change in the future. Incoming requests are matched against the host before the IngressRuleValue. If the host is unspecified, the Ingress routes all traffic based on the specified IngressRuleValue.",
|
||||
}
|
||||
|
||||
func (IngressRule) SwaggerDoc() map[string]string {
|
||||
return map_IngressRule
|
||||
}
|
||||
|
||||
var map_IngressRuleValue = map[string]string{
|
||||
"": "IngressRuleValue represents a rule to apply against incoming requests. If the rule is satisfied, the request is routed to the specified backend. Currently mixing different types of rules in a single Ingress is disallowed, so exactly one of the following must be set.",
|
||||
}
|
||||
|
||||
func (IngressRuleValue) SwaggerDoc() map[string]string {
|
||||
return map_IngressRuleValue
|
||||
}
|
||||
|
||||
var map_IngressSpec = map[string]string{
|
||||
"": "IngressSpec describes the Ingress the user wishes to exist.",
|
||||
"backend": "A default backend capable of servicing requests that don't match any rule. At least one of 'backend' or 'rules' must be specified. This field is optional to allow the loadbalancer controller or defaulting logic to specify a global default.",
|
||||
"tls": "TLS configuration. Currently the Ingress only supports a single TLS port, 443. If multiple members of this list specify different hosts, they will be multiplexed on the same port according to the hostname specified through the SNI TLS extension, if the ingress controller fulfilling the ingress supports SNI.",
|
||||
"rules": "A list of host rules used to configure the Ingress. If unspecified, or no rule matches, all traffic is sent to the default backend.",
|
||||
}
|
||||
|
||||
func (IngressSpec) SwaggerDoc() map[string]string {
|
||||
return map_IngressSpec
|
||||
}
|
||||
|
||||
var map_IngressStatus = map[string]string{
|
||||
"": "IngressStatus describe the current state of the Ingress.",
|
||||
"loadBalancer": "LoadBalancer contains the current status of the load-balancer.",
|
||||
}
|
||||
|
||||
func (IngressStatus) SwaggerDoc() map[string]string {
|
||||
return map_IngressStatus
|
||||
}
|
||||
|
||||
var map_IngressTLS = map[string]string{
|
||||
"": "IngressTLS describes the transport layer security associated with an Ingress.",
|
||||
"hosts": "Hosts are a list of hosts included in the TLS certificate. The values in this list must match the name/s used in the tlsSecret. Defaults to the wildcard host setting for the loadbalancer controller fulfilling this Ingress, if left unspecified.",
|
||||
"secretName": "SecretName is the name of the secret used to terminate SSL traffic on 443. Field is left optional to allow SSL routing based on SNI hostname alone. If the SNI host in a listener conflicts with the \"Host\" header field used by an IngressRule, the SNI host is used for termination and value of the Host header is used for routing.",
|
||||
}
|
||||
|
||||
func (IngressTLS) SwaggerDoc() map[string]string {
|
||||
return map_IngressTLS
|
||||
}
|
||||
|
||||
var map_NetworkPolicy = map[string]string{
|
||||
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"spec": "Specification of the desired behavior for this NetworkPolicy.",
|
||||
}
|
||||
|
||||
func (NetworkPolicy) SwaggerDoc() map[string]string {
|
||||
return map_NetworkPolicy
|
||||
}
|
||||
|
||||
var map_NetworkPolicyIngressRule = map[string]string{
|
||||
"": "This NetworkPolicyIngressRule matches traffic if and only if the traffic matches both ports AND from.",
|
||||
"ports": "List of ports which should be made accessible on the pods selected for this rule. Each item in this list is combined using a logical OR. If this field is not provided, this rule matches all ports (traffic not restricted by port). If this field is empty, this rule matches no ports (no traffic matches). If this field is present and contains at least one item, then this rule allows traffic only if the traffic matches at least one port in the list.",
|
||||
"from": "List of sources which should be able to access the pods selected for this rule. Items in this list are combined using a logical OR operation. If this field is not provided, this rule matches all sources (traffic not restricted by source). If this field is empty, this rule matches no sources (no traffic matches). If this field is present and contains at least on item, this rule allows traffic only if the traffic matches at least one item in the from list.",
|
||||
}
|
||||
|
||||
func (NetworkPolicyIngressRule) SwaggerDoc() map[string]string {
|
||||
return map_NetworkPolicyIngressRule
|
||||
}
|
||||
|
||||
var map_NetworkPolicyList = map[string]string{
|
||||
"": "Network Policy List is a list of NetworkPolicy objects.",
|
||||
"metadata": "Standard list metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"items": "Items is a list of schema objects.",
|
||||
}
|
||||
|
||||
func (NetworkPolicyList) SwaggerDoc() map[string]string {
|
||||
return map_NetworkPolicyList
|
||||
}
|
||||
|
||||
var map_NetworkPolicyPeer = map[string]string{
|
||||
"podSelector": "This is a label selector which selects Pods in this namespace. This field follows standard label selector semantics. If not provided, this selector selects no pods. If present but empty, this selector selects all pods in this namespace.",
|
||||
"namespaceSelector": "Selects Namespaces using cluster scoped-labels. This matches all pods in all namespaces selected by this label selector. This field follows standard label selector semantics. If omitted, this selector selects no namespaces. If present but empty, this selector selects all namespaces.",
|
||||
}
|
||||
|
||||
func (NetworkPolicyPeer) SwaggerDoc() map[string]string {
|
||||
return map_NetworkPolicyPeer
|
||||
}
|
||||
|
||||
var map_NetworkPolicyPort = map[string]string{
|
||||
"protocol": "Optional. The protocol (TCP or UDP) which traffic must match. If not specified, this field defaults to TCP.",
|
||||
"port": "If specified, the port on the given protocol. This can either be a numerical or named port on a pod. If this field is not provided, this matches all port names and numbers. If present, only traffic on the specified protocol AND port will be matched.",
|
||||
}
|
||||
|
||||
func (NetworkPolicyPort) SwaggerDoc() map[string]string {
|
||||
return map_NetworkPolicyPort
|
||||
}
|
||||
|
||||
var map_NetworkPolicySpec = map[string]string{
|
||||
"podSelector": "Selects the pods to which this NetworkPolicy object applies. The array of ingress rules is applied to any pods selected by this field. Multiple network policies can select the same set of pods. In this case, the ingress rules for each are combined additively. This field is NOT optional and follows standard label selector semantics. An empty podSelector matches all pods in this namespace.",
|
||||
"ingress": "List of ingress rules to be applied to the selected pods. Traffic is allowed to a pod if namespace.networkPolicy.ingress.isolation is undefined and cluster policy allows it, OR if the traffic source is the pod's local node, OR if the traffic matches at least one ingress rule across all of the NetworkPolicy objects whose podSelector matches the pod. If this field is empty then this NetworkPolicy does not affect ingress isolation. If this field is present and contains at least one rule, this policy allows any traffic which matches at least one of the ingress rules in this list.",
|
||||
}
|
||||
|
||||
func (NetworkPolicySpec) SwaggerDoc() map[string]string {
|
||||
return map_NetworkPolicySpec
|
||||
}
|
||||
|
||||
var map_PodSecurityPolicy = map[string]string{
|
||||
"": "Pod Security Policy governs the ability to make requests that affect the Security Context that will be applied to a pod and container.",
|
||||
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"spec": "spec defines the policy enforced.",
|
||||
}
|
||||
|
||||
func (PodSecurityPolicy) SwaggerDoc() map[string]string {
|
||||
return map_PodSecurityPolicy
|
||||
}
|
||||
|
||||
var map_PodSecurityPolicyList = map[string]string{
|
||||
"": "Pod Security Policy List is a list of PodSecurityPolicy objects.",
|
||||
"metadata": "Standard list metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"items": "Items is a list of schema objects.",
|
||||
}
|
||||
|
||||
func (PodSecurityPolicyList) SwaggerDoc() map[string]string {
|
||||
return map_PodSecurityPolicyList
|
||||
}
|
||||
|
||||
var map_PodSecurityPolicySpec = map[string]string{
|
||||
"": "Pod Security Policy Spec defines the policy enforced.",
|
||||
"privileged": "privileged determines if a pod can request to be run as privileged.",
|
||||
"defaultAddCapabilities": "DefaultAddCapabilities is the default set of capabilities that will be added to the container unless the pod spec specifically drops the capability. You may not list a capabiility in both DefaultAddCapabilities and RequiredDropCapabilities.",
|
||||
"requiredDropCapabilities": "RequiredDropCapabilities are the capabilities that will be dropped from the container. These are required to be dropped and cannot be added.",
|
||||
"allowedCapabilities": "AllowedCapabilities is a list of capabilities that can be requested to add to the container. Capabilities in this field may be added at the pod author's discretion. You must not list a capability in both AllowedCapabilities and RequiredDropCapabilities.",
|
||||
"volumes": "volumes is a white list of allowed volume plugins. Empty indicates that all plugins may be used.",
|
||||
"hostNetwork": "hostNetwork determines if the policy allows the use of HostNetwork in the pod spec.",
|
||||
"hostPorts": "hostPorts determines which host port ranges are allowed to be exposed.",
|
||||
"hostPID": "hostPID determines if the policy allows the use of HostPID in the pod spec.",
|
||||
"hostIPC": "hostIPC determines if the policy allows the use of HostIPC in the pod spec.",
|
||||
"seLinux": "seLinux is the strategy that will dictate the allowable labels that may be set.",
|
||||
"runAsUser": "runAsUser is the strategy that will dictate the allowable RunAsUser values that may be set.",
|
||||
"supplementalGroups": "SupplementalGroups is the strategy that will dictate what supplemental groups are used by the SecurityContext.",
|
||||
"fsGroup": "FSGroup is the strategy that will dictate what fs group is used by the SecurityContext.",
|
||||
"readOnlyRootFilesystem": "ReadOnlyRootFilesystem when set to true will force containers to run with a read only root file system. If the container specifically requests to run with a non-read only root file system the PSP should deny the pod. If set to false the container may run with a read only root file system if it wishes but it will not be forced to.",
|
||||
}
|
||||
|
||||
func (PodSecurityPolicySpec) SwaggerDoc() map[string]string {
|
||||
return map_PodSecurityPolicySpec
|
||||
}
|
||||
|
||||
var map_ReplicaSet = map[string]string{
|
||||
"": "ReplicaSet represents the configuration of a ReplicaSet.",
|
||||
"metadata": "If the Labels of a ReplicaSet are empty, they are defaulted to be the same as the Pod(s) that the ReplicaSet manages. Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"spec": "Spec defines the specification of the desired behavior of the ReplicaSet. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
|
||||
"status": "Status is the most recently observed status of the ReplicaSet. This data may be out of date by some window of time. Populated by the system. Read-only. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status",
|
||||
}
|
||||
|
||||
func (ReplicaSet) SwaggerDoc() map[string]string {
|
||||
return map_ReplicaSet
|
||||
}
|
||||
|
||||
var map_ReplicaSetCondition = map[string]string{
|
||||
"": "ReplicaSetCondition describes the state of a replica set at a certain point.",
|
||||
"type": "Type of replica set condition.",
|
||||
"status": "Status of the condition, one of True, False, Unknown.",
|
||||
"lastTransitionTime": "The last time the condition transitioned from one status to another.",
|
||||
"reason": "The reason for the condition's last transition.",
|
||||
"message": "A human readable message indicating details about the transition.",
|
||||
}
|
||||
|
||||
func (ReplicaSetCondition) SwaggerDoc() map[string]string {
|
||||
return map_ReplicaSetCondition
|
||||
}
|
||||
|
||||
var map_ReplicaSetList = map[string]string{
|
||||
"": "ReplicaSetList is a collection of ReplicaSets.",
|
||||
"metadata": "Standard list metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds",
|
||||
"items": "List of ReplicaSets. More info: http://kubernetes.io/docs/user-guide/replication-controller",
|
||||
}
|
||||
|
||||
func (ReplicaSetList) SwaggerDoc() map[string]string {
|
||||
return map_ReplicaSetList
|
||||
}
|
||||
|
||||
var map_ReplicaSetSpec = map[string]string{
|
||||
"": "ReplicaSetSpec is the specification of a ReplicaSet.",
|
||||
"replicas": "Replicas is the number of desired replicas. This is a pointer to distinguish between explicit zero and unspecified. Defaults to 1. More info: http://kubernetes.io/docs/user-guide/replication-controller#what-is-a-replication-controller",
|
||||
"minReadySeconds": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
|
||||
"selector": "Selector is a label query over pods that should match the replica count. If the selector is empty, it is defaulted to the labels present on the pod template. Label keys and values that must match in order to be controlled by this replica set. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors",
|
||||
"template": "Template is the object that describes the pod that will be created if insufficient replicas are detected. More info: http://kubernetes.io/docs/user-guide/replication-controller#pod-template",
|
||||
}
|
||||
|
||||
func (ReplicaSetSpec) SwaggerDoc() map[string]string {
|
||||
return map_ReplicaSetSpec
|
||||
}
|
||||
|
||||
var map_ReplicaSetStatus = map[string]string{
|
||||
"": "ReplicaSetStatus represents the current status of a ReplicaSet.",
|
||||
"replicas": "Replicas is the most recently oberved number of replicas. More info: http://kubernetes.io/docs/user-guide/replication-controller#what-is-a-replication-controller",
|
||||
"fullyLabeledReplicas": "The number of pods that have labels matching the labels of the pod template of the replicaset.",
|
||||
"readyReplicas": "The number of ready replicas for this replica set.",
|
||||
"availableReplicas": "The number of available replicas (ready for at least minReadySeconds) for this replica set.",
|
||||
"observedGeneration": "ObservedGeneration reflects the generation of the most recently observed ReplicaSet.",
|
||||
"conditions": "Represents the latest available observations of a replica set's current state.",
|
||||
}
|
||||
|
||||
func (ReplicaSetStatus) SwaggerDoc() map[string]string {
|
||||
return map_ReplicaSetStatus
|
||||
}
|
||||
|
||||
var map_ReplicationControllerDummy = map[string]string{
|
||||
"": "Dummy definition",
|
||||
}
|
||||
|
||||
func (ReplicationControllerDummy) SwaggerDoc() map[string]string {
|
||||
return map_ReplicationControllerDummy
|
||||
}
|
||||
|
||||
var map_RollbackConfig = map[string]string{
|
||||
"revision": "The revision to rollback to. If set to 0, rollbck to the last revision.",
|
||||
}
|
||||
|
||||
func (RollbackConfig) SwaggerDoc() map[string]string {
|
||||
return map_RollbackConfig
|
||||
}
|
||||
|
||||
var map_RollingUpdateDeployment = map[string]string{
|
||||
"": "Spec to control the desired behavior of rolling update.",
|
||||
"maxUnavailable": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. By default, a fixed value of 1 is used. Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old RC can be scaled down further, followed by scaling up the new RC, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods.",
|
||||
"maxSurge": "The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. By default, a value of 1 is used. Example: when this is set to 30%, the new RC can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new RC can be scaled up further, ensuring that total number of pods running at any time during the update is atmost 130% of desired pods.",
|
||||
}
|
||||
|
||||
func (RollingUpdateDeployment) SwaggerDoc() map[string]string {
|
||||
return map_RollingUpdateDeployment
|
||||
}
|
||||
|
||||
var map_RunAsUserStrategyOptions = map[string]string{
|
||||
"": "Run A sUser Strategy Options defines the strategy type and any options used to create the strategy.",
|
||||
"rule": "Rule is the strategy that will dictate the allowable RunAsUser values that may be set.",
|
||||
"ranges": "Ranges are the allowed ranges of uids that may be used.",
|
||||
}
|
||||
|
||||
func (RunAsUserStrategyOptions) SwaggerDoc() map[string]string {
|
||||
return map_RunAsUserStrategyOptions
|
||||
}
|
||||
|
||||
var map_SELinuxStrategyOptions = map[string]string{
|
||||
"": "SELinux Strategy Options defines the strategy type and any options used to create the strategy.",
|
||||
"rule": "type is the strategy that will dictate the allowable labels that may be set.",
|
||||
"seLinuxOptions": "seLinuxOptions required to run as; required for MustRunAs More info: http://releases.k8s.io/HEAD/docs/design/security_context.md#security-context",
|
||||
}
|
||||
|
||||
func (SELinuxStrategyOptions) SwaggerDoc() map[string]string {
|
||||
return map_SELinuxStrategyOptions
|
||||
}
|
||||
|
||||
var map_Scale = map[string]string{
|
||||
"": "represents a scaling request for a resource.",
|
||||
"metadata": "Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.",
|
||||
"spec": "defines the behavior of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status.",
|
||||
"status": "current status of the scale. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status. Read-only.",
|
||||
}
|
||||
|
||||
func (Scale) SwaggerDoc() map[string]string {
|
||||
return map_Scale
|
||||
}
|
||||
|
||||
var map_ScaleSpec = map[string]string{
|
||||
"": "describes the attributes of a scale subresource",
|
||||
"replicas": "desired number of instances for the scaled object.",
|
||||
}
|
||||
|
||||
func (ScaleSpec) SwaggerDoc() map[string]string {
|
||||
return map_ScaleSpec
|
||||
}
|
||||
|
||||
var map_ScaleStatus = map[string]string{
|
||||
"": "represents the current status of a scale subresource.",
|
||||
"replicas": "actual number of observed instances of the scaled object.",
|
||||
"selector": "label query over pods that should match the replicas count. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors",
|
||||
"targetSelector": "label selector for pods that should match the replicas count. This is a serializated version of both map-based and more expressive set-based selectors. This is done to avoid introspection in the clients. The string will be in the same format as the query-param syntax. If the target type only supports map-based selectors, both this field and map-based selector field are populated. More info: http://kubernetes.io/docs/user-guide/labels#label-selectors",
|
||||
}
|
||||
|
||||
func (ScaleStatus) SwaggerDoc() map[string]string {
|
||||
return map_ScaleStatus
|
||||
}
|
||||
|
||||
var map_SubresourceReference = map[string]string{
|
||||
"": "SubresourceReference contains enough information to let you inspect or modify the referred subresource.",
|
||||
"kind": "Kind of the referent; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds",
|
||||
"name": "Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names",
|
||||
"apiVersion": "API version of the referent",
|
||||
"subresource": "Subresource name of the referent",
|
||||
}
|
||||
|
||||
func (SubresourceReference) SwaggerDoc() map[string]string {
|
||||
return map_SubresourceReference
|
||||
}
|
||||
|
||||
var map_SupplementalGroupsStrategyOptions = map[string]string{
|
||||
"": "SupplementalGroupsStrategyOptions defines the strategy type and options used to create the strategy.",
|
||||
"rule": "Rule is the strategy that will dictate what supplemental groups is used in the SecurityContext.",
|
||||
"ranges": "Ranges are the allowed ranges of supplemental groups. If you would like to force a single supplemental group then supply a single range with the same start and end.",
|
||||
}
|
||||
|
||||
func (SupplementalGroupsStrategyOptions) SwaggerDoc() map[string]string {
|
||||
return map_SupplementalGroupsStrategyOptions
|
||||
}
|
||||
|
||||
var map_ThirdPartyResource = map[string]string{
|
||||
"": "A ThirdPartyResource is a generic representation of a resource, it is used by add-ons and plugins to add new resource types to the API. It consists of one or more Versions of the api.",
|
||||
"metadata": "Standard object metadata",
|
||||
"description": "Description is the description of this object.",
|
||||
"versions": "Versions are versions for this third party object",
|
||||
}
|
||||
|
||||
func (ThirdPartyResource) SwaggerDoc() map[string]string {
|
||||
return map_ThirdPartyResource
|
||||
}
|
||||
|
||||
var map_ThirdPartyResourceData = map[string]string{
|
||||
"": "An internal object, used for versioned storage in etcd. Not exposed to the end user.",
|
||||
"metadata": "Standard object metadata.",
|
||||
"data": "Data is the raw JSON data for this data.",
|
||||
}
|
||||
|
||||
func (ThirdPartyResourceData) SwaggerDoc() map[string]string {
|
||||
return map_ThirdPartyResourceData
|
||||
}
|
||||
|
||||
var map_ThirdPartyResourceDataList = map[string]string{
|
||||
"": "ThirdPartyResrouceDataList is a list of ThirdPartyResourceData.",
|
||||
"metadata": "Standard list metadata More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
|
||||
"items": "Items is the list of ThirdpartyResourceData.",
|
||||
}
|
||||
|
||||
func (ThirdPartyResourceDataList) SwaggerDoc() map[string]string {
|
||||
return map_ThirdPartyResourceDataList
|
||||
}
|
||||
|
||||
var map_ThirdPartyResourceList = map[string]string{
|
||||
"": "ThirdPartyResourceList is a list of ThirdPartyResources.",
|
||||
"metadata": "Standard list metadata.",
|
||||
"items": "Items is the list of ThirdPartyResources.",
|
||||
}
|
||||
|
||||
func (ThirdPartyResourceList) SwaggerDoc() map[string]string {
|
||||
return map_ThirdPartyResourceList
|
||||
}
|
||||
|
||||
// AUTO-GENERATED FUNCTIONS END HERE
|
1715
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/zz_generated.conversion.go
generated
vendored
Normal file
1715
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/zz_generated.conversion.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1157
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/zz_generated.deepcopy.go
generated
vendored
Normal file
1157
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/zz_generated.deepcopy.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
439
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/zz_generated.defaults.go
generated
vendored
Normal file
439
vendor/k8s.io/kubernetes/pkg/apis/extensions/v1beta1/zz_generated.defaults.go
generated
vendored
Normal file
|
@ -0,0 +1,439 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// This file was autogenerated by defaulter-gen. Do not edit it manually!
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
v1 "k8s.io/kubernetes/pkg/api/v1"
|
||||
)
|
||||
|
||||
// RegisterDefaults adds defaulters functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
scheme.AddTypeDefaultingFunc(&DaemonSet{}, func(obj interface{}) { SetObjectDefaults_DaemonSet(obj.(*DaemonSet)) })
|
||||
scheme.AddTypeDefaultingFunc(&DaemonSetList{}, func(obj interface{}) { SetObjectDefaults_DaemonSetList(obj.(*DaemonSetList)) })
|
||||
scheme.AddTypeDefaultingFunc(&Deployment{}, func(obj interface{}) { SetObjectDefaults_Deployment(obj.(*Deployment)) })
|
||||
scheme.AddTypeDefaultingFunc(&DeploymentList{}, func(obj interface{}) { SetObjectDefaults_DeploymentList(obj.(*DeploymentList)) })
|
||||
scheme.AddTypeDefaultingFunc(&HorizontalPodAutoscaler{}, func(obj interface{}) { SetObjectDefaults_HorizontalPodAutoscaler(obj.(*HorizontalPodAutoscaler)) })
|
||||
scheme.AddTypeDefaultingFunc(&HorizontalPodAutoscalerList{}, func(obj interface{}) {
|
||||
SetObjectDefaults_HorizontalPodAutoscalerList(obj.(*HorizontalPodAutoscalerList))
|
||||
})
|
||||
scheme.AddTypeDefaultingFunc(&NetworkPolicy{}, func(obj interface{}) { SetObjectDefaults_NetworkPolicy(obj.(*NetworkPolicy)) })
|
||||
scheme.AddTypeDefaultingFunc(&NetworkPolicyList{}, func(obj interface{}) { SetObjectDefaults_NetworkPolicyList(obj.(*NetworkPolicyList)) })
|
||||
scheme.AddTypeDefaultingFunc(&ReplicaSet{}, func(obj interface{}) { SetObjectDefaults_ReplicaSet(obj.(*ReplicaSet)) })
|
||||
scheme.AddTypeDefaultingFunc(&ReplicaSetList{}, func(obj interface{}) { SetObjectDefaults_ReplicaSetList(obj.(*ReplicaSetList)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_DaemonSet(in *DaemonSet) {
|
||||
SetDefaults_DaemonSet(in)
|
||||
v1.SetDefaults_PodSpec(&in.Spec.Template.Spec)
|
||||
for i := range in.Spec.Template.Spec.Volumes {
|
||||
a := &in.Spec.Template.Spec.Volumes[i]
|
||||
v1.SetDefaults_Volume(a)
|
||||
if a.VolumeSource.Secret != nil {
|
||||
v1.SetDefaults_SecretVolumeSource(a.VolumeSource.Secret)
|
||||
}
|
||||
if a.VolumeSource.ISCSI != nil {
|
||||
v1.SetDefaults_ISCSIVolumeSource(a.VolumeSource.ISCSI)
|
||||
}
|
||||
if a.VolumeSource.RBD != nil {
|
||||
v1.SetDefaults_RBDVolumeSource(a.VolumeSource.RBD)
|
||||
}
|
||||
if a.VolumeSource.DownwardAPI != nil {
|
||||
v1.SetDefaults_DownwardAPIVolumeSource(a.VolumeSource.DownwardAPI)
|
||||
for j := range a.VolumeSource.DownwardAPI.Items {
|
||||
b := &a.VolumeSource.DownwardAPI.Items[j]
|
||||
if b.FieldRef != nil {
|
||||
v1.SetDefaults_ObjectFieldSelector(b.FieldRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
if a.VolumeSource.ConfigMap != nil {
|
||||
v1.SetDefaults_ConfigMapVolumeSource(a.VolumeSource.ConfigMap)
|
||||
}
|
||||
if a.VolumeSource.AzureDisk != nil {
|
||||
v1.SetDefaults_AzureDiskVolumeSource(a.VolumeSource.AzureDisk)
|
||||
}
|
||||
}
|
||||
for i := range in.Spec.Template.Spec.InitContainers {
|
||||
a := &in.Spec.Template.Spec.InitContainers[i]
|
||||
v1.SetDefaults_Container(a)
|
||||
for j := range a.Ports {
|
||||
b := &a.Ports[j]
|
||||
v1.SetDefaults_ContainerPort(b)
|
||||
}
|
||||
for j := range a.Env {
|
||||
b := &a.Env[j]
|
||||
if b.ValueFrom != nil {
|
||||
if b.ValueFrom.FieldRef != nil {
|
||||
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Limits)
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Requests)
|
||||
if a.LivenessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.LivenessProbe)
|
||||
if a.LivenessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.ReadinessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.ReadinessProbe)
|
||||
if a.ReadinessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle != nil {
|
||||
if a.Lifecycle.PostStart != nil {
|
||||
if a.Lifecycle.PostStart.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle.PreStop != nil {
|
||||
if a.Lifecycle.PreStop.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := range in.Spec.Template.Spec.Containers {
|
||||
a := &in.Spec.Template.Spec.Containers[i]
|
||||
v1.SetDefaults_Container(a)
|
||||
for j := range a.Ports {
|
||||
b := &a.Ports[j]
|
||||
v1.SetDefaults_ContainerPort(b)
|
||||
}
|
||||
for j := range a.Env {
|
||||
b := &a.Env[j]
|
||||
if b.ValueFrom != nil {
|
||||
if b.ValueFrom.FieldRef != nil {
|
||||
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Limits)
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Requests)
|
||||
if a.LivenessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.LivenessProbe)
|
||||
if a.LivenessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.ReadinessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.ReadinessProbe)
|
||||
if a.ReadinessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle != nil {
|
||||
if a.Lifecycle.PostStart != nil {
|
||||
if a.Lifecycle.PostStart.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle.PreStop != nil {
|
||||
if a.Lifecycle.PreStop.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_DaemonSetList(in *DaemonSetList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_DaemonSet(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_Deployment(in *Deployment) {
|
||||
SetDefaults_Deployment(in)
|
||||
v1.SetDefaults_PodSpec(&in.Spec.Template.Spec)
|
||||
for i := range in.Spec.Template.Spec.Volumes {
|
||||
a := &in.Spec.Template.Spec.Volumes[i]
|
||||
v1.SetDefaults_Volume(a)
|
||||
if a.VolumeSource.Secret != nil {
|
||||
v1.SetDefaults_SecretVolumeSource(a.VolumeSource.Secret)
|
||||
}
|
||||
if a.VolumeSource.ISCSI != nil {
|
||||
v1.SetDefaults_ISCSIVolumeSource(a.VolumeSource.ISCSI)
|
||||
}
|
||||
if a.VolumeSource.RBD != nil {
|
||||
v1.SetDefaults_RBDVolumeSource(a.VolumeSource.RBD)
|
||||
}
|
||||
if a.VolumeSource.DownwardAPI != nil {
|
||||
v1.SetDefaults_DownwardAPIVolumeSource(a.VolumeSource.DownwardAPI)
|
||||
for j := range a.VolumeSource.DownwardAPI.Items {
|
||||
b := &a.VolumeSource.DownwardAPI.Items[j]
|
||||
if b.FieldRef != nil {
|
||||
v1.SetDefaults_ObjectFieldSelector(b.FieldRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
if a.VolumeSource.ConfigMap != nil {
|
||||
v1.SetDefaults_ConfigMapVolumeSource(a.VolumeSource.ConfigMap)
|
||||
}
|
||||
if a.VolumeSource.AzureDisk != nil {
|
||||
v1.SetDefaults_AzureDiskVolumeSource(a.VolumeSource.AzureDisk)
|
||||
}
|
||||
}
|
||||
for i := range in.Spec.Template.Spec.InitContainers {
|
||||
a := &in.Spec.Template.Spec.InitContainers[i]
|
||||
v1.SetDefaults_Container(a)
|
||||
for j := range a.Ports {
|
||||
b := &a.Ports[j]
|
||||
v1.SetDefaults_ContainerPort(b)
|
||||
}
|
||||
for j := range a.Env {
|
||||
b := &a.Env[j]
|
||||
if b.ValueFrom != nil {
|
||||
if b.ValueFrom.FieldRef != nil {
|
||||
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Limits)
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Requests)
|
||||
if a.LivenessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.LivenessProbe)
|
||||
if a.LivenessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.ReadinessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.ReadinessProbe)
|
||||
if a.ReadinessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle != nil {
|
||||
if a.Lifecycle.PostStart != nil {
|
||||
if a.Lifecycle.PostStart.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle.PreStop != nil {
|
||||
if a.Lifecycle.PreStop.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := range in.Spec.Template.Spec.Containers {
|
||||
a := &in.Spec.Template.Spec.Containers[i]
|
||||
v1.SetDefaults_Container(a)
|
||||
for j := range a.Ports {
|
||||
b := &a.Ports[j]
|
||||
v1.SetDefaults_ContainerPort(b)
|
||||
}
|
||||
for j := range a.Env {
|
||||
b := &a.Env[j]
|
||||
if b.ValueFrom != nil {
|
||||
if b.ValueFrom.FieldRef != nil {
|
||||
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Limits)
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Requests)
|
||||
if a.LivenessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.LivenessProbe)
|
||||
if a.LivenessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.ReadinessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.ReadinessProbe)
|
||||
if a.ReadinessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle != nil {
|
||||
if a.Lifecycle.PostStart != nil {
|
||||
if a.Lifecycle.PostStart.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle.PreStop != nil {
|
||||
if a.Lifecycle.PreStop.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_DeploymentList(in *DeploymentList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_Deployment(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_HorizontalPodAutoscaler(in *HorizontalPodAutoscaler) {
|
||||
SetDefaults_HorizontalPodAutoscaler(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_HorizontalPodAutoscalerList(in *HorizontalPodAutoscalerList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_HorizontalPodAutoscaler(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_NetworkPolicy(in *NetworkPolicy) {
|
||||
SetDefaults_NetworkPolicy(in)
|
||||
}
|
||||
|
||||
func SetObjectDefaults_NetworkPolicyList(in *NetworkPolicyList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_NetworkPolicy(a)
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ReplicaSet(in *ReplicaSet) {
|
||||
SetDefaults_ReplicaSet(in)
|
||||
v1.SetDefaults_PodSpec(&in.Spec.Template.Spec)
|
||||
for i := range in.Spec.Template.Spec.Volumes {
|
||||
a := &in.Spec.Template.Spec.Volumes[i]
|
||||
v1.SetDefaults_Volume(a)
|
||||
if a.VolumeSource.Secret != nil {
|
||||
v1.SetDefaults_SecretVolumeSource(a.VolumeSource.Secret)
|
||||
}
|
||||
if a.VolumeSource.ISCSI != nil {
|
||||
v1.SetDefaults_ISCSIVolumeSource(a.VolumeSource.ISCSI)
|
||||
}
|
||||
if a.VolumeSource.RBD != nil {
|
||||
v1.SetDefaults_RBDVolumeSource(a.VolumeSource.RBD)
|
||||
}
|
||||
if a.VolumeSource.DownwardAPI != nil {
|
||||
v1.SetDefaults_DownwardAPIVolumeSource(a.VolumeSource.DownwardAPI)
|
||||
for j := range a.VolumeSource.DownwardAPI.Items {
|
||||
b := &a.VolumeSource.DownwardAPI.Items[j]
|
||||
if b.FieldRef != nil {
|
||||
v1.SetDefaults_ObjectFieldSelector(b.FieldRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
if a.VolumeSource.ConfigMap != nil {
|
||||
v1.SetDefaults_ConfigMapVolumeSource(a.VolumeSource.ConfigMap)
|
||||
}
|
||||
if a.VolumeSource.AzureDisk != nil {
|
||||
v1.SetDefaults_AzureDiskVolumeSource(a.VolumeSource.AzureDisk)
|
||||
}
|
||||
}
|
||||
for i := range in.Spec.Template.Spec.InitContainers {
|
||||
a := &in.Spec.Template.Spec.InitContainers[i]
|
||||
v1.SetDefaults_Container(a)
|
||||
for j := range a.Ports {
|
||||
b := &a.Ports[j]
|
||||
v1.SetDefaults_ContainerPort(b)
|
||||
}
|
||||
for j := range a.Env {
|
||||
b := &a.Env[j]
|
||||
if b.ValueFrom != nil {
|
||||
if b.ValueFrom.FieldRef != nil {
|
||||
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Limits)
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Requests)
|
||||
if a.LivenessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.LivenessProbe)
|
||||
if a.LivenessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.ReadinessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.ReadinessProbe)
|
||||
if a.ReadinessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle != nil {
|
||||
if a.Lifecycle.PostStart != nil {
|
||||
if a.Lifecycle.PostStart.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle.PreStop != nil {
|
||||
if a.Lifecycle.PreStop.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := range in.Spec.Template.Spec.Containers {
|
||||
a := &in.Spec.Template.Spec.Containers[i]
|
||||
v1.SetDefaults_Container(a)
|
||||
for j := range a.Ports {
|
||||
b := &a.Ports[j]
|
||||
v1.SetDefaults_ContainerPort(b)
|
||||
}
|
||||
for j := range a.Env {
|
||||
b := &a.Env[j]
|
||||
if b.ValueFrom != nil {
|
||||
if b.ValueFrom.FieldRef != nil {
|
||||
v1.SetDefaults_ObjectFieldSelector(b.ValueFrom.FieldRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Limits)
|
||||
v1.SetDefaults_ResourceList(&a.Resources.Requests)
|
||||
if a.LivenessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.LivenessProbe)
|
||||
if a.LivenessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.LivenessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.ReadinessProbe != nil {
|
||||
v1.SetDefaults_Probe(a.ReadinessProbe)
|
||||
if a.ReadinessProbe.Handler.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.ReadinessProbe.Handler.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle != nil {
|
||||
if a.Lifecycle.PostStart != nil {
|
||||
if a.Lifecycle.PostStart.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PostStart.HTTPGet)
|
||||
}
|
||||
}
|
||||
if a.Lifecycle.PreStop != nil {
|
||||
if a.Lifecycle.PreStop.HTTPGet != nil {
|
||||
v1.SetDefaults_HTTPGetAction(a.Lifecycle.PreStop.HTTPGet)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetObjectDefaults_ReplicaSetList(in *ReplicaSetList) {
|
||||
for i := range in.Items {
|
||||
a := &in.Items[i]
|
||||
SetObjectDefaults_ReplicaSet(a)
|
||||
}
|
||||
}
|
60
vendor/k8s.io/kubernetes/pkg/apis/extensions/validation/BUILD
generated
vendored
Normal file
60
vendor/k8s.io/kubernetes/pkg/apis/extensions/validation/BUILD
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["validation.go"],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/validation:go_default_library",
|
||||
"//pkg/apis/extensions:go_default_library",
|
||||
"//pkg/security/apparmor:go_default_library",
|
||||
"//pkg/security/podsecuritypolicy/seccomp:go_default_library",
|
||||
"//pkg/security/podsecuritypolicy/util:go_default_library",
|
||||
"//pkg/util/intstr:go_default_library",
|
||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1/validation",
|
||||
"//vendor:k8s.io/apimachinery/pkg/labels",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/sets",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/validation",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/validation/field",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["validation_test.go"],
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/apis/extensions:go_default_library",
|
||||
"//pkg/security/apparmor:go_default_library",
|
||||
"//pkg/security/podsecuritypolicy/seccomp:go_default_library",
|
||||
"//pkg/security/podsecuritypolicy/util:go_default_library",
|
||||
"//pkg/util/intstr:go_default_library",
|
||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/validation/field",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
872
vendor/k8s.io/kubernetes/pkg/apis/extensions/validation/validation.go
generated
vendored
Normal file
872
vendor/k8s.io/kubernetes/pkg/apis/extensions/validation/validation.go
generated
vendored
Normal file
|
@ -0,0 +1,872 @@
|
|||
/*
|
||||
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 validation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
unversionedvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
apivalidation "k8s.io/kubernetes/pkg/api/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/security/apparmor"
|
||||
"k8s.io/kubernetes/pkg/security/podsecuritypolicy/seccomp"
|
||||
psputil "k8s.io/kubernetes/pkg/security/podsecuritypolicy/util"
|
||||
"k8s.io/kubernetes/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func ValidateThirdPartyResourceUpdate(update, old *extensions.ThirdPartyResource) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata"))...)
|
||||
allErrs = append(allErrs, ValidateThirdPartyResource(update)...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateThirdPartyResourceName(name string, prefix bool) []string {
|
||||
// Make sure it's a valid DNS subdomain
|
||||
if msgs := apivalidation.NameIsDNSSubdomain(name, prefix); len(msgs) != 0 {
|
||||
return msgs
|
||||
}
|
||||
|
||||
// Make sure it's at least three segments (kind + two-segment group name)
|
||||
if !prefix {
|
||||
parts := strings.Split(name, ".")
|
||||
if len(parts) < 3 {
|
||||
return []string{"must be at least three segments long: <kind>.<domain>.<tld>"}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateThirdPartyResource(obj *extensions.ThirdPartyResource) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&obj.ObjectMeta, false, ValidateThirdPartyResourceName, field.NewPath("metadata"))...)
|
||||
|
||||
versions := sets.String{}
|
||||
if len(obj.Versions) == 0 {
|
||||
allErrs = append(allErrs, field.Required(field.NewPath("versions"), "must specify at least one version"))
|
||||
}
|
||||
for ix := range obj.Versions {
|
||||
version := &obj.Versions[ix]
|
||||
if len(version.Name) == 0 {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("versions").Index(ix).Child("name"), version, "must not be empty"))
|
||||
} else {
|
||||
for _, msg := range validation.IsDNS1123Label(version.Name) {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("versions").Index(ix).Child("name"), version, msg))
|
||||
}
|
||||
}
|
||||
if versions.Has(version.Name) {
|
||||
allErrs = append(allErrs, field.Duplicate(field.NewPath("versions").Index(ix).Child("name"), version))
|
||||
}
|
||||
versions.Insert(version.Name)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateDaemonSet tests if required fields in the DaemonSet are set.
|
||||
func ValidateDaemonSet(ds *extensions.DaemonSet) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMeta(&ds.ObjectMeta, true, ValidateDaemonSetName, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateDaemonSetSpec(&ds.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateDaemonSetUpdate tests if required fields in the DaemonSet are set.
|
||||
func ValidateDaemonSetUpdate(ds, oldDS *extensions.DaemonSet) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMetaUpdate(&ds.ObjectMeta, &oldDS.ObjectMeta, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateDaemonSetSpec(&ds.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validateDaemonSetStatus validates a DaemonSetStatus
|
||||
func validateDaemonSetStatus(status *extensions.DaemonSetStatus, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.CurrentNumberScheduled), fldPath.Child("currentNumberScheduled"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.NumberMisscheduled), fldPath.Child("numberMisscheduled"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.DesiredNumberScheduled), fldPath.Child("desiredNumberScheduled"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.NumberReady), fldPath.Child("numberReady"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(status.ObservedGeneration, fldPath.Child("observedGeneration"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateDaemonSetStatus validates tests if required fields in the DaemonSet Status section
|
||||
func ValidateDaemonSetStatusUpdate(ds, oldDS *extensions.DaemonSet) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMetaUpdate(&ds.ObjectMeta, &oldDS.ObjectMeta, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, validateDaemonSetStatus(&ds.Status, field.NewPath("status"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateDaemonSetSpec tests if required fields in the DaemonSetSpec are set.
|
||||
func ValidateDaemonSetSpec(spec *extensions.DaemonSetSpec, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(spec.Selector, fldPath.Child("selector"))...)
|
||||
|
||||
selector, err := metav1.LabelSelectorAsSelector(spec.Selector)
|
||||
if err == nil && !selector.Matches(labels.Set(spec.Template.Labels)) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("template", "metadata", "labels"), spec.Template.Labels, "`selector` does not match template `labels`"))
|
||||
}
|
||||
if spec.Selector != nil && len(spec.Selector.MatchLabels)+len(spec.Selector.MatchExpressions) == 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("selector"), spec.Selector, "empty selector is not valid for daemonset."))
|
||||
}
|
||||
|
||||
allErrs = append(allErrs, apivalidation.ValidatePodTemplateSpec(&spec.Template, fldPath.Child("template"))...)
|
||||
// Daemons typically run on more than one node, so mark Read-Write persistent disks as invalid.
|
||||
allErrs = append(allErrs, apivalidation.ValidateReadOnlyPersistentDisks(spec.Template.Spec.Volumes, fldPath.Child("template", "spec", "volumes"))...)
|
||||
// RestartPolicy has already been first-order validated as per ValidatePodTemplateSpec().
|
||||
if spec.Template.Spec.RestartPolicy != api.RestartPolicyAlways {
|
||||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("template", "spec", "restartPolicy"), spec.Template.Spec.RestartPolicy, []string{string(api.RestartPolicyAlways)}))
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateDaemonSetName can be used to check whether the given daemon set name is valid.
|
||||
// Prefix indicates this name will be used as part of generation, in which case
|
||||
// trailing dashes are allowed.
|
||||
var ValidateDaemonSetName = apivalidation.NameIsDNSSubdomain
|
||||
|
||||
// Validates that the given name can be used as a deployment name.
|
||||
var ValidateDeploymentName = apivalidation.NameIsDNSSubdomain
|
||||
|
||||
func ValidatePositiveIntOrPercent(intOrPercent intstr.IntOrString, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
switch intOrPercent.Type {
|
||||
case intstr.String:
|
||||
for _, msg := range validation.IsValidPercent(intOrPercent.StrVal) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, intOrPercent, msg))
|
||||
}
|
||||
case intstr.Int:
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(intOrPercent.IntValue()), fldPath)...)
|
||||
default:
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, intOrPercent, "must be an integer or percentage (e.g '5%%')"))
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func getPercentValue(intOrStringValue intstr.IntOrString) (int, bool) {
|
||||
if intOrStringValue.Type != intstr.String {
|
||||
return 0, false
|
||||
}
|
||||
if len(validation.IsValidPercent(intOrStringValue.StrVal)) != 0 {
|
||||
return 0, false
|
||||
}
|
||||
value, _ := strconv.Atoi(intOrStringValue.StrVal[:len(intOrStringValue.StrVal)-1])
|
||||
return value, true
|
||||
}
|
||||
|
||||
func getIntOrPercentValue(intOrStringValue intstr.IntOrString) int {
|
||||
value, isPercent := getPercentValue(intOrStringValue)
|
||||
if isPercent {
|
||||
return value
|
||||
}
|
||||
return intOrStringValue.IntValue()
|
||||
}
|
||||
|
||||
func IsNotMoreThan100Percent(intOrStringValue intstr.IntOrString, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
value, isPercent := getPercentValue(intOrStringValue)
|
||||
if !isPercent || value <= 100 {
|
||||
return nil
|
||||
}
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, intOrStringValue, "must not be greater than 100%"))
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateRollingUpdateDeployment(rollingUpdate *extensions.RollingUpdateDeployment, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, ValidatePositiveIntOrPercent(rollingUpdate.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
|
||||
allErrs = append(allErrs, ValidatePositiveIntOrPercent(rollingUpdate.MaxSurge, fldPath.Child("maxSurge"))...)
|
||||
if getIntOrPercentValue(rollingUpdate.MaxUnavailable) == 0 && getIntOrPercentValue(rollingUpdate.MaxSurge) == 0 {
|
||||
// Both MaxSurge and MaxUnavailable cannot be zero.
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("maxUnavailable"), rollingUpdate.MaxUnavailable, "may not be 0 when `maxSurge` is 0"))
|
||||
}
|
||||
// Validate that MaxUnavailable is not more than 100%.
|
||||
allErrs = append(allErrs, IsNotMoreThan100Percent(rollingUpdate.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateDeploymentStrategy(strategy *extensions.DeploymentStrategy, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
switch strategy.Type {
|
||||
case extensions.RecreateDeploymentStrategyType:
|
||||
if strategy.RollingUpdate != nil {
|
||||
allErrs = append(allErrs, field.Forbidden(fldPath.Child("rollingUpdate"), "may not be specified when strategy `type` is '"+string(extensions.RecreateDeploymentStrategyType+"'")))
|
||||
}
|
||||
case extensions.RollingUpdateDeploymentStrategyType:
|
||||
// This should never happen since it's set and checked in defaults.go
|
||||
if strategy.RollingUpdate == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("rollingUpdate"), "this should be defaulted and never be nil"))
|
||||
} else {
|
||||
allErrs = append(allErrs, ValidateRollingUpdateDeployment(strategy.RollingUpdate, fldPath.Child("rollingUpdate"))...)
|
||||
}
|
||||
default:
|
||||
validValues := []string{string(extensions.RecreateDeploymentStrategyType), string(extensions.RollingUpdateDeploymentStrategyType)}
|
||||
allErrs = append(allErrs, field.NotSupported(fldPath, strategy, validValues))
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateRollback(rollback *extensions.RollbackConfig, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
v := rollback.Revision
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(v), fldPath.Child("version"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// Validates given deployment spec.
|
||||
func ValidateDeploymentSpec(spec *extensions.DeploymentSpec, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.Replicas), fldPath.Child("replicas"))...)
|
||||
|
||||
if spec.Selector == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("selector"), ""))
|
||||
} else {
|
||||
allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(spec.Selector, fldPath.Child("selector"))...)
|
||||
if len(spec.Selector.MatchLabels)+len(spec.Selector.MatchExpressions) == 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("selector"), spec.Selector, "empty selector is not valid for deployment."))
|
||||
}
|
||||
}
|
||||
|
||||
selector, err := metav1.LabelSelectorAsSelector(spec.Selector)
|
||||
if err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("selector"), spec.Selector, "invalid label selector."))
|
||||
} else {
|
||||
allErrs = append(allErrs, ValidatePodTemplateSpecForReplicaSet(&spec.Template, selector, spec.Replicas, fldPath.Child("template"))...)
|
||||
}
|
||||
|
||||
allErrs = append(allErrs, ValidateDeploymentStrategy(&spec.Strategy, fldPath.Child("strategy"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.MinReadySeconds), fldPath.Child("minReadySeconds"))...)
|
||||
if spec.RevisionHistoryLimit != nil {
|
||||
// zero is a valid RevisionHistoryLimit
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(*spec.RevisionHistoryLimit), fldPath.Child("revisionHistoryLimit"))...)
|
||||
}
|
||||
if spec.RollbackTo != nil {
|
||||
allErrs = append(allErrs, ValidateRollback(spec.RollbackTo, fldPath.Child("rollback"))...)
|
||||
}
|
||||
if spec.ProgressDeadlineSeconds != nil {
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(*spec.ProgressDeadlineSeconds), fldPath.Child("progressDeadlineSeconds"))...)
|
||||
if *spec.ProgressDeadlineSeconds <= spec.MinReadySeconds {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("progressDeadlineSeconds"), spec.ProgressDeadlineSeconds, "must be greater than minReadySeconds."))
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// Validates given deployment status.
|
||||
func ValidateDeploymentStatus(status *extensions.DeploymentStatus, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(status.ObservedGeneration, fldPath.Child("observedGeneration"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.Replicas), fldPath.Child("replicas"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.UpdatedReplicas), fldPath.Child("updatedReplicas"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.ReadyReplicas), fldPath.Child("readyReplicas"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.AvailableReplicas), fldPath.Child("availableReplicas"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.UnavailableReplicas), fldPath.Child("unavailableReplicas"))...)
|
||||
msg := "cannot be greater than status.replicas"
|
||||
if status.ReadyReplicas > status.Replicas {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("readyReplicas"), status.ReadyReplicas, msg))
|
||||
}
|
||||
if status.AvailableReplicas > status.Replicas {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("availableReplicas"), status.AvailableReplicas, msg))
|
||||
}
|
||||
if status.ReadyReplicas > status.AvailableReplicas {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("readyReplicas"), status.ReadyReplicas, "cannot be greater than availableReplicas"))
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateDeploymentUpdate(update, old *extensions.Deployment) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateDeploymentSpec(&update.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateDeploymentStatusUpdate(update, old *extensions.Deployment) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateDeploymentStatus(&update.Status, field.NewPath("status"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateDeployment(obj *extensions.Deployment) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMeta(&obj.ObjectMeta, true, ValidateDeploymentName, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateDeploymentSpec(&obj.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateDeploymentRollback(obj *extensions.DeploymentRollback) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateAnnotations(obj.UpdatedAnnotations, field.NewPath("updatedAnnotations"))
|
||||
if len(obj.Name) == 0 {
|
||||
allErrs = append(allErrs, field.Required(field.NewPath("name"), "name is required"))
|
||||
}
|
||||
allErrs = append(allErrs, ValidateRollback(&obj.RollbackTo, field.NewPath("rollback"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateThirdPartyResourceDataUpdate(update, old *extensions.ThirdPartyResourceData) field.ErrorList {
|
||||
return apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata"))
|
||||
}
|
||||
|
||||
func ValidateThirdPartyResourceData(obj *extensions.ThirdPartyResourceData) field.ErrorList {
|
||||
return apivalidation.ValidateObjectMeta(&obj.ObjectMeta, true, apivalidation.NameIsDNSLabel, field.NewPath("metadata"))
|
||||
}
|
||||
|
||||
// ValidateIngress tests if required fields in the Ingress are set.
|
||||
func ValidateIngress(ingress *extensions.Ingress) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMeta(&ingress.ObjectMeta, true, ValidateIngressName, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateIngressSpec(&ingress.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateIngressName validates that the given name can be used as an Ingress name.
|
||||
var ValidateIngressName = apivalidation.NameIsDNSSubdomain
|
||||
|
||||
func validateIngressTLS(spec *extensions.IngressSpec, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
// TODO: Perform a more thorough validation of spec.TLS.Hosts that takes
|
||||
// the wildcard spec from RFC 6125 into account.
|
||||
for _, itls := range spec.TLS {
|
||||
for i, host := range itls.Hosts {
|
||||
if strings.Contains(host, "*") {
|
||||
for _, msg := range validation.IsWildcardDNS1123Subdomain(host) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("hosts"), host, msg))
|
||||
}
|
||||
continue
|
||||
}
|
||||
for _, msg := range validation.IsDNS1123Subdomain(host) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("hosts"), host, msg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateIngressSpec tests if required fields in the IngressSpec are set.
|
||||
func ValidateIngressSpec(spec *extensions.IngressSpec, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
// TODO: Is a default backend mandatory?
|
||||
if spec.Backend != nil {
|
||||
allErrs = append(allErrs, validateIngressBackend(spec.Backend, fldPath.Child("backend"))...)
|
||||
} else if len(spec.Rules) == 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, spec.Rules, "either `backend` or `rules` must be specified"))
|
||||
}
|
||||
if len(spec.Rules) > 0 {
|
||||
allErrs = append(allErrs, validateIngressRules(spec.Rules, fldPath.Child("rules"))...)
|
||||
}
|
||||
if len(spec.TLS) > 0 {
|
||||
allErrs = append(allErrs, validateIngressTLS(spec, fldPath.Child("tls"))...)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateIngressUpdate tests if required fields in the Ingress are set.
|
||||
func ValidateIngressUpdate(ingress, oldIngress *extensions.Ingress) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMetaUpdate(&ingress.ObjectMeta, &oldIngress.ObjectMeta, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateIngressSpec(&ingress.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateIngressStatusUpdate tests if required fields in the Ingress are set when updating status.
|
||||
func ValidateIngressStatusUpdate(ingress, oldIngress *extensions.Ingress) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMetaUpdate(&ingress.ObjectMeta, &oldIngress.ObjectMeta, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, apivalidation.ValidateLoadBalancerStatus(&ingress.Status.LoadBalancer, field.NewPath("status", "loadBalancer"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateIngressRules(ingressRules []extensions.IngressRule, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if len(ingressRules) == 0 {
|
||||
return append(allErrs, field.Required(fldPath, ""))
|
||||
}
|
||||
for i, ih := range ingressRules {
|
||||
if len(ih.Host) > 0 {
|
||||
if isIP := (net.ParseIP(ih.Host) != nil); isIP {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("host"), ih.Host, "must be a DNS name, not an IP address"))
|
||||
}
|
||||
// TODO: Ports and ips are allowed in the host part of a url
|
||||
// according to RFC 3986, consider allowing them.
|
||||
if strings.Contains(ih.Host, "*") {
|
||||
for _, msg := range validation.IsWildcardDNS1123Subdomain(ih.Host) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("host"), ih.Host, msg))
|
||||
}
|
||||
continue
|
||||
}
|
||||
for _, msg := range validation.IsDNS1123Subdomain(ih.Host) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("host"), ih.Host, msg))
|
||||
}
|
||||
}
|
||||
allErrs = append(allErrs, validateIngressRuleValue(&ih.IngressRuleValue, fldPath.Index(0))...)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateIngressRuleValue(ingressRule *extensions.IngressRuleValue, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if ingressRule.HTTP != nil {
|
||||
allErrs = append(allErrs, validateHTTPIngressRuleValue(ingressRule.HTTP, fldPath.Child("http"))...)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateHTTPIngressRuleValue(httpIngressRuleValue *extensions.HTTPIngressRuleValue, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if len(httpIngressRuleValue.Paths) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("paths"), ""))
|
||||
}
|
||||
for i, rule := range httpIngressRuleValue.Paths {
|
||||
if len(rule.Path) > 0 {
|
||||
if !strings.HasPrefix(rule.Path, "/") {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("paths").Index(i).Child("path"), rule.Path, "must be an absolute path"))
|
||||
}
|
||||
// TODO: More draconian path regex validation.
|
||||
// Path must be a valid regex. This is the basic requirement.
|
||||
// In addition to this any characters not allowed in a path per
|
||||
// RFC 3986 section-3.3 cannot appear as a literal in the regex.
|
||||
// Consider the example: http://host/valid?#bar, everything after
|
||||
// the last '/' is a valid regex that matches valid#bar, which
|
||||
// isn't a valid path, because the path terminates at the first ?
|
||||
// or #. A more sophisticated form of validation would detect that
|
||||
// the user is confusing url regexes with path regexes.
|
||||
_, err := regexp.CompilePOSIX(rule.Path)
|
||||
if err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("paths").Index(i).Child("path"), rule.Path, "must be a valid regex"))
|
||||
}
|
||||
}
|
||||
allErrs = append(allErrs, validateIngressBackend(&rule.Backend, fldPath.Child("backend"))...)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validateIngressBackend tests if a given backend is valid.
|
||||
func validateIngressBackend(backend *extensions.IngressBackend, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
// All backends must reference a single local service by name, and a single service port by name or number.
|
||||
if len(backend.ServiceName) == 0 {
|
||||
return append(allErrs, field.Required(fldPath.Child("serviceName"), ""))
|
||||
} else {
|
||||
for _, msg := range apivalidation.ValidateServiceName(backend.ServiceName, false) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("serviceName"), backend.ServiceName, msg))
|
||||
}
|
||||
}
|
||||
allErrs = append(allErrs, apivalidation.ValidatePortNumOrName(backend.ServicePort, fldPath.Child("servicePort"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateScale(scale *extensions.Scale) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&scale.ObjectMeta, true, apivalidation.NameIsDNSSubdomain, field.NewPath("metadata"))...)
|
||||
|
||||
if scale.Spec.Replicas < 0 {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "replicas"), scale.Spec.Replicas, "must be greater than or equal to 0"))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateReplicaSetName can be used to check whether the given ReplicaSet
|
||||
// name is valid.
|
||||
// Prefix indicates this name will be used as part of generation, in which case
|
||||
// trailing dashes are allowed.
|
||||
var ValidateReplicaSetName = apivalidation.NameIsDNSSubdomain
|
||||
|
||||
// ValidateReplicaSet tests if required fields in the ReplicaSet are set.
|
||||
func ValidateReplicaSet(rs *extensions.ReplicaSet) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMeta(&rs.ObjectMeta, true, ValidateReplicaSetName, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateReplicaSetSpec(&rs.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateReplicaSetUpdate tests if required fields in the ReplicaSet are set.
|
||||
func ValidateReplicaSetUpdate(rs, oldRs *extensions.ReplicaSet) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&rs.ObjectMeta, &oldRs.ObjectMeta, field.NewPath("metadata"))...)
|
||||
allErrs = append(allErrs, ValidateReplicaSetSpec(&rs.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateReplicaSetStatusUpdate tests if required fields in the ReplicaSet are set.
|
||||
func ValidateReplicaSetStatusUpdate(rs, oldRs *extensions.ReplicaSet) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
fldPath := field.NewPath("status")
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&rs.ObjectMeta, &oldRs.ObjectMeta, field.NewPath("metadata"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(rs.Status.Replicas), fldPath.Child("replicas"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(rs.Status.FullyLabeledReplicas), fldPath.Child("fullyLabeledReplicas"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(rs.Status.ReadyReplicas), fldPath.Child("readyReplicas"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(rs.Status.AvailableReplicas), fldPath.Child("availableReplicas"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(rs.Status.ObservedGeneration), fldPath.Child("observedGeneration"))...)
|
||||
msg := "cannot be greater than status.replicas"
|
||||
if rs.Status.FullyLabeledReplicas > rs.Status.Replicas {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("fullyLabeledReplicas"), rs.Status.FullyLabeledReplicas, msg))
|
||||
}
|
||||
if rs.Status.ReadyReplicas > rs.Status.Replicas {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("readyReplicas"), rs.Status.ReadyReplicas, msg))
|
||||
}
|
||||
if rs.Status.AvailableReplicas > rs.Status.Replicas {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("availableReplicas"), rs.Status.AvailableReplicas, msg))
|
||||
}
|
||||
if rs.Status.ReadyReplicas > rs.Status.AvailableReplicas {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("readyReplicas"), rs.Status.ReadyReplicas, "cannot be greater than availableReplicas"))
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateReplicaSetSpec tests if required fields in the ReplicaSet spec are set.
|
||||
func ValidateReplicaSetSpec(spec *extensions.ReplicaSetSpec, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.Replicas), fldPath.Child("replicas"))...)
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.MinReadySeconds), fldPath.Child("minReadySeconds"))...)
|
||||
|
||||
if spec.Selector == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("selector"), ""))
|
||||
} else {
|
||||
allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(spec.Selector, fldPath.Child("selector"))...)
|
||||
if len(spec.Selector.MatchLabels)+len(spec.Selector.MatchExpressions) == 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("selector"), spec.Selector, "empty selector is not valid for deployment."))
|
||||
}
|
||||
}
|
||||
|
||||
selector, err := metav1.LabelSelectorAsSelector(spec.Selector)
|
||||
if err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("selector"), spec.Selector, "invalid label selector."))
|
||||
} else {
|
||||
allErrs = append(allErrs, ValidatePodTemplateSpecForReplicaSet(&spec.Template, selector, spec.Replicas, fldPath.Child("template"))...)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// Validates the given template and ensures that it is in accordance with the desired selector and replicas.
|
||||
func ValidatePodTemplateSpecForReplicaSet(template *api.PodTemplateSpec, selector labels.Selector, replicas int32, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if template == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath, ""))
|
||||
} else {
|
||||
if !selector.Empty() {
|
||||
// Verify that the ReplicaSet selector matches the labels in template.
|
||||
labels := labels.Set(template.Labels)
|
||||
if !selector.Matches(labels) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("metadata", "labels"), template.Labels, "`selector` does not match template `labels`"))
|
||||
}
|
||||
}
|
||||
allErrs = append(allErrs, apivalidation.ValidatePodTemplateSpec(template, fldPath)...)
|
||||
if replicas > 1 {
|
||||
allErrs = append(allErrs, apivalidation.ValidateReadOnlyPersistentDisks(template.Spec.Volumes, fldPath.Child("spec", "volumes"))...)
|
||||
}
|
||||
// RestartPolicy has already been first-order validated as per ValidatePodTemplateSpec().
|
||||
if template.Spec.RestartPolicy != api.RestartPolicyAlways {
|
||||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("spec", "restartPolicy"), template.Spec.RestartPolicy, []string{string(api.RestartPolicyAlways)}))
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidatePodSecurityPolicyName can be used to check whether the given
|
||||
// pod security policy name is valid.
|
||||
// Prefix indicates this name will be used as part of generation, in which case
|
||||
// trailing dashes are allowed.
|
||||
var ValidatePodSecurityPolicyName = apivalidation.NameIsDNSSubdomain
|
||||
|
||||
func ValidatePodSecurityPolicy(psp *extensions.PodSecurityPolicy) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&psp.ObjectMeta, false, ValidatePodSecurityPolicyName, field.NewPath("metadata"))...)
|
||||
allErrs = append(allErrs, ValidatePodSecurityPolicySpecificAnnotations(psp.Annotations, field.NewPath("metadata").Child("annotations"))...)
|
||||
allErrs = append(allErrs, ValidatePodSecurityPolicySpec(&psp.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidatePodSecurityPolicySpec(spec *extensions.PodSecurityPolicySpec, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
allErrs = append(allErrs, validatePSPRunAsUser(fldPath.Child("runAsUser"), &spec.RunAsUser)...)
|
||||
allErrs = append(allErrs, validatePSPSELinux(fldPath.Child("seLinux"), &spec.SELinux)...)
|
||||
allErrs = append(allErrs, validatePSPSupplementalGroup(fldPath.Child("supplementalGroups"), &spec.SupplementalGroups)...)
|
||||
allErrs = append(allErrs, validatePSPFSGroup(fldPath.Child("fsGroup"), &spec.FSGroup)...)
|
||||
allErrs = append(allErrs, validatePodSecurityPolicyVolumes(fldPath, spec.Volumes)...)
|
||||
allErrs = append(allErrs, validatePSPCapsAgainstDrops(spec.RequiredDropCapabilities, spec.DefaultAddCapabilities, field.NewPath("defaultAddCapabilities"))...)
|
||||
allErrs = append(allErrs, validatePSPCapsAgainstDrops(spec.RequiredDropCapabilities, spec.AllowedCapabilities, field.NewPath("allowedCapabilities"))...)
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidatePodSecurityPolicySpecificAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
if p := annotations[apparmor.DefaultProfileAnnotationKey]; p != "" {
|
||||
if err := apparmor.ValidateProfileFormat(p); err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Key(apparmor.DefaultProfileAnnotationKey), p, err.Error()))
|
||||
}
|
||||
}
|
||||
if allowed := annotations[apparmor.AllowedProfilesAnnotationKey]; allowed != "" {
|
||||
for _, p := range strings.Split(allowed, ",") {
|
||||
if err := apparmor.ValidateProfileFormat(p); err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Key(apparmor.AllowedProfilesAnnotationKey), allowed, err.Error()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sysctlAnnotation := annotations[extensions.SysctlsPodSecurityPolicyAnnotationKey]
|
||||
sysctlFldPath := fldPath.Key(extensions.SysctlsPodSecurityPolicyAnnotationKey)
|
||||
sysctls, err := extensions.SysctlsFromPodSecurityPolicyAnnotation(sysctlAnnotation)
|
||||
if err != nil {
|
||||
allErrs = append(allErrs, field.Invalid(sysctlFldPath, sysctlAnnotation, err.Error()))
|
||||
} else {
|
||||
allErrs = append(allErrs, validatePodSecurityPolicySysctls(sysctlFldPath, sysctls)...)
|
||||
}
|
||||
|
||||
if p := annotations[seccomp.DefaultProfileAnnotationKey]; p != "" {
|
||||
allErrs = append(allErrs, apivalidation.ValidateSeccompProfile(p, fldPath.Key(seccomp.DefaultProfileAnnotationKey))...)
|
||||
}
|
||||
if allowed := annotations[seccomp.AllowedProfilesAnnotationKey]; allowed != "" {
|
||||
for _, p := range strings.Split(allowed, ",") {
|
||||
allErrs = append(allErrs, apivalidation.ValidateSeccompProfile(p, fldPath.Key(seccomp.AllowedProfilesAnnotationKey))...)
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validatePSPSELinux validates the SELinux fields of PodSecurityPolicy.
|
||||
func validatePSPSELinux(fldPath *field.Path, seLinux *extensions.SELinuxStrategyOptions) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
// ensure the selinux strategy has a valid rule
|
||||
supportedSELinuxRules := sets.NewString(string(extensions.SELinuxStrategyMustRunAs),
|
||||
string(extensions.SELinuxStrategyRunAsAny))
|
||||
if !supportedSELinuxRules.Has(string(seLinux.Rule)) {
|
||||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("rule"), seLinux.Rule, supportedSELinuxRules.List()))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validatePSPRunAsUser validates the RunAsUser fields of PodSecurityPolicy.
|
||||
func validatePSPRunAsUser(fldPath *field.Path, runAsUser *extensions.RunAsUserStrategyOptions) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
// ensure the user strategy has a valid rule
|
||||
supportedRunAsUserRules := sets.NewString(string(extensions.RunAsUserStrategyMustRunAs),
|
||||
string(extensions.RunAsUserStrategyMustRunAsNonRoot),
|
||||
string(extensions.RunAsUserStrategyRunAsAny))
|
||||
if !supportedRunAsUserRules.Has(string(runAsUser.Rule)) {
|
||||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("rule"), runAsUser.Rule, supportedRunAsUserRules.List()))
|
||||
}
|
||||
|
||||
// validate range settings
|
||||
for idx, rng := range runAsUser.Ranges {
|
||||
allErrs = append(allErrs, validateIDRanges(fldPath.Child("ranges").Index(idx), rng)...)
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validatePSPFSGroup validates the FSGroupStrategyOptions fields of the PodSecurityPolicy.
|
||||
func validatePSPFSGroup(fldPath *field.Path, groupOptions *extensions.FSGroupStrategyOptions) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
supportedRules := sets.NewString(
|
||||
string(extensions.FSGroupStrategyMustRunAs),
|
||||
string(extensions.FSGroupStrategyRunAsAny),
|
||||
)
|
||||
if !supportedRules.Has(string(groupOptions.Rule)) {
|
||||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("rule"), groupOptions.Rule, supportedRules.List()))
|
||||
}
|
||||
|
||||
for idx, rng := range groupOptions.Ranges {
|
||||
allErrs = append(allErrs, validateIDRanges(fldPath.Child("ranges").Index(idx), rng)...)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validatePSPSupplementalGroup validates the SupplementalGroupsStrategyOptions fields of the PodSecurityPolicy.
|
||||
func validatePSPSupplementalGroup(fldPath *field.Path, groupOptions *extensions.SupplementalGroupsStrategyOptions) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
supportedRules := sets.NewString(
|
||||
string(extensions.SupplementalGroupsStrategyRunAsAny),
|
||||
string(extensions.SupplementalGroupsStrategyMustRunAs),
|
||||
)
|
||||
if !supportedRules.Has(string(groupOptions.Rule)) {
|
||||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("rule"), groupOptions.Rule, supportedRules.List()))
|
||||
}
|
||||
|
||||
for idx, rng := range groupOptions.Ranges {
|
||||
allErrs = append(allErrs, validateIDRanges(fldPath.Child("ranges").Index(idx), rng)...)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validatePodSecurityPolicyVolumes validates the volume fields of PodSecurityPolicy.
|
||||
func validatePodSecurityPolicyVolumes(fldPath *field.Path, volumes []extensions.FSType) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allowed := psputil.GetAllFSTypesAsSet()
|
||||
// add in the * value since that is a pseudo type that is not included by default
|
||||
allowed.Insert(string(extensions.All))
|
||||
for _, v := range volumes {
|
||||
if !allowed.Has(string(v)) {
|
||||
allErrs = append(allErrs, field.NotSupported(fldPath.Child("volumes"), v, allowed.List()))
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
const sysctlPatternSegmentFmt string = "([a-z0-9][-_a-z0-9]*)?[a-z0-9*]"
|
||||
const SysctlPatternFmt string = "(" + apivalidation.SysctlSegmentFmt + "\\.)*" + sysctlPatternSegmentFmt
|
||||
|
||||
var sysctlPatternRegexp = regexp.MustCompile("^" + SysctlPatternFmt + "$")
|
||||
|
||||
func IsValidSysctlPattern(name string) bool {
|
||||
if len(name) > apivalidation.SysctlMaxLength {
|
||||
return false
|
||||
}
|
||||
return sysctlPatternRegexp.MatchString(name)
|
||||
}
|
||||
|
||||
// validatePodSecurityPolicySysctls validates the sysctls fields of PodSecurityPolicy.
|
||||
func validatePodSecurityPolicySysctls(fldPath *field.Path, sysctls []string) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
for i, s := range sysctls {
|
||||
if !IsValidSysctlPattern(string(s)) {
|
||||
allErrs = append(
|
||||
allErrs,
|
||||
field.Invalid(fldPath.Index(i), sysctls[i], fmt.Sprintf("must have at most %d characters and match regex %s",
|
||||
apivalidation.SysctlMaxLength,
|
||||
SysctlPatternFmt,
|
||||
)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validateIDRanges ensures the range is valid.
|
||||
func validateIDRanges(fldPath *field.Path, rng extensions.IDRange) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
// if 0 <= Min <= Max then we do not need to validate max. It is always greater than or
|
||||
// equal to 0 and Min.
|
||||
if rng.Min < 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("min"), rng.Min, "min cannot be negative"))
|
||||
}
|
||||
if rng.Max < 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("max"), rng.Max, "max cannot be negative"))
|
||||
}
|
||||
if rng.Min > rng.Max {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("min"), rng.Min, "min cannot be greater than max"))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// validatePSPCapsAgainstDrops ensures an allowed cap is not listed in the required drops.
|
||||
func validatePSPCapsAgainstDrops(requiredDrops []api.Capability, capsToCheck []api.Capability, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if requiredDrops == nil {
|
||||
return allErrs
|
||||
}
|
||||
for _, cap := range capsToCheck {
|
||||
if hasCap(cap, requiredDrops) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, cap,
|
||||
fmt.Sprintf("capability is listed in %s and requiredDropCapabilities", fldPath.String())))
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// hasCap checks for needle in haystack.
|
||||
func hasCap(needle api.Capability, haystack []api.Capability) bool {
|
||||
for _, c := range haystack {
|
||||
if needle == c {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ValidatePodSecurityPolicyUpdate validates a PSP for updates.
|
||||
func ValidatePodSecurityPolicyUpdate(old *extensions.PodSecurityPolicy, new *extensions.PodSecurityPolicy) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&new.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata"))...)
|
||||
allErrs = append(allErrs, ValidatePodSecurityPolicySpecificAnnotations(new.Annotations, field.NewPath("metadata").Child("annotations"))...)
|
||||
allErrs = append(allErrs, ValidatePodSecurityPolicySpec(&new.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateNetworkPolicyName can be used to check whether the given networkpolicy
|
||||
// name is valid.
|
||||
func ValidateNetworkPolicyName(name string, prefix bool) []string {
|
||||
return apivalidation.NameIsDNSSubdomain(name, prefix)
|
||||
}
|
||||
|
||||
// ValidateNetworkPolicySpec tests if required fields in the networkpolicy spec are set.
|
||||
func ValidateNetworkPolicySpec(spec *extensions.NetworkPolicySpec, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(&spec.PodSelector, fldPath.Child("podSelector"))...)
|
||||
|
||||
// Validate ingress rules.
|
||||
for _, i := range spec.Ingress {
|
||||
// TODO: Update From to be a pointer to slice as soon as auto-generation supports it.
|
||||
for _, f := range i.From {
|
||||
numFroms := 0
|
||||
if f.PodSelector != nil {
|
||||
numFroms++
|
||||
allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(f.PodSelector, fldPath.Child("podSelector"))...)
|
||||
}
|
||||
if f.NamespaceSelector != nil {
|
||||
if numFroms > 0 {
|
||||
allErrs = append(allErrs, field.Forbidden(fldPath, "may not specify more than 1 from type"))
|
||||
} else {
|
||||
numFroms++
|
||||
allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(f.NamespaceSelector, fldPath.Child("namespaces"))...)
|
||||
}
|
||||
}
|
||||
|
||||
if numFroms == 0 {
|
||||
// At least one of PodSelector and NamespaceSelector must be defined.
|
||||
allErrs = append(allErrs, field.Required(fldPath, "must specify a from type"))
|
||||
}
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateNetworkPolicy validates a networkpolicy.
|
||||
func ValidateNetworkPolicy(np *extensions.NetworkPolicy) field.ErrorList {
|
||||
allErrs := apivalidation.ValidateObjectMeta(&np.ObjectMeta, true, ValidateNetworkPolicyName, field.NewPath("metadata"))
|
||||
allErrs = append(allErrs, ValidateNetworkPolicySpec(&np.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateNetworkPolicyUpdate tests if an update to a NetworkPolicy is valid.
|
||||
func ValidateNetworkPolicyUpdate(update, old *extensions.NetworkPolicy) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata"))...)
|
||||
if !reflect.DeepEqual(update.Spec, old.Spec) {
|
||||
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "updates to networkpolicy spec are forbidden."))
|
||||
}
|
||||
return allErrs
|
||||
}
|
2327
vendor/k8s.io/kubernetes/pkg/apis/extensions/validation/validation_test.go
generated
vendored
Normal file
2327
vendor/k8s.io/kubernetes/pkg/apis/extensions/validation/validation_test.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1033
vendor/k8s.io/kubernetes/pkg/apis/extensions/zz_generated.deepcopy.go
generated
vendored
Normal file
1033
vendor/k8s.io/kubernetes/pkg/apis/extensions/zz_generated.deepcopy.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue