mirror of https://github.com/k3s-io/k3s
Replace internal version of resource with external version for tests
parent
5e5f7e5389
commit
49852289de
|
@ -70,10 +70,6 @@ go_test(
|
||||||
],
|
],
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/apis/apps:go_default_library",
|
|
||||||
"//pkg/apis/batch:go_default_library",
|
|
||||||
"//pkg/apis/core:go_default_library",
|
|
||||||
"//pkg/apis/extensions:go_default_library",
|
|
||||||
"//pkg/controller:go_default_library",
|
"//pkg/controller:go_default_library",
|
||||||
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
"//staging/src/k8s.io/api/apps/v1beta1:go_default_library",
|
||||||
|
|
|
@ -19,16 +19,35 @@ package polymorphichelpers
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/kubernetes/pkg/apis/apps"
|
appsv1 "k8s.io/kubernetes/pkg/apis/apps"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
extensionsv1 "k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func canBeAutoscaled(kind schema.GroupKind) error {
|
func canBeAutoscaled(kind schema.GroupKind) error {
|
||||||
switch kind {
|
switch kind {
|
||||||
case api.Kind("ReplicationController"), extensions.Kind("ReplicaSet"),
|
case
|
||||||
extensions.Kind("Deployment"), apps.Kind("Deployment"), apps.Kind("ReplicaSet"):
|
schema.GroupKind{
|
||||||
|
Group: corev1.GroupName,
|
||||||
|
Kind: "ReplicationController",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: appsv1.GroupName,
|
||||||
|
Kind: "Deployment",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: appsv1.GroupName,
|
||||||
|
Kind: "ReplicaSet",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: extensionsv1.GroupName,
|
||||||
|
Kind: "Deployment",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: extensionsv1.GroupName,
|
||||||
|
Kind: "ReplicaSet",
|
||||||
|
}:
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("cannot autoscale a %v", kind)
|
return fmt.Errorf("cannot autoscale a %v", kind)
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCanBeAutoscaled(t *testing.T) {
|
func TestCanBeAutoscaled(t *testing.T) {
|
||||||
|
@ -29,11 +28,17 @@ func TestCanBeAutoscaled(t *testing.T) {
|
||||||
expectErr bool
|
expectErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
kind: api.Kind("ReplicationController"),
|
kind: schema.GroupKind{
|
||||||
|
Group: "",
|
||||||
|
Kind: "ReplicationController",
|
||||||
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: api.Kind("Node"),
|
kind: schema.GroupKind{
|
||||||
|
Group: "",
|
||||||
|
Kind: "Node",
|
||||||
|
},
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,44 @@ package polymorphichelpers
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
extensionsv1 "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/kubernetes/pkg/apis/apps"
|
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check whether the kind of resources could be exposed
|
// Check whether the kind of resources could be exposed
|
||||||
func canBeExposed(kind schema.GroupKind) error {
|
func canBeExposed(kind schema.GroupKind) error {
|
||||||
switch kind {
|
switch kind {
|
||||||
case api.Kind("ReplicationController"), api.Kind("Service"), api.Kind("Pod"),
|
case
|
||||||
extensions.Kind("Deployment"), apps.Kind("Deployment"), extensions.Kind("ReplicaSet"), apps.Kind("ReplicaSet"):
|
schema.GroupKind{
|
||||||
|
Group: corev1.GroupName,
|
||||||
|
Kind: "ReplicationController",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: corev1.GroupName,
|
||||||
|
Kind: "Service",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: corev1.GroupName,
|
||||||
|
Kind: "Pod",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: appsv1.GroupName,
|
||||||
|
Kind: "Deployment",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: appsv1.GroupName,
|
||||||
|
Kind: "ReplicaSet",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: extensionsv1.GroupName,
|
||||||
|
Kind: "Deployment",
|
||||||
|
},
|
||||||
|
schema.GroupKind{
|
||||||
|
Group: extensionsv1.GroupName,
|
||||||
|
Kind: "ReplicaSet",
|
||||||
|
}:
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("cannot expose a %s", kind)
|
return fmt.Errorf("cannot expose a %s", kind)
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCanBeExposed(t *testing.T) {
|
func TestCanBeExposed(t *testing.T) {
|
||||||
|
@ -29,11 +28,17 @@ func TestCanBeExposed(t *testing.T) {
|
||||||
expectErr bool
|
expectErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
kind: api.Kind("ReplicationController"),
|
kind: schema.GroupKind{
|
||||||
|
Group: "",
|
||||||
|
Kind: "ReplicationController",
|
||||||
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: api.Kind("Node"),
|
kind: schema.GroupKind{
|
||||||
|
Group: "",
|
||||||
|
Kind: "Node",
|
||||||
|
},
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
fakeexternal "k8s.io/client-go/kubernetes/fake"
|
fakeexternal "k8s.io/client-go/kubernetes/fake"
|
||||||
testcore "k8s.io/client-go/testing"
|
testcore "k8s.io/client-go/testing"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
"k8s.io/kubernetes/pkg/controller"
|
"k8s.io/kubernetes/pkg/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -119,18 +118,18 @@ func TestGetFirstPod(t *testing.T) {
|
||||||
watching: []watch.Event{
|
watching: []watch.Event{
|
||||||
{
|
{
|
||||||
Type: watch.Modified,
|
Type: watch.Modified,
|
||||||
Object: &api.Pod{
|
Object: &corev1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "pod-1",
|
Name: "pod-1",
|
||||||
Namespace: metav1.NamespaceDefault,
|
Namespace: metav1.NamespaceDefault,
|
||||||
CreationTimestamp: metav1.Date(2016, time.April, 1, 1, 0, 0, 0, time.UTC),
|
CreationTimestamp: metav1.Date(2016, time.April, 1, 1, 0, 0, 0, time.UTC),
|
||||||
Labels: map[string]string{"test": "selector"},
|
Labels: map[string]string{"test": "selector"},
|
||||||
},
|
},
|
||||||
Status: api.PodStatus{
|
Status: corev1.PodStatus{
|
||||||
Conditions: []api.PodCondition{
|
Conditions: []corev1.PodCondition{
|
||||||
{
|
{
|
||||||
Status: api.ConditionTrue,
|
Status: corev1.ConditionTrue,
|
||||||
Type: api.PodReady,
|
Type: corev1.PodReady,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,16 +21,16 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
apps "k8s.io/api/apps/v1"
|
||||||
|
batch "k8s.io/api/batch/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
"k8s.io/apimachinery/pkg/util/diff"
|
||||||
fakeexternal "k8s.io/client-go/kubernetes/fake"
|
fakeexternal "k8s.io/client-go/kubernetes/fake"
|
||||||
testclient "k8s.io/client-go/testing"
|
testclient "k8s.io/client-go/testing"
|
||||||
"k8s.io/kubernetes/pkg/apis/apps"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/batch"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -19,10 +19,10 @@ package polymorphichelpers
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMapBasedSelectorForObject(t *testing.T) {
|
func TestMapBasedSelectorForObject(t *testing.T) {
|
||||||
|
|
|
@ -20,8 +20,8 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDefaultObjectPauser(t *testing.T) {
|
func TestDefaultObjectPauser(t *testing.T) {
|
||||||
|
|
|
@ -20,8 +20,8 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDefaultObjectResumer(t *testing.T) {
|
func TestDefaultObjectResumer(t *testing.T) {
|
||||||
|
|
|
@ -21,9 +21,9 @@ import (
|
||||||
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPortsForObject(t *testing.T) {
|
func TestPortsForObject(t *testing.T) {
|
||||||
|
|
|
@ -21,9 +21,9 @@ import (
|
||||||
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
api "k8s.io/api/core/v1"
|
||||||
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProtocolsForObject(t *testing.T) {
|
func TestProtocolsForObject(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue