diff --git a/pkg/api/defaulting_test.go b/pkg/api/defaulting_test.go index bd1cc096a5..ab81d00b5b 100644 --- a/pkg/api/defaulting_test.go +++ b/pkg/api/defaulting_test.go @@ -53,44 +53,48 @@ func TestVerifyDefaulting(t *testing.T) { func TestDefaulting(t *testing.T) { // these are the known types with defaulters - you must add to this list if you add a top level defaulter typesWithDefaulting := map[unversioned.GroupVersionKind]struct{}{ - {Group: "", Version: "v1", Kind: "ConfigMap"}: {}, - {Group: "", Version: "v1", Kind: "ConfigMapList"}: {}, - {Group: "", Version: "v1", Kind: "Endpoints"}: {}, - {Group: "", Version: "v1", Kind: "EndpointsList"}: {}, - {Group: "", Version: "v1", Kind: "Namespace"}: {}, - {Group: "", Version: "v1", Kind: "NamespaceList"}: {}, - {Group: "", Version: "v1", Kind: "Node"}: {}, - {Group: "", Version: "v1", Kind: "NodeList"}: {}, - {Group: "", Version: "v1", Kind: "PersistentVolume"}: {}, - {Group: "", Version: "v1", Kind: "PersistentVolumeList"}: {}, - {Group: "", Version: "v1", Kind: "PersistentVolumeClaim"}: {}, - {Group: "", Version: "v1", Kind: "PersistentVolumeClaimList"}: {}, - {Group: "", Version: "v1", Kind: "PodAttachOptions"}: {}, - {Group: "", Version: "v1", Kind: "PodExecOptions"}: {}, - {Group: "", Version: "v1", Kind: "Pod"}: {}, - {Group: "", Version: "v1", Kind: "PodList"}: {}, - {Group: "", Version: "v1", Kind: "PodTemplate"}: {}, - {Group: "", Version: "v1", Kind: "PodTemplateList"}: {}, - {Group: "", Version: "v1", Kind: "ReplicationController"}: {}, - {Group: "", Version: "v1", Kind: "ReplicationControllerList"}: {}, - {Group: "", Version: "v1", Kind: "Secret"}: {}, - {Group: "", Version: "v1", Kind: "SecretList"}: {}, - {Group: "", Version: "v1", Kind: "Service"}: {}, - {Group: "", Version: "v1", Kind: "ServiceList"}: {}, - {Group: "apps", Version: "v1alpha1", Kind: "StatefulSet"}: {}, - {Group: "apps", Version: "v1alpha1", Kind: "StatefulSetList"}: {}, - {Group: "autoscaling", Version: "v1", Kind: "HorizontalPodAutoscaler"}: {}, - {Group: "autoscaling", Version: "v1", Kind: "HorizontalPodAutoscalerList"}: {}, - {Group: "batch", Version: "v1", Kind: "Job"}: {}, - {Group: "batch", Version: "v1", Kind: "JobList"}: {}, - {Group: "batch", Version: "v2alpha1", Kind: "Job"}: {}, - {Group: "batch", Version: "v2alpha1", Kind: "JobList"}: {}, - {Group: "batch", Version: "v2alpha1", Kind: "JobTemplate"}: {}, - {Group: "batch", Version: "v2alpha1", Kind: "ScheduledJob"}: {}, - {Group: "batch", Version: "v2alpha1", Kind: "ScheduledJobList"}: {}, - {Group: "componentconfig", Version: "v1alpha1", Kind: "KubeProxyConfiguration"}: {}, - {Group: "componentconfig", Version: "v1alpha1", Kind: "KubeSchedulerConfiguration"}: {}, - {Group: "componentconfig", Version: "v1alpha1", Kind: "KubeletConfiguration"}: {}, + {Group: "", Version: "v1", Kind: "ConfigMap"}: {}, + {Group: "", Version: "v1", Kind: "ConfigMapList"}: {}, + {Group: "", Version: "v1", Kind: "Endpoints"}: {}, + {Group: "", Version: "v1", Kind: "EndpointsList"}: {}, + {Group: "", Version: "v1", Kind: "Namespace"}: {}, + {Group: "", Version: "v1", Kind: "NamespaceList"}: {}, + {Group: "", Version: "v1", Kind: "Node"}: {}, + {Group: "", Version: "v1", Kind: "NodeList"}: {}, + {Group: "", Version: "v1", Kind: "PersistentVolume"}: {}, + {Group: "", Version: "v1", Kind: "PersistentVolumeList"}: {}, + {Group: "", Version: "v1", Kind: "PersistentVolumeClaim"}: {}, + {Group: "", Version: "v1", Kind: "PersistentVolumeClaimList"}: {}, + {Group: "", Version: "v1", Kind: "PodAttachOptions"}: {}, + {Group: "", Version: "v1", Kind: "PodExecOptions"}: {}, + {Group: "", Version: "v1", Kind: "Pod"}: {}, + {Group: "", Version: "v1", Kind: "PodList"}: {}, + {Group: "", Version: "v1", Kind: "PodTemplate"}: {}, + {Group: "", Version: "v1", Kind: "PodTemplateList"}: {}, + {Group: "", Version: "v1", Kind: "ReplicationController"}: {}, + {Group: "", Version: "v1", Kind: "ReplicationControllerList"}: {}, + {Group: "", Version: "v1", Kind: "Secret"}: {}, + {Group: "", Version: "v1", Kind: "SecretList"}: {}, + {Group: "", Version: "v1", Kind: "Service"}: {}, + {Group: "", Version: "v1", Kind: "ServiceList"}: {}, + {Group: "apps", Version: "v1alpha1", Kind: "StatefulSet"}: {}, + {Group: "apps", Version: "v1alpha1", Kind: "StatefulSetList"}: {}, + {Group: "autoscaling", Version: "v1", Kind: "HorizontalPodAutoscaler"}: {}, + {Group: "autoscaling", Version: "v1", Kind: "HorizontalPodAutoscalerList"}: {}, + {Group: "batch", Version: "v1", Kind: "Job"}: {}, + {Group: "batch", Version: "v1", Kind: "JobList"}: {}, + {Group: "batch", Version: "v2alpha1", Kind: "Job"}: {}, + {Group: "batch", Version: "v2alpha1", Kind: "JobList"}: {}, + {Group: "batch", Version: "v2alpha1", Kind: "JobTemplate"}: {}, + {Group: "batch", Version: "v2alpha1", Kind: "ScheduledJob"}: {}, + {Group: "batch", Version: "v2alpha1", Kind: "ScheduledJobList"}: {}, + {Group: "componentconfig", Version: "v1alpha1", Kind: "KubeProxyConfiguration"}: {}, + {Group: "componentconfig", Version: "v1alpha1", Kind: "KubeSchedulerConfiguration"}: {}, + {Group: "componentconfig", Version: "v1alpha1", Kind: "KubeletConfiguration"}: {}, + {Group: "kubeadm.k8s.io", Version: "v1alpha1", Kind: "MasterConfiguration"}: {}, + // This object contains only int fields which currently breaks the defaulting test because + // it's pretty stupid. Once we add non integer fields, we should uncomment this. + // {Group: "kubeadm.k8s.io", Version: "v1alpha1", Kind: "NodeConfiguration"}: {}, {Group: "extensions", Version: "v1beta1", Kind: "DaemonSet"}: {}, {Group: "extensions", Version: "v1beta1", Kind: "DaemonSetList"}: {}, {Group: "extensions", Version: "v1beta1", Kind: "Deployment"}: {}, diff --git a/pkg/api/testing/BUILD b/pkg/api/testing/BUILD index 8f83fe3bd7..a89214e7c7 100644 --- a/pkg/api/testing/BUILD +++ b/pkg/api/testing/BUILD @@ -19,6 +19,7 @@ go_library( ], tags = ["automanaged"], deps = [ + "//cmd/kubeadm/app/apis/kubeadm:go_default_library", "//pkg/api:go_default_library", "//pkg/api/resource:go_default_library", "//pkg/api/testapi:go_default_library", diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index cc6888e8e5..c95e67d652 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -23,6 +23,7 @@ import ( "strconv" "testing" + "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/resource" "k8s.io/kubernetes/pkg/api/testapi" @@ -538,6 +539,19 @@ func FuzzerFor(t *testing.T, version unversioned.GroupVersion, src rand.Source) // Set the bytes field on the RawExtension r.Raw = bytes }, + func(obj *kubeadm.MasterConfiguration, c fuzz.Continue) { + c.FuzzNoCustom(obj) + obj.KubernetesVersion = "v10" + obj.API.BindPort = 20 + obj.Discovery.BindPort = 20 + obj.Networking.ServiceSubnet = "foo" + obj.Networking.DNSDomain = "foo" + }, + func(obj *kubeadm.NodeConfiguration, c fuzz.Continue) { + c.FuzzNoCustom(obj) + obj.APIPort = 20 + obj.DiscoveryPort = 20 + }, ) return f }