mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	manually fix unit tests in pkg/api/v1
more manually fix pkg/api/v1 unit tests change ImportPrefix manually fix pkg/api unit tests
This commit is contained in:
		@@ -24,15 +24,16 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"github.com/google/gofuzz"
 | 
						"github.com/google/gofuzz"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						batchv2alpha1 "k8s.io/api/batch/v2alpha1"
 | 
				
			||||||
 | 
						apiv1 "k8s.io/api/core/v1"
 | 
				
			||||||
 | 
						extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
 | 
				
			||||||
	apitesting "k8s.io/apimachinery/pkg/api/testing"
 | 
						apitesting "k8s.io/apimachinery/pkg/api/testing"
 | 
				
			||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
						"k8s.io/apimachinery/pkg/runtime"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/runtime/schema"
 | 
						"k8s.io/apimachinery/pkg/runtime/schema"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/diff"
 | 
						"k8s.io/apimachinery/pkg/util/diff"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	apiv1 "k8s.io/api/core/v1"
 | 
						k8s_batchv2alpha1 "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
 | 
				
			||||||
	batchv2alpha1 "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
 | 
					 | 
				
			||||||
	extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type orderedGroupVersionKinds []schema.GroupVersionKind
 | 
					type orderedGroupVersionKinds []schema.GroupVersionKind
 | 
				
			||||||
@@ -45,7 +46,7 @@ func (o orderedGroupVersionKinds) Less(i, j int) bool {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestVerifyDefaulting(t *testing.T) {
 | 
					func TestVerifyDefaulting(t *testing.T) {
 | 
				
			||||||
	job := &batchv2alpha1.JobTemplate{}
 | 
						job := &batchv2alpha1.JobTemplate{}
 | 
				
			||||||
	batchv2alpha1.SetObjectDefaults_JobTemplate(job)
 | 
						k8s_batchv2alpha1.SetObjectDefaults_JobTemplate(job)
 | 
				
			||||||
	if job.Template.Spec.Template.Spec.DNSPolicy != apiv1.DNSClusterFirst {
 | 
						if job.Template.Spec.Template.Spec.DNSPolicy != apiv1.DNSClusterFirst {
 | 
				
			||||||
		t.Errorf("unexpected defaulting: %#v", job)
 | 
							t.Errorf("unexpected defaulting: %#v", job)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
 | 
				
			|||||||
		&announced.GroupMetaFactoryArgs{
 | 
							&announced.GroupMetaFactoryArgs{
 | 
				
			||||||
			GroupName:                  api.GroupName,
 | 
								GroupName:                  api.GroupName,
 | 
				
			||||||
			VersionPreferenceOrder:     []string{v1.SchemeGroupVersion.Version},
 | 
								VersionPreferenceOrder:     []string{v1.SchemeGroupVersion.Version},
 | 
				
			||||||
			ImportPrefix:               "k8s.io/kubernetes/pkg/api",
 | 
								ImportPrefix:               "k8s.io/api/core",
 | 
				
			||||||
			AddInternalObjectsToScheme: api.AddToScheme,
 | 
								AddInternalObjectsToScheme: api.AddToScheme,
 | 
				
			||||||
			RootScopedKinds: sets.NewString(
 | 
								RootScopedKinds: sets.NewString(
 | 
				
			||||||
				"Node",
 | 
									"Node",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,6 +30,7 @@ import (
 | 
				
			|||||||
	"github.com/ugorji/go/codec"
 | 
						"github.com/ugorji/go/codec"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/api/core/v1"
 | 
						"k8s.io/api/core/v1"
 | 
				
			||||||
 | 
						"k8s.io/api/extensions/v1beta1"
 | 
				
			||||||
	apiequality "k8s.io/apimachinery/pkg/api/equality"
 | 
						apiequality "k8s.io/apimachinery/pkg/api/equality"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/api/meta"
 | 
						"k8s.io/apimachinery/pkg/api/meta"
 | 
				
			||||||
	apitesting "k8s.io/apimachinery/pkg/api/testing"
 | 
						apitesting "k8s.io/apimachinery/pkg/api/testing"
 | 
				
			||||||
@@ -46,7 +47,7 @@ import (
 | 
				
			|||||||
	kapitesting "k8s.io/kubernetes/pkg/api/testing"
 | 
						kapitesting "k8s.io/kubernetes/pkg/api/testing"
 | 
				
			||||||
	k8s_api_v1 "k8s.io/kubernetes/pkg/api/v1"
 | 
						k8s_api_v1 "k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/extensions"
 | 
						"k8s.io/kubernetes/pkg/apis/extensions"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
 | 
						k8s_v1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// fuzzInternalObject fuzzes an arbitrary runtime object using the appropriate
 | 
					// fuzzInternalObject fuzzes an arbitrary runtime object using the appropriate
 | 
				
			||||||
@@ -77,7 +78,7 @@ func dataAsString(data []byte) string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func Convert_v1beta1_ReplicaSet_to_api_ReplicationController(in *v1beta1.ReplicaSet, out *api.ReplicationController, s conversion.Scope) error {
 | 
					func Convert_v1beta1_ReplicaSet_to_api_ReplicationController(in *v1beta1.ReplicaSet, out *api.ReplicationController, s conversion.Scope) error {
 | 
				
			||||||
	intermediate1 := &extensions.ReplicaSet{}
 | 
						intermediate1 := &extensions.ReplicaSet{}
 | 
				
			||||||
	if err := v1beta1.Convert_v1beta1_ReplicaSet_To_extensions_ReplicaSet(in, intermediate1, s); err != nil {
 | 
						if err := k8s_v1beta1.Convert_v1beta1_ReplicaSet_To_extensions_ReplicaSet(in, intermediate1, s); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,14 +17,13 @@ limitations under the License.
 | 
				
			|||||||
package v1_test
 | 
					package v1_test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
"k8s.io/api/core/v1"
 | 
					 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"k8s.io/api/core/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
						"k8s.io/apimachinery/pkg/runtime"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/validation/field"
 | 
						"k8s.io/apimachinery/pkg/util/validation/field"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/testing/compat"
 | 
						"k8s.io/kubernetes/pkg/api/testing/compat"
 | 
				
			||||||
	"k8s.io/api/core/v1"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/validation"
 | 
						"k8s.io/kubernetes/pkg/api/validation"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_ "k8s.io/kubernetes/pkg/api/install"
 | 
						_ "k8s.io/kubernetes/pkg/api/install"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,19 +17,19 @@ limitations under the License.
 | 
				
			|||||||
package v1_test
 | 
					package v1_test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
"k8s.io/api/core/v1"
 | 
					 | 
				
			||||||
	"net/url"
 | 
						"net/url"
 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"k8s.io/api/core/v1"
 | 
				
			||||||
	apiequality "k8s.io/apimachinery/pkg/api/equality"
 | 
						apiequality "k8s.io/apimachinery/pkg/api/equality"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/api/resource"
 | 
						"k8s.io/apimachinery/pkg/api/resource"
 | 
				
			||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
						"k8s.io/apimachinery/pkg/runtime"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/diff"
 | 
						"k8s.io/apimachinery/pkg/util/diff"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	"k8s.io/api/core/v1"
 | 
						k8s_api_v1 "k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestPodLogOptions(t *testing.T) {
 | 
					func TestPodLogOptions(t *testing.T) {
 | 
				
			||||||
@@ -39,7 +39,7 @@ func TestPodLogOptions(t *testing.T) {
 | 
				
			|||||||
	limitBytes := int64(3)
 | 
						limitBytes := int64(3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	versionedLogOptions := &v1.PodLogOptions{
 | 
						versionedLogOptions := &v1.PodLogOptions{
 | 
				
			||||||
		v1.Container:    "mycontainer",
 | 
							Container:    "mycontainer",
 | 
				
			||||||
		Follow:       true,
 | 
							Follow:       true,
 | 
				
			||||||
		Previous:     true,
 | 
							Previous:     true,
 | 
				
			||||||
		SinceSeconds: &sinceSeconds,
 | 
							SinceSeconds: &sinceSeconds,
 | 
				
			||||||
@@ -49,7 +49,7 @@ func TestPodLogOptions(t *testing.T) {
 | 
				
			|||||||
		LimitBytes:   &limitBytes,
 | 
							LimitBytes:   &limitBytes,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	unversionedLogOptions := &api.PodLogOptions{
 | 
						unversionedLogOptions := &api.PodLogOptions{
 | 
				
			||||||
		v1.Container:    "mycontainer",
 | 
							Container:    "mycontainer",
 | 
				
			||||||
		Follow:       true,
 | 
							Follow:       true,
 | 
				
			||||||
		Previous:     true,
 | 
							Previous:     true,
 | 
				
			||||||
		SinceSeconds: &sinceSeconds,
 | 
							SinceSeconds: &sinceSeconds,
 | 
				
			||||||
@@ -211,7 +211,7 @@ func TestResourceListConversion(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		// defaulting is a separate step from conversion that is applied when reading from the API or from etcd.
 | 
							// defaulting is a separate step from conversion that is applied when reading from the API or from etcd.
 | 
				
			||||||
		// perform that step explicitly.
 | 
							// perform that step explicitly.
 | 
				
			||||||
		v1.SetDefaults_ResourceList(&test.input)
 | 
							k8s_api_v1.SetDefaults_ResourceList(&test.input)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		err := api.Scheme.Convert(&test.input, &output, nil)
 | 
							err := api.Scheme.Convert(&test.input, &output, nil)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,17 +17,17 @@ limitations under the License.
 | 
				
			|||||||
package v1_test
 | 
					package v1_test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
"k8s.io/api/core/v1"
 | 
					 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"k8s.io/api/core/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/api/resource"
 | 
						"k8s.io/apimachinery/pkg/api/resource"
 | 
				
			||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
						"k8s.io/apimachinery/pkg/runtime"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/intstr"
 | 
						"k8s.io/apimachinery/pkg/util/intstr"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	"k8s.io/api/core/v1"
 | 
						k8s_api_v1 "k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
 | 
					func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
 | 
				
			||||||
@@ -61,7 +61,7 @@ func TestSetDefaultReplicationController(t *testing.T) {
 | 
				
			|||||||
			rc: &v1.ReplicationController{
 | 
								rc: &v1.ReplicationController{
 | 
				
			||||||
				Spec: v1.ReplicationControllerSpec{
 | 
									Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
					Template: &v1.PodTemplateSpec{
 | 
										Template: &v1.PodTemplateSpec{
 | 
				
			||||||
						v1.ObjectMeta: metav1.ObjectMeta{
 | 
											ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
							Labels: map[string]string{
 | 
												Labels: map[string]string{
 | 
				
			||||||
								"foo": "bar",
 | 
													"foo": "bar",
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
@@ -74,14 +74,14 @@ func TestSetDefaultReplicationController(t *testing.T) {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			rc: &v1.ReplicationController{
 | 
								rc: &v1.ReplicationController{
 | 
				
			||||||
				v1.ObjectMeta: metav1.ObjectMeta{
 | 
									ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
					Labels: map[string]string{
 | 
										Labels: map[string]string{
 | 
				
			||||||
						"bar": "foo",
 | 
											"bar": "foo",
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				Spec: v1.ReplicationControllerSpec{
 | 
									Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
					Template: &v1.PodTemplateSpec{
 | 
										Template: &v1.PodTemplateSpec{
 | 
				
			||||||
						v1.ObjectMeta: metav1.ObjectMeta{
 | 
											ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
							Labels: map[string]string{
 | 
												Labels: map[string]string{
 | 
				
			||||||
								"foo": "bar",
 | 
													"foo": "bar",
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
@@ -94,7 +94,7 @@ func TestSetDefaultReplicationController(t *testing.T) {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			rc: &v1.ReplicationController{
 | 
								rc: &v1.ReplicationController{
 | 
				
			||||||
				v1.ObjectMeta: metav1.ObjectMeta{
 | 
									ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
					Labels: map[string]string{
 | 
										Labels: map[string]string{
 | 
				
			||||||
						"bar": "foo",
 | 
											"bar": "foo",
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
@@ -104,7 +104,7 @@ func TestSetDefaultReplicationController(t *testing.T) {
 | 
				
			|||||||
						"some": "other",
 | 
											"some": "other",
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
					Template: &v1.PodTemplateSpec{
 | 
										Template: &v1.PodTemplateSpec{
 | 
				
			||||||
						v1.ObjectMeta: metav1.ObjectMeta{
 | 
											ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
							Labels: map[string]string{
 | 
												Labels: map[string]string{
 | 
				
			||||||
								"foo": "bar",
 | 
													"foo": "bar",
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
@@ -122,7 +122,7 @@ func TestSetDefaultReplicationController(t *testing.T) {
 | 
				
			|||||||
						"some": "other",
 | 
											"some": "other",
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
					Template: &v1.PodTemplateSpec{
 | 
										Template: &v1.PodTemplateSpec{
 | 
				
			||||||
						v1.ObjectMeta: metav1.ObjectMeta{
 | 
											ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
							Labels: map[string]string{
 | 
												Labels: map[string]string{
 | 
				
			||||||
								"foo": "bar",
 | 
													"foo": "bar",
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
@@ -175,7 +175,7 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
 | 
				
			|||||||
			rc: v1.ReplicationController{
 | 
								rc: v1.ReplicationController{
 | 
				
			||||||
				Spec: v1.ReplicationControllerSpec{
 | 
									Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
					Template: &v1.PodTemplateSpec{
 | 
										Template: &v1.PodTemplateSpec{
 | 
				
			||||||
						v1.ObjectMeta: metav1.ObjectMeta{
 | 
											ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
							Labels: map[string]string{
 | 
												Labels: map[string]string{
 | 
				
			||||||
								"foo": "bar",
 | 
													"foo": "bar",
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
@@ -190,7 +190,7 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
 | 
				
			|||||||
				Spec: v1.ReplicationControllerSpec{
 | 
									Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
					Replicas: newInt(0),
 | 
										Replicas: newInt(0),
 | 
				
			||||||
					Template: &v1.PodTemplateSpec{
 | 
										Template: &v1.PodTemplateSpec{
 | 
				
			||||||
						v1.ObjectMeta: metav1.ObjectMeta{
 | 
											ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
							Labels: map[string]string{
 | 
												Labels: map[string]string{
 | 
				
			||||||
								"foo": "bar",
 | 
													"foo": "bar",
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
@@ -205,7 +205,7 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
 | 
				
			|||||||
				Spec: v1.ReplicationControllerSpec{
 | 
									Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
					Replicas: newInt(3),
 | 
										Replicas: newInt(3),
 | 
				
			||||||
					Template: &v1.PodTemplateSpec{
 | 
										Template: &v1.PodTemplateSpec{
 | 
				
			||||||
						v1.ObjectMeta: metav1.ObjectMeta{
 | 
											ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
							Labels: map[string]string{
 | 
												Labels: map[string]string{
 | 
				
			||||||
								"foo": "bar",
 | 
													"foo": "bar",
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
@@ -473,7 +473,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
 | 
				
			|||||||
			rc: v1.ReplicationController{
 | 
								rc: v1.ReplicationController{
 | 
				
			||||||
				Spec: v1.ReplicationControllerSpec{
 | 
									Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
					Template: &v1.PodTemplateSpec{
 | 
										Template: &v1.PodTemplateSpec{
 | 
				
			||||||
						v1.ObjectMeta: metav1.ObjectMeta{
 | 
											ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
							Annotations: map[string]string{
 | 
												Annotations: map[string]string{
 | 
				
			||||||
								"pod.beta.kubernetes.io/init-containers": `
 | 
													"pod.beta.kubernetes.io/init-containers": `
 | 
				
			||||||
                                [
 | 
					                                [
 | 
				
			||||||
@@ -518,7 +518,7 @@ func TestSetDefaultReplicationControllerInitContainers(t *testing.T) {
 | 
				
			|||||||
			rc: v1.ReplicationController{
 | 
								rc: v1.ReplicationController{
 | 
				
			||||||
				Spec: v1.ReplicationControllerSpec{
 | 
									Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
					Template: &v1.PodTemplateSpec{
 | 
										Template: &v1.PodTemplateSpec{
 | 
				
			||||||
						v1.ObjectMeta: metav1.ObjectMeta{
 | 
											ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
							Annotations: map[string]string{
 | 
												Annotations: map[string]string{
 | 
				
			||||||
								"pod.beta.kubernetes.io/init-containers": `
 | 
													"pod.beta.kubernetes.io/init-containers": `
 | 
				
			||||||
                                [
 | 
					                                [
 | 
				
			||||||
@@ -676,8 +676,8 @@ func TestSetDefaultSecretVolumeSource(t *testing.T) {
 | 
				
			|||||||
	s := v1.PodSpec{}
 | 
						s := v1.PodSpec{}
 | 
				
			||||||
	s.Volumes = []v1.Volume{
 | 
						s.Volumes = []v1.Volume{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			v1.VolumeSource: v1.VolumeSource{
 | 
								VolumeSource: v1.VolumeSource{
 | 
				
			||||||
				v1.Secret: &v1.SecretVolumeSource{},
 | 
									Secret: &v1.SecretVolumeSource{},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -698,8 +698,8 @@ func TestSetDefaultConfigMapVolumeSource(t *testing.T) {
 | 
				
			|||||||
	s := v1.PodSpec{}
 | 
						s := v1.PodSpec{}
 | 
				
			||||||
	s.Volumes = []v1.Volume{
 | 
						s.Volumes = []v1.Volume{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			v1.VolumeSource: v1.VolumeSource{
 | 
								VolumeSource: v1.VolumeSource{
 | 
				
			||||||
				v1.ConfigMap: &v1.ConfigMapVolumeSource{},
 | 
									ConfigMap: &v1.ConfigMapVolumeSource{},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -720,7 +720,7 @@ func TestSetDefaultDownwardAPIVolumeSource(t *testing.T) {
 | 
				
			|||||||
	s := v1.PodSpec{}
 | 
						s := v1.PodSpec{}
 | 
				
			||||||
	s.Volumes = []v1.Volume{
 | 
						s.Volumes = []v1.Volume{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			v1.VolumeSource: v1.VolumeSource{
 | 
								VolumeSource: v1.VolumeSource{
 | 
				
			||||||
				DownwardAPI: &v1.DownwardAPIVolumeSource{},
 | 
									DownwardAPI: &v1.DownwardAPIVolumeSource{},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -742,7 +742,7 @@ func TestSetDefaultProjectedVolumeSource(t *testing.T) {
 | 
				
			|||||||
	s := v1.PodSpec{}
 | 
						s := v1.PodSpec{}
 | 
				
			||||||
	s.Volumes = []v1.Volume{
 | 
						s.Volumes = []v1.Volume{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			v1.VolumeSource: v1.VolumeSource{
 | 
								VolumeSource: v1.VolumeSource{
 | 
				
			||||||
				Projected: &v1.ProjectedVolumeSource{},
 | 
									Projected: &v1.ProjectedVolumeSource{},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -928,7 +928,7 @@ func TestSetDefaultPodSpecHostNetwork(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			Ports: []v1.ContainerPort{
 | 
								Ports: []v1.ContainerPort{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					v1.ContainerPort: portNum,
 | 
										ContainerPort: portNum,
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -937,7 +937,7 @@ func TestSetDefaultPodSpecHostNetwork(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			Ports: []v1.ContainerPort{
 | 
								Ports: []v1.ContainerPort{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					v1.ContainerPort: portNum,
 | 
										ContainerPort: portNum,
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -1105,7 +1105,7 @@ func TestSetMinimumScalePod(t *testing.T) {
 | 
				
			|||||||
	pod := &v1.Pod{
 | 
						pod := &v1.Pod{
 | 
				
			||||||
		Spec: s,
 | 
							Spec: s,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	v1.SetObjectDefaults_Pod(pod)
 | 
						k8s_api_v1.SetObjectDefaults_Pod(pod)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if expect := resource.MustParse("1m"); expect.Cmp(pod.Spec.Containers[0].Resources.Requests[v1.ResourceMemory]) != 0 {
 | 
						if expect := resource.MustParse("1m"); expect.Cmp(pod.Spec.Containers[0].Resources.Requests[v1.ResourceMemory]) != 0 {
 | 
				
			||||||
		t.Errorf("did not round resources: %#v", pod.Spec.Containers[0].Resources)
 | 
							t.Errorf("did not round resources: %#v", pod.Spec.Containers[0].Resources)
 | 
				
			||||||
@@ -1198,7 +1198,7 @@ func TestDefaultRequestIsNotSetForReplicationController(t *testing.T) {
 | 
				
			|||||||
		Spec: v1.ReplicationControllerSpec{
 | 
							Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
			Replicas: newInt(3),
 | 
								Replicas: newInt(3),
 | 
				
			||||||
			Template: &v1.PodTemplateSpec{
 | 
								Template: &v1.PodTemplateSpec{
 | 
				
			||||||
				v1.ObjectMeta: metav1.ObjectMeta{
 | 
									ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
					Labels: map[string]string{
 | 
										Labels: map[string]string{
 | 
				
			||||||
						"foo": "bar",
 | 
											"foo": "bar",
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
@@ -1218,7 +1218,7 @@ func TestDefaultRequestIsNotSetForReplicationController(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestSetDefaultLimitRangeItem(t *testing.T) {
 | 
					func TestSetDefaultLimitRangeItem(t *testing.T) {
 | 
				
			||||||
	limitRange := &v1.LimitRange{
 | 
						limitRange := &v1.LimitRange{
 | 
				
			||||||
		v1.ObjectMeta: metav1.ObjectMeta{
 | 
							ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
			Name: "test-defaults",
 | 
								Name: "test-defaults",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Spec: v1.LimitRangeSpec{
 | 
							Spec: v1.LimitRangeSpec{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,14 +24,14 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"k8s.io/api/core/v1"
 | 
				
			||||||
 | 
						"k8s.io/api/extensions/v1beta1"
 | 
				
			||||||
	apitesting "k8s.io/apimachinery/pkg/api/testing"
 | 
						apitesting "k8s.io/apimachinery/pkg/api/testing"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
						"k8s.io/apimachinery/pkg/runtime"
 | 
				
			||||||
	k8syaml "k8s.io/apimachinery/pkg/util/yaml"
 | 
						k8syaml "k8s.io/apimachinery/pkg/util/yaml"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/testapi"
 | 
						"k8s.io/kubernetes/pkg/api/testapi"
 | 
				
			||||||
	kapitesting "k8s.io/kubernetes/pkg/api/testing"
 | 
						kapitesting "k8s.io/kubernetes/pkg/api/testing"
 | 
				
			||||||
	"k8s.io/api/core/v1"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/ghodss/yaml"
 | 
						"github.com/ghodss/yaml"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,12 +20,10 @@ import (
 | 
				
			|||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rbacv1alpha1 "k8s.io/api/rbac/v1alpha1"
 | 
						"k8s.io/api/rbac/v1alpha1"
 | 
				
			||||||
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	rbacapi "k8s.io/kubernetes/pkg/apis/rbac"
 | 
						rbacapi "k8s.io/kubernetes/pkg/apis/rbac"
 | 
				
			||||||
	_ "k8s.io/kubernetes/pkg/apis/rbac/install"
 | 
						_ "k8s.io/kubernetes/pkg/apis/rbac/install"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/rbac/v1alpha1"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestConversion(t *testing.T) {
 | 
					func TestConversion(t *testing.T) {
 | 
				
			||||||
@@ -35,27 +33,27 @@ func TestConversion(t *testing.T) {
 | 
				
			|||||||
	}{
 | 
						}{
 | 
				
			||||||
		"specific user": {
 | 
							"specific user": {
 | 
				
			||||||
			old: &v1alpha1.RoleBinding{
 | 
								old: &v1alpha1.RoleBinding{
 | 
				
			||||||
				rbacv1alpha1.RoleRef: v1alpha1.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
									RoleRef:  v1alpha1.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
				
			||||||
				Subjects: []v1alpha1.Subject{{Kind: "User", APIVersion: v1alpha1.SchemeGroupVersion.String(), Name: "bob"}},
 | 
									Subjects: []v1alpha1.Subject{{Kind: "User", APIVersion: v1alpha1.SchemeGroupVersion.String(), Name: "bob"}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expected: &rbacapi.RoleBinding{
 | 
								expected: &rbacapi.RoleBinding{
 | 
				
			||||||
				rbacv1alpha1.RoleRef: rbacapi.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
									RoleRef:  rbacapi.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
				
			||||||
				Subjects: []rbacapi.Subject{{Kind: "User", APIGroup: v1alpha1.GroupName, Name: "bob"}},
 | 
									Subjects: []rbacapi.Subject{{Kind: "User", APIGroup: v1alpha1.GroupName, Name: "bob"}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		"wildcard user matches authenticated": {
 | 
							"wildcard user matches authenticated": {
 | 
				
			||||||
			old: &v1alpha1.RoleBinding{
 | 
								old: &v1alpha1.RoleBinding{
 | 
				
			||||||
				rbacv1alpha1.RoleRef: v1alpha1.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
									RoleRef:  v1alpha1.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
				
			||||||
				Subjects: []v1alpha1.Subject{{Kind: "User", APIVersion: v1alpha1.SchemeGroupVersion.String(), Name: "*"}},
 | 
									Subjects: []v1alpha1.Subject{{Kind: "User", APIVersion: v1alpha1.SchemeGroupVersion.String(), Name: "*"}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expected: &rbacapi.RoleBinding{
 | 
								expected: &rbacapi.RoleBinding{
 | 
				
			||||||
				rbacv1alpha1.RoleRef: rbacapi.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
									RoleRef:  rbacapi.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
				
			||||||
				Subjects: []rbacapi.Subject{{Kind: "Group", APIGroup: v1alpha1.GroupName, Name: "system:authenticated"}},
 | 
									Subjects: []rbacapi.Subject{{Kind: "Group", APIGroup: v1alpha1.GroupName, Name: "system:authenticated"}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		"missing api group gets defaulted": {
 | 
							"missing api group gets defaulted": {
 | 
				
			||||||
			old: &v1alpha1.RoleBinding{
 | 
								old: &v1alpha1.RoleBinding{
 | 
				
			||||||
				rbacv1alpha1.RoleRef: v1alpha1.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
									RoleRef: v1alpha1.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
				
			||||||
				Subjects: []v1alpha1.Subject{
 | 
									Subjects: []v1alpha1.Subject{
 | 
				
			||||||
					{Kind: "User", Name: "myuser"},
 | 
										{Kind: "User", Name: "myuser"},
 | 
				
			||||||
					{Kind: "Group", Name: "mygroup"},
 | 
										{Kind: "Group", Name: "mygroup"},
 | 
				
			||||||
@@ -63,7 +61,7 @@ func TestConversion(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expected: &rbacapi.RoleBinding{
 | 
								expected: &rbacapi.RoleBinding{
 | 
				
			||||||
				rbacv1alpha1.RoleRef: rbacapi.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
									RoleRef: rbacapi.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
				
			||||||
				Subjects: []rbacapi.Subject{
 | 
									Subjects: []rbacapi.Subject{
 | 
				
			||||||
					{Kind: "User", APIGroup: v1alpha1.GroupName, Name: "myuser"},
 | 
										{Kind: "User", APIGroup: v1alpha1.GroupName, Name: "myuser"},
 | 
				
			||||||
					{Kind: "Group", APIGroup: v1alpha1.GroupName, Name: "mygroup"},
 | 
										{Kind: "Group", APIGroup: v1alpha1.GroupName, Name: "mygroup"},
 | 
				
			||||||
@@ -73,7 +71,7 @@ func TestConversion(t *testing.T) {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		"bad api group gets defaulted": {
 | 
							"bad api group gets defaulted": {
 | 
				
			||||||
			old: &v1alpha1.RoleBinding{
 | 
								old: &v1alpha1.RoleBinding{
 | 
				
			||||||
				rbacv1alpha1.RoleRef: v1alpha1.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
									RoleRef: v1alpha1.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
				
			||||||
				Subjects: []v1alpha1.Subject{
 | 
									Subjects: []v1alpha1.Subject{
 | 
				
			||||||
					{Kind: "User", APIVersion: "rbac", Name: "myuser"},
 | 
										{Kind: "User", APIVersion: "rbac", Name: "myuser"},
 | 
				
			||||||
					{Kind: "Group", APIVersion: "rbac", Name: "mygroup"},
 | 
										{Kind: "Group", APIVersion: "rbac", Name: "mygroup"},
 | 
				
			||||||
@@ -84,7 +82,7 @@ func TestConversion(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expected: &rbacapi.RoleBinding{
 | 
								expected: &rbacapi.RoleBinding{
 | 
				
			||||||
				rbacv1alpha1.RoleRef: rbacapi.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
									RoleRef: rbacapi.RoleRef{Name: "foo", APIGroup: v1alpha1.GroupName},
 | 
				
			||||||
				Subjects: []rbacapi.Subject{
 | 
									Subjects: []rbacapi.Subject{
 | 
				
			||||||
					{Kind: "User", APIGroup: v1alpha1.GroupName, Name: "myuser"},
 | 
										{Kind: "User", APIGroup: v1alpha1.GroupName, Name: "myuser"},
 | 
				
			||||||
					{Kind: "Group", APIGroup: v1alpha1.GroupName, Name: "mygroup"},
 | 
										{Kind: "Group", APIGroup: v1alpha1.GroupName, Name: "mygroup"},
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user