update testapi to eliminate redundant fields
This commit is contained in:
@@ -456,7 +456,7 @@ func TestExecutorFrameworkMessage(t *testing.T) {
|
|||||||
func NewTestPod(i int) *api.Pod {
|
func NewTestPod(i int) *api.Pod {
|
||||||
name := fmt.Sprintf("pod%d", i)
|
name := fmt.Sprintf("pod%d", i)
|
||||||
return &api.Pod{
|
return &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
|
@@ -264,7 +264,7 @@ func NewTestPod() (*api.Pod, int) {
|
|||||||
currentPodNum = currentPodNum + 1
|
currentPodNum = currentPodNum + 1
|
||||||
name := fmt.Sprintf("pod%d", currentPodNum)
|
name := fmt.Sprintf("pod%d", currentPodNum)
|
||||||
return &api.Pod{
|
return &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
|
@@ -37,11 +37,11 @@ func BenchmarkPodConversion(b *testing.B) {
|
|||||||
scheme := api.Scheme.Raw()
|
scheme := api.Scheme.Raw()
|
||||||
var result *api.Pod
|
var result *api.Pod
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
versionedObj, err := scheme.ConvertToVersion(&pod, testapi.Default.Version())
|
versionedObj, err := scheme.ConvertToVersion(&pod, testapi.Default.GroupVersion().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Conversion error: %v", err)
|
b.Fatalf("Conversion error: %v", err)
|
||||||
}
|
}
|
||||||
obj, err := scheme.ConvertToVersion(versionedObj, scheme.InternalVersions[testapi.Default.Group].String())
|
obj, err := scheme.ConvertToVersion(versionedObj, scheme.InternalVersions[testapi.Default.GroupVersion().Group].String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Conversion error: %v", err)
|
b.Fatalf("Conversion error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -65,11 +65,11 @@ func BenchmarkNodeConversion(b *testing.B) {
|
|||||||
scheme := api.Scheme.Raw()
|
scheme := api.Scheme.Raw()
|
||||||
var result *api.Node
|
var result *api.Node
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
versionedObj, err := scheme.ConvertToVersion(&node, testapi.Default.Version())
|
versionedObj, err := scheme.ConvertToVersion(&node, testapi.Default.GroupVersion().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Conversion error: %v", err)
|
b.Fatalf("Conversion error: %v", err)
|
||||||
}
|
}
|
||||||
obj, err := scheme.ConvertToVersion(versionedObj, scheme.InternalVersions[testapi.Default.Group].String())
|
obj, err := scheme.ConvertToVersion(versionedObj, scheme.InternalVersions[testapi.Default.GroupVersion().Group].String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Conversion error: %v", err)
|
b.Fatalf("Conversion error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -93,11 +93,11 @@ func BenchmarkReplicationControllerConversion(b *testing.B) {
|
|||||||
scheme := api.Scheme.Raw()
|
scheme := api.Scheme.Raw()
|
||||||
var result *api.ReplicationController
|
var result *api.ReplicationController
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
versionedObj, err := scheme.ConvertToVersion(&replicationController, testapi.Default.Version())
|
versionedObj, err := scheme.ConvertToVersion(&replicationController, testapi.Default.GroupVersion().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Conversion error: %v", err)
|
b.Fatalf("Conversion error: %v", err)
|
||||||
}
|
}
|
||||||
obj, err := scheme.ConvertToVersion(versionedObj, scheme.InternalVersions[testapi.Default.Group].String())
|
obj, err := scheme.ConvertToVersion(versionedObj, scheme.InternalVersions[testapi.Default.GroupVersion().Group].String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Conversion error: %v", err)
|
b.Fatalf("Conversion error: %v", err)
|
||||||
}
|
}
|
||||||
|
@@ -60,7 +60,7 @@ func doDeepCopyTest(t *testing.T, version, kind string, f *fuzz.Fuzzer) {
|
|||||||
|
|
||||||
func TestDeepCopySingleType(t *testing.T) {
|
func TestDeepCopySingleType(t *testing.T) {
|
||||||
for i := 0; i < *fuzzIters; i++ {
|
for i := 0; i < *fuzzIters; i++ {
|
||||||
for _, version := range []string{"", testapi.Default.Version()} {
|
for _, version := range []string{"", testapi.Default.GroupVersion().String()} {
|
||||||
f := apitesting.FuzzerFor(t, version, rand.NewSource(rand.Int63()))
|
f := apitesting.FuzzerFor(t, version, rand.NewSource(rand.Int63()))
|
||||||
doDeepCopyTest(t, version, "Pod", f)
|
doDeepCopyTest(t, version, "Pod", f)
|
||||||
}
|
}
|
||||||
|
@@ -101,7 +101,7 @@ func roundTripSame(t *testing.T, item runtime.Object, except ...string) {
|
|||||||
seed := rand.Int63()
|
seed := rand.Int63()
|
||||||
fuzzInternalObject(t, testapi.Default.InternalGroupVersion().String(), item, seed)
|
fuzzInternalObject(t, testapi.Default.InternalGroupVersion().String(), item, seed)
|
||||||
|
|
||||||
version := testapi.Default.VersionUnderTest
|
version := testapi.Default.GroupVersion().String()
|
||||||
codecs := []runtime.Codec{}
|
codecs := []runtime.Codec{}
|
||||||
for _, fn := range codecsToTest {
|
for _, fn := range codecsToTest {
|
||||||
codec, err := fn(version, item)
|
codec, err := fn(version, item)
|
||||||
|
@@ -30,7 +30,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api/latest"
|
"k8s.io/kubernetes/pkg/api/latest"
|
||||||
"k8s.io/kubernetes/pkg/api/meta"
|
"k8s.io/kubernetes/pkg/api/meta"
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
apiutil "k8s.io/kubernetes/pkg/api/util"
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -41,68 +41,57 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TestGroup struct {
|
type TestGroup struct {
|
||||||
// Name of the group
|
externalGroupVersion unversioned.GroupVersion
|
||||||
Group string
|
internalGroupVersion unversioned.GroupVersion
|
||||||
// Version of the group Group under test
|
|
||||||
VersionUnderTest string
|
|
||||||
// Group and Version. In most cases equals to Group + "/" + VersionUnverTest
|
|
||||||
GroupVersionUnderTest string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
kubeTestAPI := os.Getenv("KUBE_TEST_API")
|
kubeTestAPI := os.Getenv("KUBE_TEST_API")
|
||||||
if kubeTestAPI != "" {
|
if kubeTestAPI != "" {
|
||||||
testGroupVersions := strings.Split(kubeTestAPI, ",")
|
testGroupVersions := strings.Split(kubeTestAPI, ",")
|
||||||
for _, groupVersion := range testGroupVersions {
|
for _, gvString := range testGroupVersions {
|
||||||
// TODO: caesarxuchao: the apiutil package is hacky, it will be replaced
|
groupVersion := unversioned.ParseGroupVersionOrDie(gvString)
|
||||||
// by a following PR.
|
|
||||||
Groups[apiutil.GetGroup(groupVersion)] =
|
Groups[groupVersion.Group] = TestGroup{
|
||||||
TestGroup{apiutil.GetGroup(groupVersion), apiutil.GetVersion(groupVersion), groupVersion}
|
externalGroupVersion: groupVersion,
|
||||||
|
internalGroupVersion: unversioned.GroupVersion{Group: groupVersion.Group},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: caesarxuchao: we need a central place to store all available API
|
if _, ok := Groups[api.SchemeGroupVersion.Group]; !ok {
|
||||||
// groups and their metadata.
|
Groups[api.SchemeGroupVersion.Group] = TestGroup{
|
||||||
if _, ok := Groups[""]; !ok {
|
externalGroupVersion: unversioned.GroupVersion{Group: api.SchemeGroupVersion.Group, Version: latest.GroupOrDie(api.SchemeGroupVersion.Group).GroupVersion.Version},
|
||||||
// TODO: The second latest.GroupOrDie("").GroupVersion.Version will be latest.GroupVersion after we
|
internalGroupVersion: api.SchemeGroupVersion,
|
||||||
// have multiple group support
|
}
|
||||||
Groups[""] = TestGroup{"", latest.GroupOrDie("").GroupVersion.Version, latest.GroupOrDie("").GroupVersion.String()}
|
|
||||||
}
|
}
|
||||||
if _, ok := Groups["extensions"]; !ok {
|
if _, ok := Groups[extensions.SchemeGroupVersion.Group]; !ok {
|
||||||
Groups["extensions"] = TestGroup{"extensions", latest.GroupOrDie("extensions").GroupVersion.Version, latest.GroupOrDie("extensions").GroupVersion.String()}
|
Groups[extensions.SchemeGroupVersion.Group] = TestGroup{
|
||||||
|
externalGroupVersion: unversioned.GroupVersion{Group: extensions.SchemeGroupVersion.Group, Version: latest.GroupOrDie(extensions.SchemeGroupVersion.Group).GroupVersion.Version},
|
||||||
|
internalGroupVersion: extensions.SchemeGroupVersion,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Default = Groups[""]
|
Default = Groups[api.SchemeGroupVersion.Group]
|
||||||
Extensions = Groups["extensions"]
|
Extensions = Groups[extensions.SchemeGroupVersion.Group]
|
||||||
}
|
|
||||||
|
|
||||||
// Version returns the API version to test against, as set by the KUBE_TEST_API env var.
|
|
||||||
func (g TestGroup) Version() string {
|
|
||||||
return g.VersionUnderTest
|
|
||||||
}
|
|
||||||
|
|
||||||
// GroupAndVersion returns the API version to test against for a group, as set
|
|
||||||
// by the KUBE_TEST_API env var.
|
|
||||||
// Return value is in the form of "group/version".
|
|
||||||
func (g TestGroup) GroupAndVersion() string {
|
|
||||||
return g.GroupVersionUnderTest
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g TestGroup) GroupVersion() *unversioned.GroupVersion {
|
func (g TestGroup) GroupVersion() *unversioned.GroupVersion {
|
||||||
return &unversioned.GroupVersion{Group: g.Group, Version: g.VersionUnderTest}
|
copyOfGroupVersion := g.externalGroupVersion
|
||||||
|
return ©OfGroupVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// InternalGroupVersion returns the group,version used to identify the internal
|
// InternalGroupVersion returns the group,version used to identify the internal
|
||||||
// types for this API
|
// types for this API
|
||||||
func (g TestGroup) InternalGroupVersion() unversioned.GroupVersion {
|
func (g TestGroup) InternalGroupVersion() unversioned.GroupVersion {
|
||||||
return unversioned.GroupVersion{Group: g.Group}
|
return g.internalGroupVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// Codec returns the codec for the API version to test against, as set by the
|
// Codec returns the codec for the API version to test against, as set by the
|
||||||
// KUBE_TEST_API env var.
|
// KUBE_TEST_API env var.
|
||||||
func (g TestGroup) Codec() runtime.Codec {
|
func (g TestGroup) Codec() runtime.Codec {
|
||||||
// TODO: caesarxuchao: Restructure the body once we have a central `latest`.
|
// TODO: caesarxuchao: Restructure the body once we have a central `latest`.
|
||||||
interfaces, err := latest.GroupOrDie(g.Group).InterfacesFor(g.GroupVersionUnderTest)
|
interfaces, err := latest.GroupOrDie(g.externalGroupVersion.Group).InterfacesFor(g.externalGroupVersion.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -112,62 +101,39 @@ func (g TestGroup) Codec() runtime.Codec {
|
|||||||
// Converter returns the api.Scheme for the API version to test against, as set by the
|
// Converter returns the api.Scheme for the API version to test against, as set by the
|
||||||
// KUBE_TEST_API env var.
|
// KUBE_TEST_API env var.
|
||||||
func (g TestGroup) Converter() runtime.ObjectConvertor {
|
func (g TestGroup) Converter() runtime.ObjectConvertor {
|
||||||
// TODO: caesarxuchao: Restructure the body once we have a central `latest`.
|
interfaces, err := latest.GroupOrDie(g.externalGroupVersion.Group).InterfacesFor(g.externalGroupVersion.String())
|
||||||
if g.Group == "" {
|
if err != nil {
|
||||||
interfaces, err := latest.GroupOrDie("").InterfacesFor(g.VersionUnderTest)
|
panic(err)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return interfaces.ObjectConvertor
|
|
||||||
}
|
}
|
||||||
if g.Group == "extensions" {
|
return interfaces.ObjectConvertor
|
||||||
interfaces, err := latest.GroupOrDie("extensions").InterfacesFor(g.VersionUnderTest)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return interfaces.ObjectConvertor
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("cannot test group %s", g.Group))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetadataAccessor returns the MetadataAccessor for the API version to test against,
|
// MetadataAccessor returns the MetadataAccessor for the API version to test against,
|
||||||
// as set by the KUBE_TEST_API env var.
|
// as set by the KUBE_TEST_API env var.
|
||||||
func (g TestGroup) MetadataAccessor() meta.MetadataAccessor {
|
func (g TestGroup) MetadataAccessor() meta.MetadataAccessor {
|
||||||
// TODO: caesarxuchao: Restructure the body once we have a central `latest`.
|
interfaces, err := latest.GroupOrDie(g.externalGroupVersion.Group).InterfacesFor(g.externalGroupVersion.String())
|
||||||
if g.Group == "" {
|
if err != nil {
|
||||||
interfaces, err := latest.GroupOrDie("").InterfacesFor(g.VersionUnderTest)
|
panic(err)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return interfaces.MetadataAccessor
|
|
||||||
}
|
}
|
||||||
if g.Group == "extensions" {
|
return interfaces.MetadataAccessor
|
||||||
interfaces, err := latest.GroupOrDie("extensions").InterfacesFor(g.VersionUnderTest)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return interfaces.MetadataAccessor
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("cannot test group %s", g.Group))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelfLink returns a self link that will appear to be for the version Version().
|
// SelfLink returns a self link that will appear to be for the version Version().
|
||||||
// 'resource' should be the resource path, e.g. "pods" for the Pod type. 'name' should be
|
// 'resource' should be the resource path, e.g. "pods" for the Pod type. 'name' should be
|
||||||
// empty for lists.
|
// empty for lists.
|
||||||
func (g TestGroup) SelfLink(resource, name string) string {
|
func (g TestGroup) SelfLink(resource, name string) string {
|
||||||
if g.Group == "" {
|
if g.externalGroupVersion.Group == api.SchemeGroupVersion.Group {
|
||||||
if name == "" {
|
if name == "" {
|
||||||
return fmt.Sprintf("/api/%s/%s", g.Version(), resource)
|
return fmt.Sprintf("/api/%s/%s", g.externalGroupVersion.Version, resource)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("/api/%s/%s/%s", g.Version(), resource, name)
|
return fmt.Sprintf("/api/%s/%s/%s", g.externalGroupVersion.Version, resource, name)
|
||||||
} else {
|
} else {
|
||||||
// TODO: will need a /apis prefix once we have proper multi-group
|
// TODO: will need a /apis prefix once we have proper multi-group
|
||||||
// support
|
// support
|
||||||
if name == "" {
|
if name == "" {
|
||||||
return fmt.Sprintf("/apis/%s/%s/%s", g.Group, g.Version(), resource)
|
return fmt.Sprintf("/apis/%s/%s/%s", g.externalGroupVersion.Group, g.externalGroupVersion.Version, resource)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("/apis/%s/%s/%s/%s", g.Group, g.Version(), resource, name)
|
return fmt.Sprintf("/apis/%s/%s/%s/%s", g.externalGroupVersion.Group, g.externalGroupVersion.Version, resource, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,12 +142,12 @@ func (g TestGroup) SelfLink(resource, name string) string {
|
|||||||
// /api/v1/watch/namespaces/foo/pods/pod0 for v1.
|
// /api/v1/watch/namespaces/foo/pods/pod0 for v1.
|
||||||
func (g TestGroup) ResourcePathWithPrefix(prefix, resource, namespace, name string) string {
|
func (g TestGroup) ResourcePathWithPrefix(prefix, resource, namespace, name string) string {
|
||||||
var path string
|
var path string
|
||||||
if len(g.Group) == 0 {
|
if g.externalGroupVersion.Group == api.SchemeGroupVersion.Group {
|
||||||
path = "/api/" + g.Version()
|
path = "/api/" + g.externalGroupVersion.Version
|
||||||
} else {
|
} else {
|
||||||
// TODO: switch back once we have proper multiple group support
|
// TODO: switch back once we have proper multiple group support
|
||||||
// path = "/apis/" + g.Group + "/" + Version(group...)
|
// path = "/apis/" + g.Group + "/" + Version(group...)
|
||||||
path = "/apis/" + g.Group + "/" + g.Version()
|
path = "/apis/" + g.externalGroupVersion.Group + "/" + g.externalGroupVersion.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
if prefix != "" {
|
if prefix != "" {
|
||||||
@@ -209,28 +175,28 @@ func (g TestGroup) ResourcePath(resource, namespace, name string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g TestGroup) RESTMapper() meta.RESTMapper {
|
func (g TestGroup) RESTMapper() meta.RESTMapper {
|
||||||
return latest.GroupOrDie(g.Group).RESTMapper
|
return latest.GroupOrDie(g.externalGroupVersion.Group).RESTMapper
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get codec based on runtime.Object
|
// Get codec based on runtime.Object
|
||||||
func GetCodecForObject(obj runtime.Object) (runtime.Codec, error) {
|
func GetCodecForObject(obj runtime.Object) (runtime.Codec, error) {
|
||||||
gvk, err := api.Scheme.ObjectKind(obj)
|
kind, err := api.Scheme.ObjectKind(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unexpected encoding error: %v", err)
|
return nil, fmt.Errorf("unexpected encoding error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, group := range Groups {
|
for _, group := range Groups {
|
||||||
if group.GroupVersion().Group != gvk.Group {
|
if group.GroupVersion().Group != kind.Group {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if api.Scheme.Recognizes(gvk) {
|
if api.Scheme.Recognizes(kind) {
|
||||||
return group.Codec(), nil
|
return group.Codec(), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Codec used for unversioned types
|
// Codec used for unversioned types
|
||||||
if api.Scheme.Recognizes(gvk) {
|
if api.Scheme.Recognizes(kind) {
|
||||||
return api.Codec, nil
|
return api.Codec, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("unexpected kind: %v", gvk)
|
return nil, fmt.Errorf("unexpected kind: %v", kind)
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO these tests don't add much value for testing things that have groups
|
||||||
|
|
||||||
func TestResourcePathWithPrefix(t *testing.T) {
|
func TestResourcePathWithPrefix(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
prefix string
|
prefix string
|
||||||
@@ -28,11 +30,11 @@ func TestResourcePathWithPrefix(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{"prefix", "resource", "mynamespace", "myresource", "/api/" + Default.Version() + "/prefix/namespaces/mynamespace/resource/myresource"},
|
{"prefix", "resource", "mynamespace", "myresource", "/api/" + Default.GroupVersion().Version + "/prefix/namespaces/mynamespace/resource/myresource"},
|
||||||
{"prefix", "resource", "", "myresource", "/api/" + Default.Version() + "/prefix/resource/myresource"},
|
{"prefix", "resource", "", "myresource", "/api/" + Default.GroupVersion().Version + "/prefix/resource/myresource"},
|
||||||
{"prefix", "resource", "mynamespace", "", "/api/" + Default.Version() + "/prefix/namespaces/mynamespace/resource"},
|
{"prefix", "resource", "mynamespace", "", "/api/" + Default.GroupVersion().Version + "/prefix/namespaces/mynamespace/resource"},
|
||||||
{"prefix", "resource", "", "", "/api/" + Default.Version() + "/prefix/resource"},
|
{"prefix", "resource", "", "", "/api/" + Default.GroupVersion().Version + "/prefix/resource"},
|
||||||
{"", "resource", "mynamespace", "myresource", "/api/" + Default.Version() + "/namespaces/mynamespace/resource/myresource"},
|
{"", "resource", "mynamespace", "myresource", "/api/" + Default.GroupVersion().Version + "/namespaces/mynamespace/resource/myresource"},
|
||||||
}
|
}
|
||||||
for _, item := range testCases {
|
for _, item := range testCases {
|
||||||
if actual := Default.ResourcePathWithPrefix(item.prefix, item.resource, item.namespace, item.name); actual != item.expected {
|
if actual := Default.ResourcePathWithPrefix(item.prefix, item.resource, item.namespace, item.name); actual != item.expected {
|
||||||
@@ -48,10 +50,10 @@ func TestResourcePath(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{"resource", "mynamespace", "myresource", "/api/" + Default.Version() + "/namespaces/mynamespace/resource/myresource"},
|
{"resource", "mynamespace", "myresource", "/api/" + Default.GroupVersion().Version + "/namespaces/mynamespace/resource/myresource"},
|
||||||
{"resource", "", "myresource", "/api/" + Default.Version() + "/resource/myresource"},
|
{"resource", "", "myresource", "/api/" + Default.GroupVersion().Version + "/resource/myresource"},
|
||||||
{"resource", "mynamespace", "", "/api/" + Default.Version() + "/namespaces/mynamespace/resource"},
|
{"resource", "mynamespace", "", "/api/" + Default.GroupVersion().Version + "/namespaces/mynamespace/resource"},
|
||||||
{"resource", "", "", "/api/" + Default.Version() + "/resource"},
|
{"resource", "", "", "/api/" + Default.GroupVersion().Version + "/resource"},
|
||||||
}
|
}
|
||||||
for _, item := range testCases {
|
for _, item := range testCases {
|
||||||
if actual := Default.ResourcePath(item.resource, item.namespace, item.name); actual != item.expected {
|
if actual := Default.ResourcePath(item.resource, item.namespace, item.name); actual != item.expected {
|
||||||
|
@@ -18,3 +18,10 @@ package unversioned
|
|||||||
|
|
||||||
// SchemeGroupVersion is group version used to register these objects
|
// SchemeGroupVersion is group version used to register these objects
|
||||||
var SchemeGroupVersion = GroupVersion{Group: "", Version: ""}
|
var SchemeGroupVersion = GroupVersion{Group: "", Version: ""}
|
||||||
|
|
||||||
|
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
|
||||||
|
func Kind(kind string) GroupKind {
|
||||||
|
return SchemeGroupVersion.WithKind(kind).GroupKind()
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO this doesn't actually register them right now due to cycles.
|
||||||
|
@@ -28,7 +28,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func readPod(filename string) (string, error) {
|
func readPod(filename string) (string, error) {
|
||||||
data, err := ioutil.ReadFile("testdata/" + testapi.Default.Version() + "/" + filename)
|
data, err := ioutil.ReadFile("testdata/" + testapi.Default.GroupVersion().Version + "/" + filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,8 @@ func readPod(filename string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadSchemaForTest() (Schema, error) {
|
func loadSchemaForTest() (Schema, error) {
|
||||||
pathToSwaggerSpec := "../../../api/swagger-spec/" + testapi.Default.Version() + ".json"
|
// TODO this path is broken
|
||||||
|
pathToSwaggerSpec := "../../../api/swagger-spec/" + testapi.Default.GroupVersion().Version + ".json"
|
||||||
data, err := ioutil.ReadFile(pathToSwaggerSpec)
|
data, err := ioutil.ReadFile(pathToSwaggerSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@@ -806,7 +806,7 @@ func TestValidateEnv(t *testing.T) {
|
|||||||
Name: "abc",
|
Name: "abc",
|
||||||
ValueFrom: &api.EnvVarSource{
|
ValueFrom: &api.EnvVarSource{
|
||||||
FieldRef: &api.ObjectFieldSelector{
|
FieldRef: &api.ObjectFieldSelector{
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
FieldPath: "metadata.name",
|
FieldPath: "metadata.name",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -838,7 +838,7 @@ func TestValidateEnv(t *testing.T) {
|
|||||||
Value: "foo",
|
Value: "foo",
|
||||||
ValueFrom: &api.EnvVarSource{
|
ValueFrom: &api.EnvVarSource{
|
||||||
FieldRef: &api.ObjectFieldSelector{
|
FieldRef: &api.ObjectFieldSelector{
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
FieldPath: "metadata.name",
|
FieldPath: "metadata.name",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -851,7 +851,7 @@ func TestValidateEnv(t *testing.T) {
|
|||||||
Name: "abc",
|
Name: "abc",
|
||||||
ValueFrom: &api.EnvVarSource{
|
ValueFrom: &api.EnvVarSource{
|
||||||
FieldRef: &api.ObjectFieldSelector{
|
FieldRef: &api.ObjectFieldSelector{
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
@@ -876,7 +876,7 @@ func TestValidateEnv(t *testing.T) {
|
|||||||
ValueFrom: &api.EnvVarSource{
|
ValueFrom: &api.EnvVarSource{
|
||||||
FieldRef: &api.ObjectFieldSelector{
|
FieldRef: &api.ObjectFieldSelector{
|
||||||
FieldPath: "metadata.whoops",
|
FieldPath: "metadata.whoops",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
@@ -915,7 +915,7 @@ func TestValidateEnv(t *testing.T) {
|
|||||||
ValueFrom: &api.EnvVarSource{
|
ValueFrom: &api.EnvVarSource{
|
||||||
FieldRef: &api.ObjectFieldSelector{
|
FieldRef: &api.ObjectFieldSelector{
|
||||||
FieldPath: "status.phase",
|
FieldPath: "status.phase",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
|
4
pkg/client/cache/listwatch_test.go
vendored
4
pkg/client/cache/listwatch_test.go
vendored
@@ -55,7 +55,7 @@ func buildLocation(resourcePath string, query url.Values) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListWatchesCanList(t *testing.T) {
|
func TestListWatchesCanList(t *testing.T) {
|
||||||
fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(testapi.Default.Version())
|
fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(testapi.Default.GroupVersion().String())
|
||||||
table := []struct {
|
table := []struct {
|
||||||
location string
|
location string
|
||||||
resource string
|
resource string
|
||||||
@@ -105,7 +105,7 @@ func TestListWatchesCanList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListWatchesCanWatch(t *testing.T) {
|
func TestListWatchesCanWatch(t *testing.T) {
|
||||||
fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(testapi.Default.Version())
|
fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(testapi.Default.GroupVersion().String())
|
||||||
table := []struct {
|
table := []struct {
|
||||||
rv string
|
rv string
|
||||||
location string
|
location string
|
||||||
|
@@ -142,9 +142,9 @@ func (c *testClient) ValidateCommon(t *testing.T, err error) {
|
|||||||
validator, ok := c.QueryValidator[key]
|
validator, ok := c.QueryValidator[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
switch key {
|
switch key {
|
||||||
case unversioned.LabelSelectorQueryParam(testapi.Default.Version()):
|
case unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String()):
|
||||||
validator = validateLabels
|
validator = validateLabels
|
||||||
case unversioned.FieldSelectorQueryParam(testapi.Default.Version()):
|
case unversioned.FieldSelectorQueryParam(testapi.Default.GroupVersion().String()):
|
||||||
validator = validateFields
|
validator = validateFields
|
||||||
default:
|
default:
|
||||||
validator = func(a, b string) bool { return a == b }
|
validator = func(a, b string) bool { return a == b }
|
||||||
|
@@ -34,7 +34,7 @@ func createValidTestConfig() *clientcmdapi.Config {
|
|||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.Clusters["clean"] = &clientcmdapi.Cluster{
|
config.Clusters["clean"] = &clientcmdapi.Cluster{
|
||||||
Server: server,
|
Server: server,
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
}
|
}
|
||||||
config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
|
config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
|
||||||
Token: token,
|
Token: token,
|
||||||
@@ -89,7 +89,7 @@ func TestCertificateData(t *testing.T) {
|
|||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.Clusters["clean"] = &clientcmdapi.Cluster{
|
config.Clusters["clean"] = &clientcmdapi.Cluster{
|
||||||
Server: "https://localhost:8443",
|
Server: "https://localhost:8443",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
CertificateAuthorityData: caData,
|
CertificateAuthorityData: caData,
|
||||||
}
|
}
|
||||||
config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
|
config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
|
||||||
@@ -122,7 +122,7 @@ func TestBasicAuthData(t *testing.T) {
|
|||||||
config := clientcmdapi.NewConfig()
|
config := clientcmdapi.NewConfig()
|
||||||
config.Clusters["clean"] = &clientcmdapi.Cluster{
|
config.Clusters["clean"] = &clientcmdapi.Cluster{
|
||||||
Server: "https://localhost:8443",
|
Server: "https://localhost:8443",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
}
|
}
|
||||||
config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
|
config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
|
||||||
Username: username,
|
Username: username,
|
||||||
|
@@ -32,12 +32,12 @@ func TestEventSearch(t *testing.T) {
|
|||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: testapi.Default.ResourcePath("events", "baz", ""),
|
Path: testapi.Default.ResourcePath("events", "baz", ""),
|
||||||
Query: url.Values{
|
Query: url.Values{
|
||||||
unversioned.FieldSelectorQueryParam(testapi.Default.Version()): []string{
|
unversioned.FieldSelectorQueryParam(testapi.Default.GroupVersion().String()): []string{
|
||||||
getInvolvedObjectNameFieldLabel(testapi.Default.Version()) + "=foo,",
|
getInvolvedObjectNameFieldLabel(testapi.Default.GroupVersion().String()) + "=foo,",
|
||||||
"involvedObject.namespace=baz,",
|
"involvedObject.namespace=baz,",
|
||||||
"involvedObject.kind=Pod",
|
"involvedObject.kind=Pod",
|
||||||
},
|
},
|
||||||
unversioned.LabelSelectorQueryParam(testapi.Default.Version()): []string{},
|
unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String()): []string{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Response: Response{StatusCode: 200, Body: &api.EventList{}},
|
Response: Response{StatusCode: 200, Body: &api.EventList{}},
|
||||||
|
@@ -56,37 +56,37 @@ func TestNegotiateVersion(t *testing.T) {
|
|||||||
name: "server supports client default",
|
name: "server supports client default",
|
||||||
version: &uapi.GroupVersion{Version: "version1"},
|
version: &uapi.GroupVersion{Version: "version1"},
|
||||||
config: &unversioned.Config{},
|
config: &unversioned.Config{},
|
||||||
serverVersions: []string{"/version1", testapi.Default.Version()},
|
serverVersions: []string{"/version1", testapi.Default.GroupVersion().String()},
|
||||||
clientVersions: []uapi.GroupVersion{{Version: "version1"}, {Version: testapi.Default.Version()}},
|
clientVersions: []uapi.GroupVersion{{Version: "version1"}, *testapi.Default.GroupVersion()},
|
||||||
expectedVersion: &uapi.GroupVersion{Version: "version1"},
|
expectedVersion: &uapi.GroupVersion{Version: "version1"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "server falls back to client supported",
|
name: "server falls back to client supported",
|
||||||
version: &uapi.GroupVersion{Version: testapi.Default.Version()},
|
version: testapi.Default.GroupVersion(),
|
||||||
config: &unversioned.Config{},
|
config: &unversioned.Config{},
|
||||||
serverVersions: []string{"/version1"},
|
serverVersions: []string{"/version1"},
|
||||||
clientVersions: []uapi.GroupVersion{{Version: "version1"}, {Version: testapi.Default.Version()}},
|
clientVersions: []uapi.GroupVersion{{Version: "version1"}, *testapi.Default.GroupVersion()},
|
||||||
expectedVersion: &uapi.GroupVersion{Version: "version1"},
|
expectedVersion: &uapi.GroupVersion{Version: "version1"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "explicit version supported",
|
name: "explicit version supported",
|
||||||
config: &unversioned.Config{GroupVersion: testapi.Default.GroupVersion()},
|
config: &unversioned.Config{GroupVersion: testapi.Default.GroupVersion()},
|
||||||
serverVersions: []string{"/version1", testapi.Default.Version()},
|
serverVersions: []string{"/version1", testapi.Default.GroupVersion().String()},
|
||||||
clientVersions: []uapi.GroupVersion{{Version: "version1"}, {Version: testapi.Default.Version()}},
|
clientVersions: []uapi.GroupVersion{{Version: "version1"}, *testapi.Default.GroupVersion()},
|
||||||
expectedVersion: &uapi.GroupVersion{Version: testapi.Default.Version()},
|
expectedVersion: testapi.Default.GroupVersion(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "explicit version not supported",
|
name: "explicit version not supported",
|
||||||
config: &unversioned.Config{GroupVersion: testapi.Default.GroupVersion()},
|
config: &unversioned.Config{GroupVersion: testapi.Default.GroupVersion()},
|
||||||
serverVersions: []string{"/version1"},
|
serverVersions: []string{"/version1"},
|
||||||
clientVersions: []uapi.GroupVersion{{Version: "version1"}, {Version: testapi.Default.Version()}},
|
clientVersions: []uapi.GroupVersion{{Version: "version1"}, *testapi.Default.GroupVersion()},
|
||||||
expectErr: func(err error) bool { return strings.Contains(err.Error(), `server does not support API version "v1"`) },
|
expectErr: func(err error) bool { return strings.Contains(err.Error(), `server does not support API version "v1"`) },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "connection refused error",
|
name: "connection refused error",
|
||||||
config: &unversioned.Config{GroupVersion: testapi.Default.GroupVersion()},
|
config: &unversioned.Config{GroupVersion: testapi.Default.GroupVersion()},
|
||||||
serverVersions: []string{"/version1"},
|
serverVersions: []string{"/version1"},
|
||||||
clientVersions: []uapi.GroupVersion{{Version: "version1"}, {Version: testapi.Default.Version()}},
|
clientVersions: []uapi.GroupVersion{{Version: "version1"}, *testapi.Default.GroupVersion()},
|
||||||
sendErr: errors.New("connection refused"),
|
sendErr: errors.New("connection refused"),
|
||||||
expectErr: func(err error) bool { return strings.Contains(err.Error(), "connection refused") },
|
expectErr: func(err error) bool { return strings.Contains(err.Error(), "connection refused") },
|
||||||
},
|
},
|
||||||
|
@@ -199,8 +199,8 @@ func TestSetsCodec(t *testing.T) {
|
|||||||
Prefix string
|
Prefix string
|
||||||
Codec runtime.Codec
|
Codec runtime.Codec
|
||||||
}{
|
}{
|
||||||
testapi.Default.Version(): {false, "/api/" + testapi.Default.Version() + "/", testapi.Default.Codec()},
|
testapi.Default.GroupVersion().Version: {false, "/api/" + testapi.Default.GroupVersion().Version + "/", testapi.Default.Codec()},
|
||||||
"invalidVersion": {true, "", nil},
|
"invalidVersion": {true, "", nil},
|
||||||
}
|
}
|
||||||
for version, expected := range testCases {
|
for version, expected := range testCases {
|
||||||
client, err := New(&Config{Host: "127.0.0.1", GroupVersion: &unversioned.GroupVersion{Version: version}})
|
client, err := New(&Config{Host: "127.0.0.1", GroupVersion: &unversioned.GroupVersion{Version: version}})
|
||||||
@@ -243,13 +243,13 @@ func TestValidatesHostParameter(t *testing.T) {
|
|||||||
URL string
|
URL string
|
||||||
Err bool
|
Err bool
|
||||||
}{
|
}{
|
||||||
{"127.0.0.1", "", "http://127.0.0.1/" + testapi.Default.Version(), false},
|
{"127.0.0.1", "", "http://127.0.0.1/" + testapi.Default.GroupVersion().Version, false},
|
||||||
{"127.0.0.1:8080", "", "http://127.0.0.1:8080/" + testapi.Default.Version(), false},
|
{"127.0.0.1:8080", "", "http://127.0.0.1:8080/" + testapi.Default.GroupVersion().Version, false},
|
||||||
{"foo.bar.com", "", "http://foo.bar.com/" + testapi.Default.Version(), false},
|
{"foo.bar.com", "", "http://foo.bar.com/" + testapi.Default.GroupVersion().Version, false},
|
||||||
{"http://host/prefix", "", "http://host/prefix/" + testapi.Default.Version(), false},
|
{"http://host/prefix", "", "http://host/prefix/" + testapi.Default.GroupVersion().Version, false},
|
||||||
{"http://host", "", "http://host/" + testapi.Default.Version(), false},
|
{"http://host", "", "http://host/" + testapi.Default.GroupVersion().Version, false},
|
||||||
{"http://host", "/", "http://host/" + testapi.Default.Version(), false},
|
{"http://host", "/", "http://host/" + testapi.Default.GroupVersion().Version, false},
|
||||||
{"http://host", "/other", "http://host/other/" + testapi.Default.Version(), false},
|
{"http://host", "/other", "http://host/other/" + testapi.Default.GroupVersion().Version, false},
|
||||||
{"host/server", "", "", true},
|
{"host/server", "", "", true},
|
||||||
}
|
}
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
|
@@ -44,7 +44,7 @@ func TestListNodes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListNodesLabels(t *testing.T) {
|
func TestListNodesLabels(t *testing.T) {
|
||||||
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
|
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
|
||||||
c := &testClient{
|
c := &testClient{
|
||||||
Request: testRequest{
|
Request: testRequest{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
|
@@ -65,7 +65,7 @@ func TestListPods(t *testing.T) {
|
|||||||
|
|
||||||
func TestListPodsLabels(t *testing.T) {
|
func TestListPodsLabels(t *testing.T) {
|
||||||
ns := api.NamespaceDefault
|
ns := api.NamespaceDefault
|
||||||
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
|
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
|
||||||
c := &testClient{
|
c := &testClient{
|
||||||
Request: testRequest{
|
Request: testRequest{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
|
@@ -847,7 +847,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
|
|||||||
}
|
}
|
||||||
tmpStr := string(reqBodyExpected)
|
tmpStr := string(reqBodyExpected)
|
||||||
requestURL := testapi.Default.ResourcePathWithPrefix("foo", "bar", "", "baz")
|
requestURL := testapi.Default.ResourcePathWithPrefix("foo", "bar", "", "baz")
|
||||||
requestURL += "?" + unversioned.LabelSelectorQueryParam(testapi.Default.Version()) + "=name%3Dfoo&timeout=1s"
|
requestURL += "?" + unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String()) + "=name%3Dfoo&timeout=1s"
|
||||||
fakeHandler.ValidateRequest(t, requestURL, "POST", &tmpStr)
|
fakeHandler.ValidateRequest(t, requestURL, "POST", &tmpStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -887,7 +887,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
|
|||||||
}
|
}
|
||||||
tmpStr := string(reqBodyExpected)
|
tmpStr := string(reqBodyExpected)
|
||||||
requestURL := testapi.Default.ResourcePath("foo", "", "bar/baz")
|
requestURL := testapi.Default.ResourcePath("foo", "", "bar/baz")
|
||||||
requestURL += "?" + unversioned.LabelSelectorQueryParam(testapi.Default.Version()) + "=name%3Dfoo&timeout=1s"
|
requestURL += "?" + unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String()) + "=name%3Dfoo&timeout=1s"
|
||||||
fakeHandler.ValidateRequest(t, requestURL, "POST", &tmpStr)
|
fakeHandler.ValidateRequest(t, requestURL, "POST", &tmpStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ func TestDoRequestSuccess(t *testing.T) {
|
|||||||
if !reflect.DeepEqual(status, statusOut) {
|
if !reflect.DeepEqual(status, statusOut) {
|
||||||
t.Errorf("Unexpected mis-match. Expected %#v. Saw %#v", status, statusOut)
|
t.Errorf("Unexpected mis-match. Expected %#v. Saw %#v", status, statusOut)
|
||||||
}
|
}
|
||||||
fakeHandler.ValidateRequest(t, "/"+testapi.Default.Version()+"/test", "GET", nil)
|
fakeHandler.ValidateRequest(t, "/"+testapi.Default.GroupVersion().String()+"/test", "GET", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDoRequestFailed(t *testing.T) {
|
func TestDoRequestFailed(t *testing.T) {
|
||||||
@@ -137,5 +137,5 @@ func TestDoRequestCreated(t *testing.T) {
|
|||||||
if !reflect.DeepEqual(status, statusOut) {
|
if !reflect.DeepEqual(status, statusOut) {
|
||||||
t.Errorf("Unexpected mis-match. Expected %#v. Saw %#v", status, statusOut)
|
t.Errorf("Unexpected mis-match. Expected %#v. Saw %#v", status, statusOut)
|
||||||
}
|
}
|
||||||
fakeHandler.ValidateRequest(t, "/"+testapi.Default.Version()+"/test", "GET", nil)
|
fakeHandler.ValidateRequest(t, "/"+testapi.Default.GroupVersion().String()+"/test", "GET", nil)
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,7 @@ func TestListServices(t *testing.T) {
|
|||||||
|
|
||||||
func TestListServicesLabels(t *testing.T) {
|
func TestListServicesLabels(t *testing.T) {
|
||||||
ns := api.NamespaceDefault
|
ns := api.NamespaceDefault
|
||||||
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
|
labelSelectorQueryParamName := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
|
||||||
c := &testClient{
|
c := &testClient{
|
||||||
Request: testRequest{
|
Request: testRequest{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
|
@@ -50,7 +50,7 @@ func NewFakeControllerExpectationsLookup(ttl time.Duration) (*ControllerExpectat
|
|||||||
|
|
||||||
func newReplicationController(replicas int) *api.ReplicationController {
|
func newReplicationController(replicas int) *api.ReplicationController {
|
||||||
rc := &api.ReplicationController{
|
rc := &api.ReplicationController{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
UID: util.NewUUID(),
|
UID: util.NewUUID(),
|
||||||
Name: "foobar",
|
Name: "foobar",
|
||||||
|
@@ -49,7 +49,7 @@ func getKey(ds *extensions.DaemonSet, t *testing.T) string {
|
|||||||
|
|
||||||
func newDaemonSet(name string) *extensions.DaemonSet {
|
func newDaemonSet(name string) *extensions.DaemonSet {
|
||||||
return &extensions.DaemonSet{
|
return &extensions.DaemonSet{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Extensions.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Extensions.GroupVersion().String()},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
@@ -78,7 +78,7 @@ func newDaemonSet(name string) *extensions.DaemonSet {
|
|||||||
|
|
||||||
func newNode(name string, label map[string]string) *api.Node {
|
func newNode(name string, label map[string]string) *api.Node {
|
||||||
return &api.Node{
|
return &api.Node{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Labels: label,
|
Labels: label,
|
||||||
@@ -100,7 +100,7 @@ func addNodes(nodeStore cache.Store, startIndex, numNodes int, label map[string]
|
|||||||
|
|
||||||
func newPod(podName string, nodeName string, label map[string]string) *api.Pod {
|
func newPod(podName string, nodeName string, label map[string]string) *api.Pod {
|
||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
GenerateName: podName,
|
GenerateName: podName,
|
||||||
Labels: label,
|
Labels: label,
|
||||||
|
@@ -38,7 +38,7 @@ import (
|
|||||||
func addPods(store cache.Store, namespace string, nPods int, nPorts int, nNotReady int) {
|
func addPods(store cache.Store, namespace string, nPods int, nPorts int, nNotReady int) {
|
||||||
for i := 0; i < nPods+nNotReady; i++ {
|
for i := 0; i < nPods+nNotReady; i++ {
|
||||||
p := &api.Pod{
|
p := &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: fmt.Sprintf("pod%d", i),
|
Name: fmt.Sprintf("pod%d", i),
|
||||||
|
@@ -50,7 +50,7 @@ func getKey(rc *api.ReplicationController, t *testing.T) string {
|
|||||||
|
|
||||||
func newReplicationController(replicas int) *api.ReplicationController {
|
func newReplicationController(replicas int) *api.ReplicationController {
|
||||||
rc := &api.ReplicationController{
|
rc := &api.ReplicationController{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
UID: util.NewUUID(),
|
UID: util.NewUUID(),
|
||||||
Name: "foobar",
|
Name: "foobar",
|
||||||
|
@@ -111,7 +111,7 @@ func TestPodAndContainerAttach(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAttach(t *testing.T) {
|
func TestAttach(t *testing.T) {
|
||||||
version := testapi.Default.Version()
|
version := testapi.Default.GroupVersion().Version
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name, version, podPath, attachPath, container string
|
name, version, podPath, attachPath, container string
|
||||||
pod *api.Pod
|
pod *api.Pod
|
||||||
@@ -195,7 +195,7 @@ func TestAttach(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAttachWarnings(t *testing.T) {
|
func TestAttachWarnings(t *testing.T) {
|
||||||
version := testapi.Default.Version()
|
version := testapi.Default.GroupVersion().Version
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name, container, version, podPath, expectedErr, expectedOut string
|
name, container, version, podPath, expectedErr, expectedOut string
|
||||||
pod *api.Pod
|
pod *api.Pod
|
||||||
|
@@ -77,7 +77,7 @@ func versionErrIfFalse(b bool) error {
|
|||||||
return versionErr
|
return versionErr
|
||||||
}
|
}
|
||||||
|
|
||||||
var validVersion = testapi.Default.Version()
|
var validVersion = testapi.Default.GroupVersion().Version
|
||||||
var internalGV = unversioned.GroupVersion{Group: "apitest", Version: ""}
|
var internalGV = unversioned.GroupVersion{Group: "apitest", Version: ""}
|
||||||
var unlikelyGV = unversioned.GroupVersion{Group: "apitest", Version: "unlikelyversion"}
|
var unlikelyGV = unversioned.GroupVersion{Group: "apitest", Version: "unlikelyversion"}
|
||||||
var validVersionGV = unversioned.GroupVersion{Group: "apitest", Version: validVersion}
|
var validVersionGV = unversioned.GroupVersion{Group: "apitest", Version: validVersion}
|
||||||
|
@@ -577,13 +577,13 @@ func TestNewEmptyCluster(t *testing.T) {
|
|||||||
func TestAdditionalCluster(t *testing.T) {
|
func TestAdditionalCluster(t *testing.T) {
|
||||||
expectedConfig := newRedFederalCowHammerConfig()
|
expectedConfig := newRedFederalCowHammerConfig()
|
||||||
cluster := clientcmdapi.NewCluster()
|
cluster := clientcmdapi.NewCluster()
|
||||||
cluster.APIVersion = testapi.Default.Version()
|
cluster.APIVersion = testapi.Default.GroupVersion().String()
|
||||||
cluster.CertificateAuthority = "/ca-location"
|
cluster.CertificateAuthority = "/ca-location"
|
||||||
cluster.InsecureSkipTLSVerify = false
|
cluster.InsecureSkipTLSVerify = false
|
||||||
cluster.Server = "serverlocation"
|
cluster.Server = "serverlocation"
|
||||||
expectedConfig.Clusters["different-cluster"] = cluster
|
expectedConfig.Clusters["different-cluster"] = cluster
|
||||||
test := configCommandTest{
|
test := configCommandTest{
|
||||||
args: []string{"set-cluster", "different-cluster", "--" + clientcmd.FlagAPIServer + "=serverlocation", "--" + clientcmd.FlagInsecure + "=false", "--" + clientcmd.FlagCAFile + "=/ca-location", "--" + clientcmd.FlagAPIVersion + "=" + testapi.Default.Version()},
|
args: []string{"set-cluster", "different-cluster", "--" + clientcmd.FlagAPIServer + "=serverlocation", "--" + clientcmd.FlagInsecure + "=false", "--" + clientcmd.FlagCAFile + "=/ca-location", "--" + clientcmd.FlagAPIVersion + "=" + testapi.Default.GroupVersion().String()},
|
||||||
startingConfig: newRedFederalCowHammerConfig(),
|
startingConfig: newRedFederalCowHammerConfig(),
|
||||||
expectedConfig: expectedConfig,
|
expectedConfig: expectedConfig,
|
||||||
}
|
}
|
||||||
|
@@ -417,12 +417,12 @@ func TestDeleteMultipleSelector(t *testing.T) {
|
|||||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||||
switch p, m := req.URL.Path, req.Method; {
|
switch p, m := req.URL.Path, req.Method; {
|
||||||
case p == "/namespaces/test/pods" && m == "GET":
|
case p == "/namespaces/test/pods" && m == "GET":
|
||||||
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
|
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())) != "a=b" {
|
||||||
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
||||||
}
|
}
|
||||||
return &http.Response{StatusCode: 200, Body: objBody(codec, pods)}, nil
|
return &http.Response{StatusCode: 200, Body: objBody(codec, pods)}, nil
|
||||||
case p == "/namespaces/test/services" && m == "GET":
|
case p == "/namespaces/test/services" && m == "GET":
|
||||||
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
|
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())) != "a=b" {
|
||||||
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
||||||
}
|
}
|
||||||
return &http.Response{StatusCode: 200, Body: objBody(codec, svc)}, nil
|
return &http.Response{StatusCode: 200, Body: objBody(codec, svc)}, nil
|
||||||
|
@@ -157,7 +157,7 @@ func TestPodAndContainer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestExec(t *testing.T) {
|
func TestExec(t *testing.T) {
|
||||||
version := testapi.Default.Version()
|
version := testapi.Default.GroupVersion().Version
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name, version, podPath, execPath, container string
|
name, version, podPath, execPath, container string
|
||||||
pod *api.Pod
|
pod *api.Pod
|
||||||
|
@@ -147,9 +147,9 @@ func TestGetUnknownSchemaObject(t *testing.T) {
|
|||||||
//
|
//
|
||||||
// The expected behavior of the `kubectl get` command is:
|
// The expected behavior of the `kubectl get` command is:
|
||||||
// 1. objects using unrecognized schemes will always be returned using that scheme/version, "unlikelyversion" in this test;
|
// 1. objects using unrecognized schemes will always be returned using that scheme/version, "unlikelyversion" in this test;
|
||||||
// 2. if the specified output-version is a recognized, valid Scheme, then the list should use that scheme, and otherwise it will default to the client version, testapi.Default.Version() in this test;
|
// 2. if the specified output-version is a recognized, valid Scheme, then the list should use that scheme, and otherwise it will default to the client version, testapi.Default.GroupVersion().String() in this test;
|
||||||
// 3a. if the specified output-version is a recognized, valid Scheme, in which the requested object (replicationcontroller) can be represented, then the object should be returned using that version;
|
// 3a. if the specified output-version is a recognized, valid Scheme, in which the requested object (replicationcontroller) can be represented, then the object should be returned using that version;
|
||||||
// 3b. otherwise if the specified output-version is unrecognized, but the requested object (replicationcontroller) is recognized by the client's codec, then it will be converted to the client version, testapi.Default.Version() in this test.
|
// 3b. otherwise if the specified output-version is unrecognized, but the requested object (replicationcontroller) is recognized by the client's codec, then it will be converted to the client version, testapi.Default.GroupVersion().String() in this test.
|
||||||
func TestGetUnknownSchemaObjectListGeneric(t *testing.T) {
|
func TestGetUnknownSchemaObjectListGeneric(t *testing.T) {
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
outputVersion string
|
outputVersion string
|
||||||
@@ -158,26 +158,26 @@ func TestGetUnknownSchemaObjectListGeneric(t *testing.T) {
|
|||||||
rcVersion string
|
rcVersion string
|
||||||
}{
|
}{
|
||||||
"handles specific version": {
|
"handles specific version": {
|
||||||
outputVersion: testapi.Default.Version(),
|
outputVersion: testapi.Default.GroupVersion().String(),
|
||||||
listVersion: testapi.Default.Version(),
|
listVersion: testapi.Default.GroupVersion().String(),
|
||||||
testtypeVersion: unlikelyGV.String(),
|
testtypeVersion: unlikelyGV.String(),
|
||||||
rcVersion: testapi.Default.Version(),
|
rcVersion: testapi.Default.GroupVersion().String(),
|
||||||
},
|
},
|
||||||
"handles second specific version": {
|
"handles second specific version": {
|
||||||
outputVersion: "unlikely.group/unlikelyversion",
|
outputVersion: "unlikely.group/unlikelyversion",
|
||||||
listVersion: testapi.Default.Version(),
|
listVersion: testapi.Default.GroupVersion().String(),
|
||||||
testtypeVersion: unlikelyGV.String(),
|
testtypeVersion: unlikelyGV.String(),
|
||||||
rcVersion: testapi.Default.Version(), // see expected behavior 3b
|
rcVersion: testapi.Default.GroupVersion().String(), // see expected behavior 3b
|
||||||
},
|
},
|
||||||
"handles common version": {
|
"handles common version": {
|
||||||
outputVersion: testapi.Default.Version(),
|
outputVersion: testapi.Default.GroupVersion().String(),
|
||||||
listVersion: testapi.Default.Version(),
|
listVersion: testapi.Default.GroupVersion().String(),
|
||||||
testtypeVersion: unlikelyGV.String(),
|
testtypeVersion: unlikelyGV.String(),
|
||||||
rcVersion: testapi.Default.Version(),
|
rcVersion: testapi.Default.GroupVersion().String(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for k, test := range testCases {
|
for k, test := range testCases {
|
||||||
apiCodec := runtime.CodecFor(api.Scheme, testapi.Default.Version())
|
apiCodec := runtime.CodecFor(api.Scheme, testapi.Default.GroupVersion().String())
|
||||||
regularClient := &fake.RESTClient{
|
regularClient := &fake.RESTClient{
|
||||||
Codec: apiCodec,
|
Codec: apiCodec,
|
||||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||||
@@ -509,7 +509,7 @@ func TestGetMultipleTypeObjectsWithSelector(t *testing.T) {
|
|||||||
tf.Client = &fake.RESTClient{
|
tf.Client = &fake.RESTClient{
|
||||||
Codec: codec,
|
Codec: codec,
|
||||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||||
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
|
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())) != "a=b" {
|
||||||
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
||||||
}
|
}
|
||||||
switch req.URL.Path {
|
switch req.URL.Path {
|
||||||
@@ -635,7 +635,7 @@ func TestWatchSelector(t *testing.T) {
|
|||||||
tf.Client = &fake.RESTClient{
|
tf.Client = &fake.RESTClient{
|
||||||
Codec: codec,
|
Codec: codec,
|
||||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||||
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != "a=b" {
|
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())) != "a=b" {
|
||||||
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
||||||
}
|
}
|
||||||
switch req.URL.Path {
|
switch req.URL.Path {
|
||||||
|
@@ -44,7 +44,7 @@ func (f *fakePortForwarder) ForwardPorts(method string, url *url.URL, config *cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPortForward(t *testing.T) {
|
func TestPortForward(t *testing.T) {
|
||||||
version := testapi.Default.Version()
|
version := testapi.Default.GroupVersion().Version
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name, version, podPath, pfPath, container string
|
name, version, podPath, pfPath, container string
|
||||||
@@ -114,7 +114,7 @@ func TestPortForward(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPortForwardWithPFlag(t *testing.T) {
|
func TestPortForwardWithPFlag(t *testing.T) {
|
||||||
version := testapi.Default.Version()
|
version := testapi.Default.GroupVersion().Version
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name, version, podPath, pfPath, container string
|
name, version, podPath, pfPath, container string
|
||||||
|
@@ -207,7 +207,7 @@ func TestFlagUnderscoreRenaming(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadSchemaForTest() (validation.Schema, error) {
|
func loadSchemaForTest() (validation.Schema, error) {
|
||||||
pathToSwaggerSpec := "../../../../api/swagger-spec/" + testapi.Default.Version() + ".json"
|
pathToSwaggerSpec := "../../../../api/swagger-spec/" + testapi.Default.GroupVersion().Version + ".json"
|
||||||
data, err := ioutil.ReadFile(pathToSwaggerSpec)
|
data, err := ioutil.ReadFile(pathToSwaggerSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@@ -50,7 +50,7 @@ func TestMerge(t *testing.T) {
|
|||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fragment: fmt.Sprintf(`{ "apiVersion": "%s" }`, testapi.Default.Version()),
|
fragment: fmt.Sprintf(`{ "apiVersion": "%s" }`, testapi.Default.GroupVersion().String()),
|
||||||
expected: &api.Pod{
|
expected: &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
@@ -79,7 +79,7 @@ func TestMerge(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`, testapi.Default.Version()),
|
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`, testapi.Default.GroupVersion().String()),
|
||||||
expected: &api.Pod{
|
expected: &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
@@ -105,7 +105,7 @@ func TestMerge(t *testing.T) {
|
|||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`, testapi.Default.Version()),
|
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`, testapi.Default.GroupVersion().String()),
|
||||||
expected: &api.Pod{
|
expected: &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
@@ -146,7 +146,7 @@ func TestMerge(t *testing.T) {
|
|||||||
obj: &api.Service{
|
obj: &api.Service{
|
||||||
Spec: api.ServiceSpec{},
|
Spec: api.ServiceSpec{},
|
||||||
},
|
},
|
||||||
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "ports": [ { "port": 0 } ] } }`, testapi.Default.Version()),
|
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "ports": [ { "port": 0 } ] } }`, testapi.Default.GroupVersion().String()),
|
||||||
expected: &api.Service{
|
expected: &api.Service{
|
||||||
Spec: api.ServiceSpec{
|
Spec: api.ServiceSpec{
|
||||||
SessionAffinity: "None",
|
SessionAffinity: "None",
|
||||||
@@ -169,7 +169,7 @@ func TestMerge(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "selector": { "version": "v2" } } }`, testapi.Default.Version()),
|
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "selector": { "version": "v2" } } }`, testapi.Default.GroupVersion().String()),
|
||||||
expected: &api.Service{
|
expected: &api.Service{
|
||||||
Spec: api.ServiceSpec{
|
Spec: api.ServiceSpec{
|
||||||
SessionAffinity: "None",
|
SessionAffinity: "None",
|
||||||
|
@@ -504,7 +504,7 @@ func TestResourceByNameAndEmptySelector(t *testing.T) {
|
|||||||
|
|
||||||
func TestSelector(t *testing.T) {
|
func TestSelector(t *testing.T) {
|
||||||
pods, svc := testData()
|
pods, svc := testData()
|
||||||
labelKey := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
|
labelKey := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
|
||||||
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClientWith("", t, map[string]string{
|
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClientWith("", t, map[string]string{
|
||||||
"/namespaces/test/pods?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), pods),
|
"/namespaces/test/pods?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), pods),
|
||||||
"/namespaces/test/services?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), svc),
|
"/namespaces/test/services?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), svc),
|
||||||
@@ -799,7 +799,7 @@ func TestSingularRootScopedObject(t *testing.T) {
|
|||||||
|
|
||||||
func TestListObject(t *testing.T) {
|
func TestListObject(t *testing.T) {
|
||||||
pods, _ := testData()
|
pods, _ := testData()
|
||||||
labelKey := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
|
labelKey := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
|
||||||
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClientWith("", t, map[string]string{
|
b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClientWith("", t, map[string]string{
|
||||||
"/namespaces/test/pods?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), pods),
|
"/namespaces/test/pods?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), pods),
|
||||||
})).
|
})).
|
||||||
@@ -832,7 +832,7 @@ func TestListObject(t *testing.T) {
|
|||||||
|
|
||||||
func TestListObjectWithDifferentVersions(t *testing.T) {
|
func TestListObjectWithDifferentVersions(t *testing.T) {
|
||||||
pods, svc := testData()
|
pods, svc := testData()
|
||||||
labelKey := unversioned.LabelSelectorQueryParam(testapi.Default.Version())
|
labelKey := unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())
|
||||||
obj, err := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClientWith("", t, map[string]string{
|
obj, err := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClientWith("", t, map[string]string{
|
||||||
"/namespaces/test/pods?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), pods),
|
"/namespaces/test/pods?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), pods),
|
||||||
"/namespaces/test/services?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), svc),
|
"/namespaces/test/services?" + labelKey + "=a%3Db": runtime.EncodeOrDie(testapi.Default.Codec(), svc),
|
||||||
|
@@ -323,7 +323,7 @@ func TestHelperList(t *testing.T) {
|
|||||||
t.Errorf("url doesn't contain name: %#v", req.URL)
|
t.Errorf("url doesn't contain name: %#v", req.URL)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.Version())) != labels.SelectorFromSet(labels.Set{"foo": "baz"}).String() {
|
if req.URL.Query().Get(unversioned.LabelSelectorQueryParam(testapi.Default.GroupVersion().String())) != labels.SelectorFromSet(labels.Set{"foo": "baz"}).String() {
|
||||||
t.Errorf("url doesn't contain query parameters: %#v", req.URL)
|
t.Errorf("url doesn't contain query parameters: %#v", req.URL)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,7 @@ func TestHelperList(t *testing.T) {
|
|||||||
RESTClient: client,
|
RESTClient: client,
|
||||||
NamespaceScoped: true,
|
NamespaceScoped: true,
|
||||||
}
|
}
|
||||||
obj, err := modifier.List("bar", testapi.Default.Version(), labels.SelectorFromSet(labels.Set{"foo": "baz"}))
|
obj, err := modifier.List("bar", testapi.Default.GroupVersion().String(), labels.SelectorFromSet(labels.Set{"foo": "baz"}))
|
||||||
if (err != nil) != test.Err {
|
if (err != nil) != test.Err {
|
||||||
t.Errorf("unexpected error: %t %v", test.Err, err)
|
t.Errorf("unexpected error: %t %v", test.Err, err)
|
||||||
}
|
}
|
||||||
|
@@ -102,7 +102,7 @@ func TestPrinter(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
emptyListTest := &api.PodList{}
|
emptyListTest := &api.PodList{}
|
||||||
testapi, err := api.Scheme.ConvertToVersion(podTest, testapi.Default.Version())
|
testapi, err := api.Scheme.ConvertToVersion(podTest, testapi.Default.GroupVersion().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@@ -67,7 +67,7 @@ func TestExtractInvalidPods(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "Invalid volume name",
|
desc: "Invalid volume name",
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Volumes: []api.Volume{{Name: "_INVALID_"}},
|
Volumes: []api.Volume{{Name: "_INVALID_"}},
|
||||||
},
|
},
|
||||||
@@ -76,7 +76,7 @@ func TestExtractInvalidPods(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "Duplicate volume names",
|
desc: "Duplicate volume names",
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Volumes: []api.Volume{{Name: "repeated"}, {Name: "repeated"}},
|
Volumes: []api.Volume{{Name: "repeated"}, {Name: "repeated"}},
|
||||||
},
|
},
|
||||||
@@ -85,7 +85,7 @@ func TestExtractInvalidPods(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "Unspecified container name",
|
desc: "Unspecified container name",
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Containers: []api.Container{{Name: ""}},
|
Containers: []api.Container{{Name: ""}},
|
||||||
},
|
},
|
||||||
@@ -94,7 +94,7 @@ func TestExtractInvalidPods(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "Invalid container name",
|
desc: "Invalid container name",
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.Version()},
|
TypeMeta: unversioned.TypeMeta{APIVersion: testapi.Default.GroupVersion().String()},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Containers: []api.Container{{Name: "_INVALID_"}},
|
Containers: []api.Container{{Name: "_INVALID_"}},
|
||||||
},
|
},
|
||||||
@@ -294,7 +294,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
func TestURLWithHeader(t *testing.T) {
|
func TestURLWithHeader(t *testing.T) {
|
||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{
|
TypeMeta: unversioned.TypeMeta{
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
Kind: "Pod",
|
Kind: "Pod",
|
||||||
},
|
},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
@@ -67,14 +67,14 @@ func TestGenerateContainerRef(t *testing.T) {
|
|||||||
okPod = api.Pod{
|
okPod = api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{
|
TypeMeta: unversioned.TypeMeta{
|
||||||
Kind: "Pod",
|
Kind: "Pod",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
},
|
},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "ok",
|
Name: "ok",
|
||||||
Namespace: "test-ns",
|
Namespace: "test-ns",
|
||||||
UID: "bar",
|
UID: "bar",
|
||||||
ResourceVersion: "42",
|
ResourceVersion: "42",
|
||||||
SelfLink: "/api/" + testapi.Default.Version() + "/pods/foo",
|
SelfLink: "/api/" + testapi.Default.GroupVersion().String() + "/pods/foo",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
@@ -91,7 +91,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
|||||||
noSelfLinkPod.Kind = ""
|
noSelfLinkPod.Kind = ""
|
||||||
noSelfLinkPod.APIVersion = ""
|
noSelfLinkPod.APIVersion = ""
|
||||||
noSelfLinkPod.ObjectMeta.SelfLink = ""
|
noSelfLinkPod.ObjectMeta.SelfLink = ""
|
||||||
defaultedSelfLinkPod.ObjectMeta.SelfLink = "/api/" + testapi.Default.Version() + "/pods/ok"
|
defaultedSelfLinkPod.ObjectMeta.SelfLink = "/api/" + testapi.Default.GroupVersion().String() + "/pods/ok"
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -108,7 +108,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: &api.ObjectReference{
|
expected: &api.ObjectReference{
|
||||||
Kind: "Pod",
|
Kind: "Pod",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
Name: "ok",
|
Name: "ok",
|
||||||
Namespace: "test-ns",
|
Namespace: "test-ns",
|
||||||
UID: "bar",
|
UID: "bar",
|
||||||
@@ -123,7 +123,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
|||||||
container: &api.Container{},
|
container: &api.Container{},
|
||||||
expected: &api.ObjectReference{
|
expected: &api.ObjectReference{
|
||||||
Kind: "Pod",
|
Kind: "Pod",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
Name: "ok",
|
Name: "ok",
|
||||||
Namespace: "test-ns",
|
Namespace: "test-ns",
|
||||||
UID: "bar",
|
UID: "bar",
|
||||||
@@ -147,7 +147,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: &api.ObjectReference{
|
expected: &api.ObjectReference{
|
||||||
Kind: "Pod",
|
Kind: "Pod",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
Name: "ok",
|
Name: "ok",
|
||||||
Namespace: "test-ns",
|
Namespace: "test-ns",
|
||||||
UID: "bar",
|
UID: "bar",
|
||||||
@@ -164,7 +164,7 @@ func TestGenerateContainerRef(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expected: &api.ObjectReference{
|
expected: &api.ObjectReference{
|
||||||
Kind: "Pod",
|
Kind: "Pod",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
Name: "ok",
|
Name: "ok",
|
||||||
Namespace: "test-ns",
|
Namespace: "test-ns",
|
||||||
UID: "bar",
|
UID: "bar",
|
||||||
|
@@ -1337,7 +1337,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
|||||||
Name: "POD_NAME",
|
Name: "POD_NAME",
|
||||||
ValueFrom: &api.EnvVarSource{
|
ValueFrom: &api.EnvVarSource{
|
||||||
FieldRef: &api.ObjectFieldSelector{
|
FieldRef: &api.ObjectFieldSelector{
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
FieldPath: "metadata.name",
|
FieldPath: "metadata.name",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1346,7 +1346,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
|||||||
Name: "POD_NAMESPACE",
|
Name: "POD_NAMESPACE",
|
||||||
ValueFrom: &api.EnvVarSource{
|
ValueFrom: &api.EnvVarSource{
|
||||||
FieldRef: &api.ObjectFieldSelector{
|
FieldRef: &api.ObjectFieldSelector{
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
FieldPath: "metadata.namespace",
|
FieldPath: "metadata.namespace",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1355,7 +1355,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
|||||||
Name: "POD_IP",
|
Name: "POD_IP",
|
||||||
ValueFrom: &api.EnvVarSource{
|
ValueFrom: &api.EnvVarSource{
|
||||||
FieldRef: &api.ObjectFieldSelector{
|
FieldRef: &api.ObjectFieldSelector{
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
FieldPath: "status.podIP",
|
FieldPath: "status.podIP",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1383,7 +1383,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
|
|||||||
Name: "POD_NAME",
|
Name: "POD_NAME",
|
||||||
ValueFrom: &api.EnvVarSource{
|
ValueFrom: &api.EnvVarSource{
|
||||||
FieldRef: &api.ObjectFieldSelector{
|
FieldRef: &api.ObjectFieldSelector{
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
FieldPath: "metadata.name",
|
FieldPath: "metadata.name",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -69,8 +69,8 @@ func setUp(t *testing.T) (Master, *etcdtesting.EtcdTestServer, Config, *assert.A
|
|||||||
storageDestinations.AddAPIGroup(
|
storageDestinations.AddAPIGroup(
|
||||||
"extensions", etcdstorage.NewEtcdStorage(server.Client, testapi.Extensions.Codec(), etcdtest.PathPrefix()))
|
"extensions", etcdstorage.NewEtcdStorage(server.Client, testapi.Extensions.Codec(), etcdtest.PathPrefix()))
|
||||||
config.StorageDestinations = storageDestinations
|
config.StorageDestinations = storageDestinations
|
||||||
storageVersions[""] = testapi.Default.Version()
|
storageVersions[""] = testapi.Default.GroupVersion().String()
|
||||||
storageVersions["extensions"] = testapi.Extensions.GroupAndVersion()
|
storageVersions["extensions"] = testapi.Extensions.GroupVersion().String()
|
||||||
config.StorageVersions = storageVersions
|
config.StorageVersions = storageVersions
|
||||||
config.PublicAddress = net.ParseIP("192.168.10.4")
|
config.PublicAddress = net.ParseIP("192.168.10.4")
|
||||||
master.nodeRegistry = registrytest.NewNodeRegistry([]string{"node1", "node2"}, api.NodeResources{})
|
master.nodeRegistry = registrytest.NewNodeRegistry([]string{"node1", "node2"}, api.NodeResources{})
|
||||||
@@ -413,8 +413,8 @@ func TestDiscoveryAtAPIS(t *testing.T) {
|
|||||||
expectGroupName := "extensions"
|
expectGroupName := "extensions"
|
||||||
expectVersions := []unversioned.GroupVersionForDiscovery{
|
expectVersions := []unversioned.GroupVersionForDiscovery{
|
||||||
{
|
{
|
||||||
GroupVersion: testapi.Extensions.GroupAndVersion(),
|
GroupVersion: testapi.Extensions.GroupVersion().String(),
|
||||||
Version: testapi.Extensions.Version(),
|
Version: testapi.Extensions.GroupVersion().Version,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
expectPreferredVersion := unversioned.GroupVersionForDiscovery{
|
expectPreferredVersion := unversioned.GroupVersionForDiscovery{
|
||||||
|
@@ -51,7 +51,7 @@ func TestGetAttrs(t *testing.T) {
|
|||||||
Name: "foo",
|
Name: "foo",
|
||||||
Namespace: "baz",
|
Namespace: "baz",
|
||||||
UID: "long uid string",
|
UID: "long uid string",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
ResourceVersion: "0",
|
ResourceVersion: "0",
|
||||||
FieldPath: "",
|
FieldPath: "",
|
||||||
},
|
},
|
||||||
@@ -73,7 +73,7 @@ func TestGetAttrs(t *testing.T) {
|
|||||||
"involvedObject.name": "foo",
|
"involvedObject.name": "foo",
|
||||||
"involvedObject.namespace": "baz",
|
"involvedObject.namespace": "baz",
|
||||||
"involvedObject.uid": "long uid string",
|
"involvedObject.uid": "long uid string",
|
||||||
"involvedObject.apiVersion": testapi.Default.Version(),
|
"involvedObject.apiVersion": testapi.Default.GroupVersion().String(),
|
||||||
"involvedObject.resourceVersion": "0",
|
"involvedObject.resourceVersion": "0",
|
||||||
"involvedObject.fieldPath": "",
|
"involvedObject.fieldPath": "",
|
||||||
"reason": "ForTesting",
|
"reason": "ForTesting",
|
||||||
|
@@ -28,7 +28,7 @@ func TestDecodeList(t *testing.T) {
|
|||||||
pl := &api.List{
|
pl := &api.List{
|
||||||
Items: []runtime.Object{
|
Items: []runtime.Object{
|
||||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
||||||
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: testapi.Default.Version()}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"` + testapi.Default.Version() + `","metadata":{"name":"test"}}`)},
|
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: testapi.Default.GroupVersion().String()}, RawJSON: []byte(`{"kind":"Pod","apiVersion":"` + testapi.Default.GroupVersion().String() + `","metadata":{"name":"test"}}`)},
|
||||||
&runtime.Unstructured{TypeMeta: runtime.TypeMeta{Kind: "Foo", APIVersion: "Bar"}, Object: map[string]interface{}{"test": "value"}},
|
&runtime.Unstructured{TypeMeta: runtime.TypeMeta{Kind: "Foo", APIVersion: "Bar"}, Object: map[string]interface{}{"test": "value"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -26,13 +26,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestDecodeUnstructured(t *testing.T) {
|
func TestDecodeUnstructured(t *testing.T) {
|
||||||
version := testapi.Default.Version()
|
groupVersionString := testapi.Default.GroupVersion().String()
|
||||||
rawJson := fmt.Sprintf(`{"kind":"Pod","apiVersion":"%s","metadata":{"name":"test"}}`, version)
|
rawJson := fmt.Sprintf(`{"kind":"Pod","apiVersion":"%s","metadata":{"name":"test"}}`, groupVersionString)
|
||||||
pl := &api.List{
|
pl := &api.List{
|
||||||
Items: []runtime.Object{
|
Items: []runtime.Object{
|
||||||
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
&api.Pod{ObjectMeta: api.ObjectMeta{Name: "1"}},
|
||||||
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: version}, RawJSON: []byte(rawJson)},
|
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "Pod", APIVersion: groupVersionString}, RawJSON: []byte(rawJson)},
|
||||||
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "", APIVersion: version}, RawJSON: []byte(rawJson)},
|
&runtime.Unknown{TypeMeta: runtime.TypeMeta{Kind: "", APIVersion: groupVersionString}, RawJSON: []byte(rawJson)},
|
||||||
&runtime.Unstructured{TypeMeta: runtime.TypeMeta{Kind: "Foo", APIVersion: "Bar"}, Object: map[string]interface{}{"test": "value"}},
|
&runtime.Unstructured{TypeMeta: runtime.TypeMeta{Kind: "Foo", APIVersion: "Bar"}, Object: map[string]interface{}{"test": "value"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ func init() {
|
|||||||
scheme = runtime.NewScheme()
|
scheme = runtime.NewScheme()
|
||||||
scheme.AddKnownTypes(testapi.Default.InternalGroupVersion(), &storagetesting.TestResource{})
|
scheme.AddKnownTypes(testapi.Default.InternalGroupVersion(), &storagetesting.TestResource{})
|
||||||
scheme.AddKnownTypes(*testapi.Default.GroupVersion(), &storagetesting.TestResource{})
|
scheme.AddKnownTypes(*testapi.Default.GroupVersion(), &storagetesting.TestResource{})
|
||||||
codec = runtime.CodecFor(scheme, testapi.Default.Version())
|
codec = runtime.CodecFor(scheme, testapi.Default.GroupVersion().String())
|
||||||
scheme.AddConversionFuncs(
|
scheme.AddConversionFuncs(
|
||||||
func(in *storagetesting.TestResource, out *storagetesting.TestResource, s conversion.Scope) error {
|
func(in *storagetesting.TestResource, out *storagetesting.TestResource, s conversion.Scope) error {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
@@ -153,7 +153,7 @@ func makeCheckPod(ns string, nfsserver string) *api.Pod {
|
|||||||
return &api.Pod{
|
return &api.Pod{
|
||||||
TypeMeta: unversioned.TypeMeta{
|
TypeMeta: unversioned.TypeMeta{
|
||||||
Kind: "Pod",
|
Kind: "Pod",
|
||||||
APIVersion: testapi.Default.Version(),
|
APIVersion: testapi.Default.GroupVersion().String(),
|
||||||
},
|
},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
GenerateName: "checker-",
|
GenerateName: "checker-",
|
||||||
|
@@ -36,7 +36,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Proxy", func() {
|
var _ = Describe("Proxy", func() {
|
||||||
version := testapi.Default.Version()
|
version := testapi.Default.GroupVersion().Version
|
||||||
Context("version "+version, func() { proxyContext(version) })
|
Context("version "+version, func() { proxyContext(version) })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -79,7 +79,7 @@ func timeoutPath(resource, namespace, name string) string {
|
|||||||
var aPod string = `
|
var aPod string = `
|
||||||
{
|
{
|
||||||
"kind": "Pod",
|
"kind": "Pod",
|
||||||
"apiVersion": "` + testapi.Default.Version() + `",
|
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "a",
|
"name": "a",
|
||||||
"creationTimestamp": null%s
|
"creationTimestamp": null%s
|
||||||
@@ -97,7 +97,7 @@ var aPod string = `
|
|||||||
var aRC string = `
|
var aRC string = `
|
||||||
{
|
{
|
||||||
"kind": "ReplicationController",
|
"kind": "ReplicationController",
|
||||||
"apiVersion": "` + testapi.Default.Version() + `",
|
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "a",
|
"name": "a",
|
||||||
"labels": {
|
"labels": {
|
||||||
@@ -130,7 +130,7 @@ var aRC string = `
|
|||||||
var aService string = `
|
var aService string = `
|
||||||
{
|
{
|
||||||
"kind": "Service",
|
"kind": "Service",
|
||||||
"apiVersion": "` + testapi.Default.Version() + `",
|
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "a",
|
"name": "a",
|
||||||
"labels": {
|
"labels": {
|
||||||
@@ -154,7 +154,7 @@ var aService string = `
|
|||||||
var aNode string = `
|
var aNode string = `
|
||||||
{
|
{
|
||||||
"kind": "Node",
|
"kind": "Node",
|
||||||
"apiVersion": "` + testapi.Default.Version() + `",
|
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "a"%s
|
"name": "a"%s
|
||||||
},
|
},
|
||||||
@@ -166,7 +166,7 @@ var aNode string = `
|
|||||||
var aEvent string = `
|
var aEvent string = `
|
||||||
{
|
{
|
||||||
"kind": "Event",
|
"kind": "Event",
|
||||||
"apiVersion": "` + testapi.Default.Version() + `",
|
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "a"%s
|
"name": "a"%s
|
||||||
},
|
},
|
||||||
@@ -182,7 +182,7 @@ var aEvent string = `
|
|||||||
var aBinding string = `
|
var aBinding string = `
|
||||||
{
|
{
|
||||||
"kind": "Binding",
|
"kind": "Binding",
|
||||||
"apiVersion": "` + testapi.Default.Version() + `",
|
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "a"%s
|
"name": "a"%s
|
||||||
},
|
},
|
||||||
@@ -205,7 +205,7 @@ var emptyEndpoints string = `
|
|||||||
var aEndpoints string = `
|
var aEndpoints string = `
|
||||||
{
|
{
|
||||||
"kind": "Endpoints",
|
"kind": "Endpoints",
|
||||||
"apiVersion": "` + testapi.Default.Version() + `",
|
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "a"%s
|
"name": "a"%s
|
||||||
},
|
},
|
||||||
@@ -230,7 +230,7 @@ var aEndpoints string = `
|
|||||||
var deleteNow string = `
|
var deleteNow string = `
|
||||||
{
|
{
|
||||||
"kind": "DeleteOptions",
|
"kind": "DeleteOptions",
|
||||||
"apiVersion": "` + testapi.Default.Version() + `",
|
"apiVersion": "` + testapi.Default.GroupVersion().String() + `",
|
||||||
"gracePeriodSeconds": 0%s
|
"gracePeriodSeconds": 0%s
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@@ -236,7 +236,7 @@ func TestSchedulerExtender(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
policy.APIVersion = testapi.Default.Version()
|
policy.APIVersion = testapi.Default.GroupVersion().String()
|
||||||
|
|
||||||
schedulerConfigFactory := factory.NewConfigFactory(restClient, nil)
|
schedulerConfigFactory := factory.NewConfigFactory(restClient, nil)
|
||||||
schedulerConfig, err := schedulerConfigFactory.CreateFromConfig(policy)
|
schedulerConfig, err := schedulerConfigFactory.CreateFromConfig(policy)
|
||||||
|
@@ -139,9 +139,9 @@ func NewMasterConfig() *master.Config {
|
|||||||
etcdClient := NewEtcdClient()
|
etcdClient := NewEtcdClient()
|
||||||
storageVersions := make(map[string]string)
|
storageVersions := make(map[string]string)
|
||||||
etcdStorage := etcdstorage.NewEtcdStorage(etcdClient, testapi.Default.Codec(), etcdtest.PathPrefix())
|
etcdStorage := etcdstorage.NewEtcdStorage(etcdClient, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||||
storageVersions[""] = testapi.Default.GroupAndVersion()
|
storageVersions[""] = testapi.Default.GroupVersion().String()
|
||||||
expEtcdStorage := NewExtensionsEtcdStorage(etcdClient)
|
expEtcdStorage := NewExtensionsEtcdStorage(etcdClient)
|
||||||
storageVersions["extensions"] = testapi.Extensions.GroupAndVersion()
|
storageVersions["extensions"] = testapi.Extensions.GroupVersion().String()
|
||||||
storageDestinations := master.NewStorageDestinations()
|
storageDestinations := master.NewStorageDestinations()
|
||||||
storageDestinations.AddAPIGroup("", etcdStorage)
|
storageDestinations.AddAPIGroup("", etcdStorage)
|
||||||
storageDestinations.AddAPIGroup("extensions", expEtcdStorage)
|
storageDestinations.AddAPIGroup("extensions", expEtcdStorage)
|
||||||
|
@@ -56,11 +56,11 @@ func TestSecrets(t *testing.T) {
|
|||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
client := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()})
|
client := client.NewOrDie(&client.Config{Host: s.URL, GroupVersion: testapi.Default.GroupVersion()})
|
||||||
DoTestSecrets(t, client, testapi.Default.Version())
|
DoTestSecrets(t, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoTestSecrets test secrets for one api version.
|
// DoTestSecrets test secrets for one api version.
|
||||||
func DoTestSecrets(t *testing.T, client *client.Client, apiVersion string) {
|
func DoTestSecrets(t *testing.T, client *client.Client) {
|
||||||
// Make a secret object.
|
// Make a secret object.
|
||||||
ns := "ns"
|
ns := "ns"
|
||||||
s := api.Secret{
|
s := api.Secret{
|
||||||
|
Reference in New Issue
Block a user