Stop exposing v1beta3 by default

This commit is contained in:
nikhiljindal
2015-06-29 19:30:14 -07:00
parent 9363285b4a
commit 274792d7bb
37 changed files with 117 additions and 242 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package util
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
@@ -26,6 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
)
@@ -45,7 +47,7 @@ func TestMerge(t *testing.T) {
Name: "foo",
},
},
fragment: `{ "apiVersion": "v1beta3" }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s" }`, testapi.Version()),
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
@@ -77,7 +79,7 @@ func TestMerge(t *testing.T) {
},
},
},
fragment: `{ "apiVersion": "v1beta3", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`, testapi.Version()),
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
@@ -103,7 +105,7 @@ func TestMerge(t *testing.T) {
Name: "foo",
},
},
fragment: `{ "apiVersion": "v1beta3", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`, testapi.Version()),
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
@@ -142,7 +144,7 @@ func TestMerge(t *testing.T) {
obj: &api.Service{
Spec: api.ServiceSpec{},
},
fragment: `{ "apiVersion": "v1beta3", "spec": { "ports": [ { "port": 0 } ] } }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "ports": [ { "port": 0 } ] } }`, testapi.Version()),
expected: &api.Service{
Spec: api.ServiceSpec{
SessionAffinity: "None",
@@ -165,145 +167,7 @@ func TestMerge(t *testing.T) {
},
},
},
fragment: `{ "apiVersion": "v1beta3", "spec": { "selector": { "version": "v2" } } }`,
expected: &api.Service{
Spec: api.ServiceSpec{
SessionAffinity: "None",
Type: api.ServiceTypeClusterIP,
Selector: map[string]string{
"version": "v2",
},
},
},
},
{
kind: "Pod",
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
},
fragment: `{ "apiVersion": "v1" }`,
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
},
},
/* TODO: uncomment this test once Merge is updated to use
strategic-merge-patch. See #8449.
{
kind: "Pod",
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
Containers: []api.Container{
api.Container{
Name: "c1",
Image: "red-image",
},
api.Container{
Name: "c2",
Image: "blue-image",
},
},
},
},
fragment: `{ "apiVersion": "v1", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`,
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
Containers: []api.Container{
api.Container{
Name: "c1",
Image: "green-image",
},
api.Container{
Name: "c2",
Image: "blue-image",
},
},
},
},
}, */
{
kind: "Pod",
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
},
fragment: `{ "apiVersion": "v1", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`,
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
Volumes: []api.Volume{
{
Name: "v1",
VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}},
},
{
Name: "v2",
VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}},
},
},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
},
},
{
kind: "Pod",
obj: &api.Pod{},
fragment: "invalid json",
expected: &api.Pod{},
expectErr: true,
},
{
kind: "Service",
obj: &api.Service{},
fragment: `{ "apiVersion": "badVersion" }`,
expectErr: true,
},
{
kind: "Service",
obj: &api.Service{
Spec: api.ServiceSpec{},
},
fragment: `{ "apiVersion": "v1", "spec": { "ports": [ { "port": 0 } ] } }`,
expected: &api.Service{
Spec: api.ServiceSpec{
SessionAffinity: "None",
Type: api.ServiceTypeClusterIP,
Ports: []api.ServicePort{
{
Protocol: api.ProtocolTCP,
Port: 0,
},
},
},
},
},
{
kind: "Service",
obj: &api.Service{
Spec: api.ServiceSpec{
Selector: map[string]string{
"version": "v1",
},
},
},
fragment: `{ "apiVersion": "v1", "spec": { "selector": { "version": "v2" } } }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "selector": { "version": "v2" } } }`, testapi.Version()),
expected: &api.Service{
Spec: api.ServiceSpec{
SessionAffinity: "None",