mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Rename storage interfaces
This commit is contained in:
parent
d17985f1ad
commit
99d6b0e9f4
@ -217,7 +217,7 @@ func (s *APIServer) verifyClusterIPFlags() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEtcd(etcdConfigFile string, etcdServerList util.StringList, storageVersion string, pathPrefix string) (etcdStorage storage.StorageInterface, err error) {
|
func newEtcd(etcdConfigFile string, etcdServerList util.StringList, storageVersion string, pathPrefix string) (etcdStorage storage.Interface, err error) {
|
||||||
var client tools.EtcdClient
|
var client tools.EtcdClient
|
||||||
if etcdConfigFile != "" {
|
if etcdConfigFile != "" {
|
||||||
client, err = etcd.NewClientFromFile(etcdConfigFile)
|
client, err = etcd.NewClientFromFile(etcdConfigFile)
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewAuthenticator returns an authenticator.Request or an error
|
// NewAuthenticator returns an authenticator.Request or an error
|
||||||
func NewAuthenticator(basicAuthFile, clientCAFile, tokenFile, serviceAccountKeyFile string, serviceAccountLookup bool, storage storage.StorageInterface) (authenticator.Request, error) {
|
func NewAuthenticator(basicAuthFile, clientCAFile, tokenFile, serviceAccountKeyFile string, serviceAccountLookup bool, storage storage.Interface) (authenticator.Request, error) {
|
||||||
var authenticators []authenticator.Request
|
var authenticators []authenticator.Request
|
||||||
|
|
||||||
if len(basicAuthFile) > 0 {
|
if len(basicAuthFile) > 0 {
|
||||||
@ -104,7 +104,7 @@ func newAuthenticatorFromTokenFile(tokenAuthFile string) (authenticator.Request,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newServiceAccountAuthenticator returns an authenticator.Request or an error
|
// newServiceAccountAuthenticator returns an authenticator.Request or an error
|
||||||
func newServiceAccountAuthenticator(keyfile string, lookup bool, storage storage.StorageInterface) (authenticator.Request, error) {
|
func newServiceAccountAuthenticator(keyfile string, lookup bool, storage storage.Interface) (authenticator.Request, error) {
|
||||||
publicKey, err := serviceaccount.ReadPublicKey(keyfile)
|
publicKey, err := serviceaccount.ReadPublicKey(keyfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -88,7 +88,7 @@ const (
|
|||||||
|
|
||||||
// Config is a structure used to configure a Master.
|
// Config is a structure used to configure a Master.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
DatabaseStorage storage.StorageInterface
|
DatabaseStorage storage.Interface
|
||||||
EventTTL time.Duration
|
EventTTL time.Duration
|
||||||
MinionRegexp string
|
MinionRegexp string
|
||||||
KubeletClient client.KubeletClient
|
KubeletClient client.KubeletClient
|
||||||
@ -224,9 +224,9 @@ type Master struct {
|
|||||||
clock util.Clock
|
clock util.Clock
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEtcdStorage returns a StorageInterface for the provided arguments or an error if the version
|
// NewEtcdStorage returns a storage.Interface for the provided arguments or an error if the version
|
||||||
// is incorrect.
|
// is incorrect.
|
||||||
func NewEtcdStorage(client tools.EtcdClient, version string, prefix string) (etcdStorage storage.StorageInterface, err error) {
|
func NewEtcdStorage(client tools.EtcdClient, version string, prefix string) (etcdStorage storage.Interface, err error) {
|
||||||
if version == "" {
|
if version == "" {
|
||||||
version = latest.Version
|
version = latest.Version
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ type REST struct {
|
|||||||
var controllerPrefix = "/controllers"
|
var controllerPrefix = "/controllers"
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against replication controllers.
|
// NewREST returns a RESTStorage object that will work against replication controllers.
|
||||||
func NewREST(s storage.StorageInterface) *REST {
|
func NewREST(s storage.Interface) *REST {
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.ReplicationController{} },
|
NewFunc: func() runtime.Object { return &api.ReplicationController{} },
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ const (
|
|||||||
FAIL
|
FAIL
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
||||||
|
@ -33,7 +33,7 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStorage returns a RESTStorage object that will work against endpoints.
|
// NewStorage returns a RESTStorage object that will work against endpoints.
|
||||||
func NewStorage(s storage.StorageInterface) *REST {
|
func NewStorage(s storage.Interface) *REST {
|
||||||
prefix := "/services/endpoints"
|
prefix := "/services/endpoints"
|
||||||
return &REST{
|
return &REST{
|
||||||
&etcdgeneric.Etcd{
|
&etcdgeneric.Etcd{
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
||||||
|
@ -45,15 +45,15 @@ const (
|
|||||||
// Registry implements BindingRegistry, ControllerRegistry, EndpointRegistry,
|
// Registry implements BindingRegistry, ControllerRegistry, EndpointRegistry,
|
||||||
// MinionRegistry, PodRegistry and ServiceRegistry, backed by etcd.
|
// MinionRegistry, PodRegistry and ServiceRegistry, backed by etcd.
|
||||||
type Registry struct {
|
type Registry struct {
|
||||||
storage.StorageInterface
|
storage.Interface
|
||||||
pods pod.Registry
|
pods pod.Registry
|
||||||
endpoints endpoint.Registry
|
endpoints endpoint.Registry
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRegistry creates an etcd registry.
|
// NewRegistry creates an etcd registry.
|
||||||
func NewRegistry(storage storage.StorageInterface, pods pod.Registry, endpoints endpoint.Registry) *Registry {
|
func NewRegistry(storage storage.Interface, pods pod.Registry, endpoints endpoint.Registry) *Registry {
|
||||||
registry := &Registry{
|
registry := &Registry{
|
||||||
StorageInterface: storage,
|
Interface: storage,
|
||||||
pods: pods,
|
pods: pods,
|
||||||
endpoints: endpoints,
|
endpoints: endpoints,
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ type registry struct {
|
|||||||
|
|
||||||
// NewEtcdRegistry returns a registry which will store Events in the given
|
// NewEtcdRegistry returns a registry which will store Events in the given
|
||||||
// EtcdStorage. ttl is the time that Events will be retained by the system.
|
// EtcdStorage. ttl is the time that Events will be retained by the system.
|
||||||
func NewEtcdRegistry(s storage.StorageInterface, ttl uint64) generic.Registry {
|
func NewEtcdRegistry(s storage.Interface, ttl uint64) generic.Registry {
|
||||||
prefix := "/events"
|
prefix := "/events"
|
||||||
return registry{
|
return registry{
|
||||||
Etcd: &etcdgeneric.Etcd{
|
Etcd: &etcdgeneric.Etcd{
|
||||||
|
@ -104,7 +104,7 @@ type Etcd struct {
|
|||||||
ReturnDeletedObject bool
|
ReturnDeletedObject bool
|
||||||
|
|
||||||
// Used for all etcd access functions
|
// Used for all etcd access functions
|
||||||
Storage storage.StorageInterface
|
Storage storage.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
// NamespaceKeyRootFunc is the default function for constructing etcd paths to resource directories enforcing namespace rules.
|
// NamespaceKeyRootFunc is the default function for constructing etcd paths to resource directories enforcing namespace rules.
|
||||||
|
@ -30,7 +30,7 @@ type registry struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewEtcdRegistry returns a registry which will store LimitRange in the given storage
|
// NewEtcdRegistry returns a registry which will store LimitRange in the given storage
|
||||||
func NewEtcdRegistry(s storage.StorageInterface) generic.Registry {
|
func NewEtcdRegistry(s storage.Interface) generic.Registry {
|
||||||
prefix := "/limitranges"
|
prefix := "/limitranges"
|
||||||
return registry{
|
return registry{
|
||||||
Etcd: &etcdgeneric.Etcd{
|
Etcd: &etcdgeneric.Etcd{
|
||||||
|
@ -49,7 +49,7 @@ func (r *StatusREST) Update(ctx api.Context, obj runtime.Object) (runtime.Object
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStorage returns a RESTStorage object that will work against nodes.
|
// NewStorage returns a RESTStorage object that will work against nodes.
|
||||||
func NewStorage(s storage.StorageInterface, connection client.ConnectionInfoGetter) (*REST, *StatusREST) {
|
func NewStorage(s storage.Interface, connection client.ConnectionInfoGetter) (*REST, *StatusREST) {
|
||||||
prefix := "/minions"
|
prefix := "/minions"
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.Node{} },
|
NewFunc: func() runtime.Object { return &api.Node{} },
|
||||||
|
@ -48,7 +48,7 @@ func (fakeConnectionInfoGetter) GetConnectionInfo(host string) (string, uint, ht
|
|||||||
return "http", 12345, nil, nil
|
return "http", 12345, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
||||||
|
@ -49,7 +49,7 @@ type FinalizeREST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStorage returns a RESTStorage object that will work against namespaces
|
// NewStorage returns a RESTStorage object that will work against namespaces
|
||||||
func NewStorage(s storage.StorageInterface) (*REST, *StatusREST, *FinalizeREST) {
|
func NewStorage(s storage.Interface) (*REST, *StatusREST, *FinalizeREST) {
|
||||||
prefix := "/namespaces"
|
prefix := "/namespaces"
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.Namespace{} },
|
NewFunc: func() runtime.Object { return &api.Namespace{} },
|
||||||
|
@ -34,14 +34,14 @@ import (
|
|||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
||||||
return fakeEtcdClient, etcdStorage
|
return fakeEtcdClient, etcdStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient, storage.StorageInterface) {
|
func newStorage(t *testing.T) (*REST, *tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient, s := newEtcdStorage(t)
|
fakeEtcdClient, s := newEtcdStorage(t)
|
||||||
storage, _, _ := NewStorage(s)
|
storage, _, _ := NewStorage(s)
|
||||||
return storage, fakeEtcdClient, s
|
return storage, fakeEtcdClient, s
|
||||||
|
@ -35,7 +35,7 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against PersistentVolume objects.
|
// NewREST returns a RESTStorage object that will work against PersistentVolume objects.
|
||||||
func NewStorage(s storage.StorageInterface) (*REST, *StatusREST) {
|
func NewStorage(s storage.Interface) (*REST, *StatusREST) {
|
||||||
prefix := "/persistentvolumes"
|
prefix := "/persistentvolumes"
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.PersistentVolume{} },
|
NewFunc: func() runtime.Object { return &api.PersistentVolume{} },
|
||||||
|
@ -39,7 +39,7 @@ type testRegistry struct {
|
|||||||
*registrytest.GenericRegistry
|
*registrytest.GenericRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient, storage.StorageInterface) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
||||||
|
@ -33,7 +33,7 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against PersistentVolumeClaim objects.
|
// NewREST returns a RESTStorage object that will work against PersistentVolumeClaim objects.
|
||||||
func NewStorage(s storage.StorageInterface) (*REST, *StatusREST) {
|
func NewStorage(s storage.Interface) (*REST, *StatusREST) {
|
||||||
prefix := "/persistentvolumeclaims"
|
prefix := "/persistentvolumeclaims"
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} },
|
NewFunc: func() runtime.Object { return &api.PersistentVolumeClaim{} },
|
||||||
|
@ -39,7 +39,7 @@ type testRegistry struct {
|
|||||||
*registrytest.GenericRegistry
|
*registrytest.GenericRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient, storage.StorageInterface) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
||||||
|
@ -57,7 +57,7 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStorage returns a RESTStorage object that will work against pods.
|
// NewStorage returns a RESTStorage object that will work against pods.
|
||||||
func NewStorage(s storage.StorageInterface, k client.ConnectionInfoGetter) PodStorage {
|
func NewStorage(s storage.Interface, k client.ConnectionInfoGetter) PodStorage {
|
||||||
prefix := "/pods"
|
prefix := "/pods"
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.Pod{} },
|
NewFunc: func() runtime.Object { return &api.Pod{} },
|
||||||
|
@ -41,14 +41,14 @@ import (
|
|||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
||||||
return fakeEtcdClient, etcdStorage
|
return fakeEtcdClient, etcdStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *tools.FakeEtcdClient, storage.StorageInterface) {
|
func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient, etcdStorage := newEtcdStorage(t)
|
fakeEtcdClient, etcdStorage := newEtcdStorage(t)
|
||||||
storage := NewStorage(etcdStorage, nil)
|
storage := NewStorage(etcdStorage, nil)
|
||||||
return storage.Pod, storage.Binding, storage.Status, fakeEtcdClient, etcdStorage
|
return storage.Pod, storage.Binding, storage.Status, fakeEtcdClient, etcdStorage
|
||||||
|
@ -33,7 +33,7 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewREST returns a RESTStorage object that will work against pod templates.
|
// NewREST returns a RESTStorage object that will work against pod templates.
|
||||||
func NewREST(s storage.StorageInterface) *REST {
|
func NewREST(s storage.Interface) *REST {
|
||||||
prefix := "/podtemplates"
|
prefix := "/podtemplates"
|
||||||
store := etcdgeneric.Etcd{
|
store := etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.PodTemplate{} },
|
NewFunc: func() runtime.Object { return &api.PodTemplate{} },
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
||||||
|
@ -33,7 +33,7 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStorage returns a RESTStorage object that will work against ResourceQuota objects.
|
// NewStorage returns a RESTStorage object that will work against ResourceQuota objects.
|
||||||
func NewStorage(s storage.StorageInterface) (*REST, *StatusREST) {
|
func NewStorage(s storage.Interface) (*REST, *StatusREST) {
|
||||||
prefix := "/resourcequotas"
|
prefix := "/resourcequotas"
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.ResourceQuota{} },
|
NewFunc: func() runtime.Object { return &api.ResourceQuota{} },
|
||||||
|
@ -39,14 +39,14 @@ import (
|
|||||||
"github.com/coreos/go-etcd/etcd"
|
"github.com/coreos/go-etcd/etcd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, latest.Codec, etcdtest.PathPrefix())
|
||||||
return fakeEtcdClient, etcdStorage
|
return fakeEtcdClient, etcdStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient, storage.StorageInterface) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient, h := newEtcdStorage(t)
|
fakeEtcdClient, h := newEtcdStorage(t)
|
||||||
storage, statusStorage := NewStorage(h)
|
storage, statusStorage := NewStorage(h)
|
||||||
return storage, statusStorage, fakeEtcdClient, h
|
return storage, statusStorage, fakeEtcdClient, h
|
||||||
|
@ -33,7 +33,7 @@ type REST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStorage returns a registry which will store Secret in the given etcdStorage
|
// NewStorage returns a registry which will store Secret in the given etcdStorage
|
||||||
func NewStorage(s storage.StorageInterface) *REST {
|
func NewStorage(s storage.Interface) *REST {
|
||||||
prefix := "/secrets"
|
prefix := "/secrets"
|
||||||
|
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
||||||
|
@ -43,7 +43,7 @@ type Etcd struct {
|
|||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
|
|
||||||
alloc allocator.Snapshottable
|
alloc allocator.Snapshottable
|
||||||
storage storage.StorageInterface
|
storage storage.Interface
|
||||||
last string
|
last string
|
||||||
|
|
||||||
baseKey string
|
baseKey string
|
||||||
@ -56,7 +56,7 @@ var _ service.RangeRegistry = &Etcd{}
|
|||||||
|
|
||||||
// NewEtcd returns an allocator that is backed by Etcd and can manage
|
// NewEtcd returns an allocator that is backed by Etcd and can manage
|
||||||
// persisting the snapshot state of allocation after each allocation is made.
|
// persisting the snapshot state of allocation after each allocation is made.
|
||||||
func NewEtcd(alloc allocator.Snapshottable, baseKey string, kind string, storage storage.StorageInterface) *Etcd {
|
func NewEtcd(alloc allocator.Snapshottable, baseKey string, kind string, storage storage.Interface) *Etcd {
|
||||||
return &Etcd{
|
return &Etcd{
|
||||||
alloc: alloc,
|
alloc: alloc,
|
||||||
storage: storage,
|
storage: storage,
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
||||||
|
@ -35,7 +35,7 @@ type REST struct {
|
|||||||
const Prefix = "/serviceaccounts"
|
const Prefix = "/serviceaccounts"
|
||||||
|
|
||||||
// NewStorage returns a RESTStorage object that will work against service accounts objects.
|
// NewStorage returns a RESTStorage object that will work against service accounts objects.
|
||||||
func NewStorage(s storage.StorageInterface) *REST {
|
func NewStorage(s storage.Interface) *REST {
|
||||||
store := &etcdgeneric.Etcd{
|
store := &etcdgeneric.Etcd{
|
||||||
NewFunc: func() runtime.Object { return &api.ServiceAccount{} },
|
NewFunc: func() runtime.Object { return &api.ServiceAccount{} },
|
||||||
NewListFunc: func() runtime.Object { return &api.ServiceAccountList{} },
|
NewListFunc: func() runtime.Object { return &api.ServiceAccountList{} },
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.StorageInterface) {
|
func newEtcdStorage(t *testing.T) (*tools.FakeEtcdClient, storage.Interface) {
|
||||||
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
fakeEtcdClient := tools.NewFakeEtcdClient(t)
|
||||||
fakeEtcdClient.TestIndex = true
|
fakeEtcdClient.TestIndex = true
|
||||||
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
etcdStorage := tools.NewEtcdStorage(fakeEtcdClient, testapi.Codec(), etcdtest.PathPrefix())
|
||||||
|
@ -73,7 +73,7 @@ func (r *registryGetter) GetSecret(namespace, name string) (*api.Secret, error)
|
|||||||
|
|
||||||
// NewGetterFromStorageInterface returns a ServiceAccountTokenGetter that
|
// NewGetterFromStorageInterface returns a ServiceAccountTokenGetter that
|
||||||
// uses the specified storage to retrieve service accounts and secrets.
|
// uses the specified storage to retrieve service accounts and secrets.
|
||||||
func NewGetterFromStorageInterface(storage storage.StorageInterface) ServiceAccountTokenGetter {
|
func NewGetterFromStorageInterface(storage storage.Interface) ServiceAccountTokenGetter {
|
||||||
return NewGetterFromRegistries(
|
return NewGetterFromRegistries(
|
||||||
serviceaccount.NewRegistry(serviceaccountetcd.NewStorage(storage)),
|
serviceaccount.NewRegistry(serviceaccountetcd.NewStorage(storage)),
|
||||||
secret.NewRegistry(secretetcd.NewStorage(storage)),
|
secret.NewRegistry(secretetcd.NewStorage(storage)),
|
||||||
|
@ -23,9 +23,9 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StorageVersioner abstracts setting and retrieving metadata fields from database response
|
// Versioner abstracts setting and retrieving metadata fields from database response
|
||||||
// onto the object ot list.
|
// onto the object ot list.
|
||||||
type StorageVersioner interface {
|
type Versioner interface {
|
||||||
// UpdateObject sets storage metadata into an API object. Returns an error if the object
|
// UpdateObject sets storage metadata into an API object. Returns an error if the object
|
||||||
// cannot be updated correctly. May return nil if the requested object does not need metadata
|
// cannot be updated correctly. May return nil if the requested object does not need metadata
|
||||||
// from database.
|
// from database.
|
||||||
@ -63,21 +63,21 @@ func Everything(runtime.Object) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass an StorageUpdateFunc to StorageInterface.GuaranteedUpdate to make an update
|
// Pass an UpdateFunc to Interface.GuaranteedUpdate to make an update
|
||||||
// that is guaranteed to succeed.
|
// that is guaranteed to succeed.
|
||||||
// See the comment for GuaranteedUpdate for more details.
|
// See the comment for GuaranteedUpdate for more details.
|
||||||
type StorageUpdateFunc func(input runtime.Object, res ResponseMeta) (output runtime.Object, ttl *uint64, err error)
|
type UpdateFunc func(input runtime.Object, res ResponseMeta) (output runtime.Object, ttl *uint64, err error)
|
||||||
|
|
||||||
// StorageInterface offers a common interface for object marshaling/unmarshling operations and
|
// Interface offers a common interface for object marshaling/unmarshling operations and
|
||||||
// hids all the storage-related operations behind it.
|
// hids all the storage-related operations behind it.
|
||||||
type StorageInterface interface {
|
type Interface interface {
|
||||||
// Returns list of servers addresses of the underyling database.
|
// Returns list of servers addresses of the underyling database.
|
||||||
// TODO: This method is used only in a single place. Consider refactoring and getting rid
|
// TODO: This method is used only in a single place. Consider refactoring and getting rid
|
||||||
// of this method from the interface.
|
// of this method from the interface.
|
||||||
Backends() []string
|
Backends() []string
|
||||||
|
|
||||||
// Returns StorageVersioner associated with this interface.
|
// Returns Versioner associated with this interface.
|
||||||
Versioner() StorageVersioner
|
Versioner() Versioner
|
||||||
|
|
||||||
// Create adds a new object at a key unless it already exists. 'ttl' is time-to-live
|
// Create adds a new object at a key unless it already exists. 'ttl' is time-to-live
|
||||||
// in seconds (0 means forever). If no error is returned and out is not nil, out will be
|
// in seconds (0 means forever). If no error is returned and out is not nil, out will be
|
||||||
@ -129,7 +129,7 @@ type StorageInterface interface {
|
|||||||
//
|
//
|
||||||
// Exmaple:
|
// Exmaple:
|
||||||
//
|
//
|
||||||
// s := /* implementation of StorageInterface */
|
// s := /* implementation of Interface */
|
||||||
// err := s.GuaranteedUpdate(
|
// err := s.GuaranteedUpdate(
|
||||||
// "myKey", &MyType{}, true,
|
// "myKey", &MyType{}, true,
|
||||||
// func(input runtime.Object, res ResponseMeta) (runtime.Object, *uint64, error) {
|
// func(input runtime.Object, res ResponseMeta) (runtime.Object, *uint64, error) {
|
||||||
@ -145,5 +145,5 @@ type StorageInterface interface {
|
|||||||
// return cur, nil, nil
|
// return cur, nil, nil
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
GuaranteedUpdate(key string, ptrToType runtime.Object, ignoreNotFound bool, tryUpdate StorageUpdateFunc) error
|
GuaranteedUpdate(key string, ptrToType runtime.Object, ignoreNotFound bool, tryUpdate UpdateFunc) error
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewEtcdStorage(client EtcdClient, codec runtime.Codec, prefix string) storage.StorageInterface {
|
func NewEtcdStorage(client EtcdClient, codec runtime.Codec, prefix string) storage.Interface {
|
||||||
return &etcdHelper{
|
return &etcdHelper{
|
||||||
client: client,
|
client: client,
|
||||||
codec: codec,
|
codec: codec,
|
||||||
@ -47,13 +47,13 @@ func NewEtcdStorage(client EtcdClient, codec runtime.Codec, prefix string) stora
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// etcdHelper is the reference implementation of StorageInterface.
|
// etcdHelper is the reference implementation of storage.Interface.
|
||||||
type etcdHelper struct {
|
type etcdHelper struct {
|
||||||
client EtcdClient
|
client EtcdClient
|
||||||
codec runtime.Codec
|
codec runtime.Codec
|
||||||
copier runtime.ObjectCopier
|
copier runtime.ObjectCopier
|
||||||
// optional, has to be set to perform any atomic operations
|
// optional, has to be set to perform any atomic operations
|
||||||
versioner storage.StorageVersioner
|
versioner storage.Versioner
|
||||||
// prefix for all etcd keys
|
// prefix for all etcd keys
|
||||||
pathPrefix string
|
pathPrefix string
|
||||||
|
|
||||||
@ -71,17 +71,17 @@ func init() {
|
|||||||
metrics.Register()
|
metrics.Register()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) Backends() []string {
|
func (h *etcdHelper) Backends() []string {
|
||||||
return h.client.GetCluster()
|
return h.client.GetCluster()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) Versioner() storage.StorageVersioner {
|
func (h *etcdHelper) Versioner() storage.Versioner {
|
||||||
return h.versioner
|
return h.versioner
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) Create(key string, obj, out runtime.Object, ttl uint64) error {
|
func (h *etcdHelper) Create(key string, obj, out runtime.Object, ttl uint64) error {
|
||||||
key = h.prefixEtcdKey(key)
|
key = h.prefixEtcdKey(key)
|
||||||
data, err := h.codec.Encode(obj)
|
data, err := h.codec.Encode(obj)
|
||||||
@ -109,7 +109,7 @@ func (h *etcdHelper) Create(key string, obj, out runtime.Object, ttl uint64) err
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) Set(key string, obj, out runtime.Object, ttl uint64) error {
|
func (h *etcdHelper) Set(key string, obj, out runtime.Object, ttl uint64) error {
|
||||||
var response *etcd.Response
|
var response *etcd.Response
|
||||||
data, err := h.codec.Encode(obj)
|
data, err := h.codec.Encode(obj)
|
||||||
@ -150,7 +150,7 @@ func (h *etcdHelper) Set(key string, obj, out runtime.Object, ttl uint64) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) Delete(key string, out runtime.Object) error {
|
func (h *etcdHelper) Delete(key string, out runtime.Object) error {
|
||||||
key = h.prefixEtcdKey(key)
|
key = h.prefixEtcdKey(key)
|
||||||
if _, err := conversion.EnforcePtr(out); err != nil {
|
if _, err := conversion.EnforcePtr(out); err != nil {
|
||||||
@ -169,7 +169,7 @@ func (h *etcdHelper) Delete(key string, out runtime.Object) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) RecursiveDelete(key string, recursive bool) error {
|
func (h *etcdHelper) RecursiveDelete(key string, recursive bool) error {
|
||||||
key = h.prefixEtcdKey(key)
|
key = h.prefixEtcdKey(key)
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
@ -178,7 +178,7 @@ func (h *etcdHelper) RecursiveDelete(key string, recursive bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) Watch(key string, resourceVersion uint64, filter storage.FilterFunc) (watch.Interface, error) {
|
func (h *etcdHelper) Watch(key string, resourceVersion uint64, filter storage.FilterFunc) (watch.Interface, error) {
|
||||||
key = h.prefixEtcdKey(key)
|
key = h.prefixEtcdKey(key)
|
||||||
w := newEtcdWatcher(false, nil, filter, h.codec, h.versioner, nil, h)
|
w := newEtcdWatcher(false, nil, filter, h.codec, h.versioner, nil, h)
|
||||||
@ -186,7 +186,7 @@ func (h *etcdHelper) Watch(key string, resourceVersion uint64, filter storage.Fi
|
|||||||
return w, nil
|
return w, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) WatchList(key string, resourceVersion uint64, filter storage.FilterFunc) (watch.Interface, error) {
|
func (h *etcdHelper) WatchList(key string, resourceVersion uint64, filter storage.FilterFunc) (watch.Interface, error) {
|
||||||
key = h.prefixEtcdKey(key)
|
key = h.prefixEtcdKey(key)
|
||||||
w := newEtcdWatcher(true, exceptKey(key), filter, h.codec, h.versioner, nil, h)
|
w := newEtcdWatcher(true, exceptKey(key), filter, h.codec, h.versioner, nil, h)
|
||||||
@ -194,7 +194,7 @@ func (h *etcdHelper) WatchList(key string, resourceVersion uint64, filter storag
|
|||||||
return w, nil
|
return w, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) Get(key string, objPtr runtime.Object, ignoreNotFound bool) error {
|
func (h *etcdHelper) Get(key string, objPtr runtime.Object, ignoreNotFound bool) error {
|
||||||
key = h.prefixEtcdKey(key)
|
key = h.prefixEtcdKey(key)
|
||||||
_, _, _, err := h.bodyAndExtractObj(key, objPtr, ignoreNotFound)
|
_, _, _, err := h.bodyAndExtractObj(key, objPtr, ignoreNotFound)
|
||||||
@ -245,7 +245,7 @@ func (h *etcdHelper) extractObj(response *etcd.Response, inErr error, objPtr run
|
|||||||
return body, node, err
|
return body, node, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) GetToList(key string, listObj runtime.Object) error {
|
func (h *etcdHelper) GetToList(key string, listObj runtime.Object) error {
|
||||||
trace := util.NewTrace("GetToList " + getTypeName(listObj))
|
trace := util.NewTrace("GetToList " + getTypeName(listObj))
|
||||||
listPtr, err := runtime.GetItemsPtr(listObj)
|
listPtr, err := runtime.GetItemsPtr(listObj)
|
||||||
@ -319,7 +319,7 @@ func (h *etcdHelper) decodeNodeList(nodes []*etcd.Node, slicePtr interface{}) er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) List(key string, listObj runtime.Object) error {
|
func (h *etcdHelper) List(key string, listObj runtime.Object) error {
|
||||||
trace := util.NewTrace("List " + getTypeName(listObj))
|
trace := util.NewTrace("List " + getTypeName(listObj))
|
||||||
defer trace.LogIfLong(time.Second)
|
defer trace.LogIfLong(time.Second)
|
||||||
@ -367,16 +367,16 @@ func (h *etcdHelper) listEtcdNode(key string) ([]*etcd.Node, uint64, error) {
|
|||||||
|
|
||||||
type SimpleUpdateFunc func(runtime.Object) (runtime.Object, error)
|
type SimpleUpdateFunc func(runtime.Object) (runtime.Object, error)
|
||||||
|
|
||||||
// SimpleUpdateFunc converts SimpleUpdateFunc into StorageUpdateFunc
|
// SimpleUpdateFunc converts SimpleUpdateFunc into UpdateFunc
|
||||||
func SimpleUpdate(fn SimpleUpdateFunc) storage.StorageUpdateFunc {
|
func SimpleUpdate(fn SimpleUpdateFunc) storage.UpdateFunc {
|
||||||
return func(input runtime.Object, _ storage.ResponseMeta) (runtime.Object, *uint64, error) {
|
return func(input runtime.Object, _ storage.ResponseMeta) (runtime.Object, *uint64, error) {
|
||||||
out, err := fn(input)
|
out, err := fn(input)
|
||||||
return out, nil, err
|
return out, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements StorageInterface.
|
// Implements storage.Interface.
|
||||||
func (h *etcdHelper) GuaranteedUpdate(key string, ptrToType runtime.Object, ignoreNotFound bool, tryUpdate storage.StorageUpdateFunc) error {
|
func (h *etcdHelper) GuaranteedUpdate(key string, ptrToType runtime.Object, ignoreNotFound bool, tryUpdate storage.UpdateFunc) error {
|
||||||
v, err := conversion.EnforcePtr(ptrToType)
|
v, err := conversion.EnforcePtr(ptrToType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Panic is appropriate, because this is a programming error.
|
// Panic is appropriate, because this is a programming error.
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
// for objects that have an embedded ObjectMeta or ListMeta field.
|
// for objects that have an embedded ObjectMeta or ListMeta field.
|
||||||
type APIObjectVersioner struct{}
|
type APIObjectVersioner struct{}
|
||||||
|
|
||||||
// UpdateObject implements StorageVersioner
|
// UpdateObject implements Versioner
|
||||||
func (a APIObjectVersioner) UpdateObject(obj runtime.Object, expiration *time.Time, resourceVersion uint64) error {
|
func (a APIObjectVersioner) UpdateObject(obj runtime.Object, expiration *time.Time, resourceVersion uint64) error {
|
||||||
objectMeta, err := api.ObjectMetaFor(obj)
|
objectMeta, err := api.ObjectMetaFor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -47,7 +47,7 @@ func (a APIObjectVersioner) UpdateObject(obj runtime.Object, expiration *time.Ti
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateList implements StorageVersioner
|
// UpdateList implements Versioner
|
||||||
func (a APIObjectVersioner) UpdateList(obj runtime.Object, resourceVersion uint64) error {
|
func (a APIObjectVersioner) UpdateList(obj runtime.Object, resourceVersion uint64) error {
|
||||||
listMeta, err := api.ListMetaFor(obj)
|
listMeta, err := api.ListMetaFor(obj)
|
||||||
if err != nil || listMeta == nil {
|
if err != nil || listMeta == nil {
|
||||||
@ -61,7 +61,7 @@ func (a APIObjectVersioner) UpdateList(obj runtime.Object, resourceVersion uint6
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectResourceVersion implements StorageVersioner
|
// ObjectResourceVersion implements Versioner
|
||||||
func (a APIObjectVersioner) ObjectResourceVersion(obj runtime.Object) (uint64, error) {
|
func (a APIObjectVersioner) ObjectResourceVersion(obj runtime.Object) (uint64, error) {
|
||||||
meta, err := api.ObjectMetaFor(obj)
|
meta, err := api.ObjectMetaFor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -74,5 +74,5 @@ func (a APIObjectVersioner) ObjectResourceVersion(obj runtime.Object) (uint64, e
|
|||||||
return strconv.ParseUint(version, 10, 64)
|
return strconv.ParseUint(version, 10, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIObjectVersioner implements StorageVersioner
|
// APIObjectVersioner implements Versioner
|
||||||
var _ storage.StorageVersioner = APIObjectVersioner{}
|
var _ storage.Versioner = APIObjectVersioner{}
|
||||||
|
@ -74,7 +74,7 @@ func exceptKey(except string) includeFunc {
|
|||||||
// etcdWatcher converts a native etcd watch to a watch.Interface.
|
// etcdWatcher converts a native etcd watch to a watch.Interface.
|
||||||
type etcdWatcher struct {
|
type etcdWatcher struct {
|
||||||
encoding runtime.Codec
|
encoding runtime.Codec
|
||||||
versioner storage.StorageVersioner
|
versioner storage.Versioner
|
||||||
transform TransformFunc
|
transform TransformFunc
|
||||||
|
|
||||||
list bool // If we're doing a recursive watch, should be true.
|
list bool // If we're doing a recursive watch, should be true.
|
||||||
@ -102,7 +102,7 @@ const watchWaitDuration = 100 * time.Millisecond
|
|||||||
|
|
||||||
// newEtcdWatcher returns a new etcdWatcher; if list is true, watch sub-nodes. If you provide a transform
|
// newEtcdWatcher returns a new etcdWatcher; if list is true, watch sub-nodes. If you provide a transform
|
||||||
// and a versioner, the versioner must be able to handle the objects that transform creates.
|
// and a versioner, the versioner must be able to handle the objects that transform creates.
|
||||||
func newEtcdWatcher(list bool, include includeFunc, filter storage.FilterFunc, encoding runtime.Codec, versioner storage.StorageVersioner, transform TransformFunc, cache etcdCache) *etcdWatcher {
|
func newEtcdWatcher(list bool, include includeFunc, filter storage.FilterFunc, encoding runtime.Codec, versioner storage.Versioner, transform TransformFunc, cache etcdCache) *etcdWatcher {
|
||||||
w := &etcdWatcher{
|
w := &etcdWatcher{
|
||||||
encoding: encoding,
|
encoding: encoding,
|
||||||
versioner: versioner,
|
versioner: versioner,
|
||||||
|
@ -41,7 +41,7 @@ func NewEtcdClient() *etcd.Client {
|
|||||||
return etcd.NewClient([]string{})
|
return etcd.NewClient([]string{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEtcdStorage() (storage.StorageInterface, error) {
|
func NewEtcdStorage() (storage.Interface, error) {
|
||||||
return master.NewEtcdStorage(NewEtcdClient(), testapi.Version(), etcdtest.PathPrefix())
|
return master.NewEtcdStorage(NewEtcdClient(), testapi.Version(), etcdtest.PathPrefix())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ type MasterComponents struct {
|
|||||||
// Used to stop master components individually, and via MasterComponents.Stop
|
// Used to stop master components individually, and via MasterComponents.Stop
|
||||||
once sync.Once
|
once sync.Once
|
||||||
// Kubernetes etcd storage, has embedded etcd client
|
// Kubernetes etcd storage, has embedded etcd client
|
||||||
EtcdStorage storage.StorageInterface
|
EtcdStorage storage.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is a struct of configuration directives for NewMasterComponents.
|
// 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
|
// startMasterOrDie starts a kubernetes master and an httpserver to handle api requests
|
||||||
func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Server, storage.StorageInterface) {
|
func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Server, storage.Interface) {
|
||||||
var m *master.Master
|
var m *master.Master
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
m.Handler.ServeHTTP(w, req)
|
m.Handler.ServeHTTP(w, req)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
var etcdStorage storage.StorageInterface
|
var etcdStorage storage.Interface
|
||||||
var err error
|
var err error
|
||||||
if masterConfig == nil {
|
if masterConfig == nil {
|
||||||
etcdStorage, err = master.NewEtcdStorage(NewEtcdClient(), "", etcdtest.PathPrefix())
|
etcdStorage, err = master.NewEtcdStorage(NewEtcdClient(), "", etcdtest.PathPrefix())
|
||||||
|
Loading…
Reference in New Issue
Block a user