Commit d2bd6a7f authored by zhengjiajin's avatar zhengjiajin

Remove kubectl create namespace dependencies on kubernetes/pkg/api

parent 7f991a3b
...@@ -19,8 +19,8 @@ package kubectl ...@@ -19,8 +19,8 @@ package kubectl
import ( import (
"fmt" "fmt"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/api"
) )
// NamespaceGeneratorV1 supports stable generation of a namespace // NamespaceGeneratorV1 supports stable generation of a namespace
...@@ -65,7 +65,7 @@ func (g *NamespaceGeneratorV1) StructuredGenerate() (runtime.Object, error) { ...@@ -65,7 +65,7 @@ func (g *NamespaceGeneratorV1) StructuredGenerate() (runtime.Object, error) {
if err := g.validate(); err != nil { if err := g.validate(); err != nil {
return nil, err return nil, err
} }
namespace := &api.Namespace{} namespace := &v1.Namespace{}
namespace.Name = g.Name namespace.Name = g.Name
return namespace, nil return namespace, nil
} }
......
...@@ -20,14 +20,14 @@ import ( ...@@ -20,14 +20,14 @@ import (
"reflect" "reflect"
"testing" "testing"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
) )
func TestNamespaceGenerate(t *testing.T) { func TestNamespaceGenerate(t *testing.T) {
tests := []struct { tests := []struct {
params map[string]interface{} params map[string]interface{}
expected *api.Namespace expected *v1.Namespace
expectErr bool expectErr bool
index int index int
}{ }{
...@@ -35,7 +35,7 @@ func TestNamespaceGenerate(t *testing.T) { ...@@ -35,7 +35,7 @@ func TestNamespaceGenerate(t *testing.T) {
params: map[string]interface{}{ params: map[string]interface{}{
"name": "foo", "name": "foo",
}, },
expected: &api.Namespace{ expected: &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "foo", Name: "foo",
}, },
...@@ -92,8 +92,8 @@ func TestNamespaceGenerate(t *testing.T) { ...@@ -92,8 +92,8 @@ func TestNamespaceGenerate(t *testing.T) {
case !test.expectErr && err == nil: case !test.expectErr && err == nil:
// do nothing and drop through // do nothing and drop through
} }
if !reflect.DeepEqual(obj.(*api.Namespace), test.expected) { if !reflect.DeepEqual(obj.(*v1.Namespace), test.expected) {
t.Errorf("\nexpected:\n%#v\nsaw:\n%#v", test.expected, obj.(*api.Namespace)) t.Errorf("\nexpected:\n%#v\nsaw:\n%#v", test.expected, obj.(*v1.Namespace))
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment