Merge pull request #12020 from wojtek-t/move_to_storage
Move storage-related code to pkg/storage
This commit is contained in:
@@ -25,7 +25,8 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/storage"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/storage/etcd"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/test/integration/framework"
|
||||
@@ -33,7 +34,7 @@ import (
|
||||
|
||||
func TestSet(t *testing.T) {
|
||||
client := framework.NewEtcdClient()
|
||||
etcdStorage := tools.NewEtcdStorage(client, testapi.Codec(), "")
|
||||
etcdStorage := etcd.NewEtcdStorage(client, testapi.Codec(), "")
|
||||
framework.WithEtcdKey(func(key string) {
|
||||
testObject := api.ServiceAccount{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
if err := etcdStorage.Set(key, &testObject, nil, 0); err != nil {
|
||||
@@ -56,7 +57,7 @@ func TestSet(t *testing.T) {
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
client := framework.NewEtcdClient()
|
||||
etcdStorage := tools.NewEtcdStorage(client, testapi.Codec(), "")
|
||||
etcdStorage := etcd.NewEtcdStorage(client, testapi.Codec(), "")
|
||||
framework.WithEtcdKey(func(key string) {
|
||||
testObject := api.ServiceAccount{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
coded, err := testapi.Codec().Encode(&testObject)
|
||||
@@ -81,7 +82,7 @@ func TestGet(t *testing.T) {
|
||||
|
||||
func TestWatch(t *testing.T) {
|
||||
client := framework.NewEtcdClient()
|
||||
etcdStorage := tools.NewEtcdStorage(client, testapi.Codec(), etcdtest.PathPrefix())
|
||||
etcdStorage := etcd.NewEtcdStorage(client, testapi.Codec(), etcdtest.PathPrefix())
|
||||
framework.WithEtcdKey(func(key string) {
|
||||
key = etcdtest.AddPrefix(key)
|
||||
resp, err := client.Set(key, runtime.EncodeOrDie(testapi.Codec(), &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
@@ -91,7 +92,7 @@ func TestWatch(t *testing.T) {
|
||||
expectedVersion := resp.Node.ModifiedIndex
|
||||
|
||||
// watch should load the object at the current index
|
||||
w, err := etcdStorage.Watch(key, 0, tools.Everything)
|
||||
w, err := etcdStorage.Watch(key, 0, storage.Everything)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ import (
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/storage"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
"github.com/golang/glog"
|
||||
@@ -41,7 +41,7 @@ func NewEtcdClient() *etcd.Client {
|
||||
return etcd.NewClient([]string{})
|
||||
}
|
||||
|
||||
func NewEtcdStorage() (tools.StorageInterface, error) {
|
||||
func NewEtcdStorage() (storage.Interface, error) {
|
||||
return master.NewEtcdStorage(NewEtcdClient(), testapi.Version(), etcdtest.PathPrefix())
|
||||
}
|
||||
|
||||
|
@@ -35,7 +35,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/storage"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/admission/admit"
|
||||
"github.com/golang/glog"
|
||||
@@ -72,7 +72,7 @@ type MasterComponents struct {
|
||||
// Used to stop master components individually, and via MasterComponents.Stop
|
||||
once sync.Once
|
||||
// Kubernetes etcd storage, has embedded etcd client
|
||||
EtcdStorage tools.StorageInterface
|
||||
EtcdStorage storage.Interface
|
||||
}
|
||||
|
||||
// Config is a struct of configuration directives for NewMasterComponents.
|
||||
@@ -119,13 +119,13 @@ func NewMasterComponents(c *Config) *MasterComponents {
|
||||
}
|
||||
|
||||
// startMasterOrDie starts a kubernetes master and an httpserver to handle api requests
|
||||
func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Server, tools.StorageInterface) {
|
||||
func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Server, storage.Interface) {
|
||||
var m *master.Master
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
m.Handler.ServeHTTP(w, req)
|
||||
}))
|
||||
|
||||
var etcdStorage tools.StorageInterface
|
||||
var etcdStorage storage.Interface
|
||||
var err error
|
||||
if masterConfig == nil {
|
||||
etcdStorage, err = master.NewEtcdStorage(NewEtcdClient(), "", etcdtest.PathPrefix())
|
||||
|
Reference in New Issue
Block a user