Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
99d6b0e9
Commit
99d6b0e9
authored
Jul 30, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename storage interfaces
parent
d17985f1
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
84 additions
and
84 deletions
+84
-84
server.go
cmd/kube-apiserver/app/server.go
+1
-1
authn.go
pkg/apiserver/authn.go
+2
-2
master.go
pkg/master/master.go
+3
-3
etcd.go
pkg/registry/controller/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/controller/etcd/etcd_test.go
+1
-1
etcd.go
pkg/registry/endpoint/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/endpoint/etcd/etcd_test.go
+1
-1
etcd.go
pkg/registry/etcd/etcd.go
+5
-5
registry.go
pkg/registry/event/registry.go
+1
-1
etcd.go
pkg/registry/generic/etcd/etcd.go
+1
-1
registry.go
pkg/registry/limitrange/registry.go
+1
-1
etcd.go
pkg/registry/minion/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/minion/etcd/etcd_test.go
+1
-1
etcd.go
pkg/registry/namespace/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/namespace/etcd/etcd_test.go
+2
-2
etcd.go
pkg/registry/persistentvolume/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/persistentvolume/etcd/etcd_test.go
+1
-1
etcd.go
pkg/registry/persistentvolumeclaim/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/persistentvolumeclaim/etcd/etcd_test.go
+1
-1
etcd.go
pkg/registry/pod/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/pod/etcd/etcd_test.go
+2
-2
etcd.go
pkg/registry/podtemplate/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/podtemplate/etcd/etcd_test.go
+1
-1
etcd.go
pkg/registry/resourcequota/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/resourcequota/etcd/etcd_test.go
+2
-2
etcd.go
pkg/registry/secret/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/secret/etcd/etcd_test.go
+1
-1
etcd.go
pkg/registry/service/allocator/etcd/etcd.go
+2
-2
etcd_test.go
pkg/registry/service/allocator/etcd/etcd_test.go
+1
-1
etcd_test.go
pkg/registry/service/ipallocator/etcd/etcd_test.go
+1
-1
etcd.go
pkg/registry/serviceaccount/etcd/etcd.go
+1
-1
etcd_test.go
pkg/registry/serviceaccount/etcd/etcd_test.go
+1
-1
tokengetter.go
pkg/serviceaccount/tokengetter.go
+1
-1
interfaces.go
pkg/storage/interfaces.go
+10
-10
etcd_helper.go
pkg/tools/etcd_helper.go
+19
-19
etcd_object.go
pkg/tools/etcd_object.go
+5
-5
etcd_watcher.go
pkg/tools/etcd_watcher.go
+2
-2
etcd_utils.go
test/integration/framework/etcd_utils.go
+1
-1
master_utils.go
test/integration/framework/master_utils.go
+3
-3
No files found.
cmd/kube-apiserver/app/server.go
View file @
99d6b0e9
...
...
@@ -217,7 +217,7 @@ func (s *APIServer) verifyClusterIPFlags() {
}
}
func
newEtcd
(
etcdConfigFile
string
,
etcdServerList
util
.
StringList
,
storageVersion
string
,
pathPrefix
string
)
(
etcdStorage
storage
.
Storage
Interface
,
err
error
)
{
func
newEtcd
(
etcdConfigFile
string
,
etcdServerList
util
.
StringList
,
storageVersion
string
,
pathPrefix
string
)
(
etcdStorage
storage
.
Interface
,
err
error
)
{
var
client
tools
.
EtcdClient
if
etcdConfigFile
!=
""
{
client
,
err
=
etcd
.
NewClientFromFile
(
etcdConfigFile
)
...
...
pkg/apiserver/authn.go
View file @
99d6b0e9
...
...
@@ -32,7 +32,7 @@ import (
)
// NewAuthenticator returns an authenticator.Request or an error
func
NewAuthenticator
(
basicAuthFile
,
clientCAFile
,
tokenFile
,
serviceAccountKeyFile
string
,
serviceAccountLookup
bool
,
storage
storage
.
Storage
Interface
)
(
authenticator
.
Request
,
error
)
{
func
NewAuthenticator
(
basicAuthFile
,
clientCAFile
,
tokenFile
,
serviceAccountKeyFile
string
,
serviceAccountLookup
bool
,
storage
storage
.
Interface
)
(
authenticator
.
Request
,
error
)
{
var
authenticators
[]
authenticator
.
Request
if
len
(
basicAuthFile
)
>
0
{
...
...
@@ -104,7 +104,7 @@ func newAuthenticatorFromTokenFile(tokenAuthFile string) (authenticator.Request,
}
// newServiceAccountAuthenticator returns an authenticator.Request or an error
func
newServiceAccountAuthenticator
(
keyfile
string
,
lookup
bool
,
storage
storage
.
Storage
Interface
)
(
authenticator
.
Request
,
error
)
{
func
newServiceAccountAuthenticator
(
keyfile
string
,
lookup
bool
,
storage
storage
.
Interface
)
(
authenticator
.
Request
,
error
)
{
publicKey
,
err
:=
serviceaccount
.
ReadPublicKey
(
keyfile
)
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/master/master.go
View file @
99d6b0e9
...
...
@@ -88,7 +88,7 @@ const (
// Config is a structure used to configure a Master.
type
Config
struct
{
DatabaseStorage
storage
.
Storage
Interface
DatabaseStorage
storage
.
Interface
EventTTL
time
.
Duration
MinionRegexp
string
KubeletClient
client
.
KubeletClient
...
...
@@ -224,9 +224,9 @@ type Master struct {
clock
util
.
Clock
}
// NewEtcdStorage returns a
Storage
Interface 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.
func
NewEtcdStorage
(
client
tools
.
EtcdClient
,
version
string
,
prefix
string
)
(
etcdStorage
storage
.
Storage
Interface
,
err
error
)
{
func
NewEtcdStorage
(
client
tools
.
EtcdClient
,
version
string
,
prefix
string
)
(
etcdStorage
storage
.
Interface
,
err
error
)
{
if
version
==
""
{
version
=
latest
.
Version
}
...
...
pkg/registry/controller/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -37,7 +37,7 @@ type REST struct {
var
controllerPrefix
=
"/controllers"
// NewREST returns a RESTStorage object that will work against replication controllers.
func
NewREST
(
s
storage
.
Storage
Interface
)
*
REST
{
func
NewREST
(
s
storage
.
Interface
)
*
REST
{
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ReplicationController
{}
},
...
...
pkg/registry/controller/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -41,7 +41,7 @@ const (
FAIL
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
latest
.
Codec
,
etcdtest
.
PathPrefix
())
...
...
pkg/registry/endpoint/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -33,7 +33,7 @@ type REST struct {
}
// NewStorage returns a RESTStorage object that will work against endpoints.
func
NewStorage
(
s
storage
.
Storage
Interface
)
*
REST
{
func
NewStorage
(
s
storage
.
Interface
)
*
REST
{
prefix
:=
"/services/endpoints"
return
&
REST
{
&
etcdgeneric
.
Etcd
{
...
...
pkg/registry/endpoint/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -33,7 +33,7 @@ import (
"github.com/coreos/go-etcd/etcd"
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
latest
.
Codec
,
etcdtest
.
PathPrefix
())
...
...
pkg/registry/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -45,17 +45,17 @@ const (
// Registry implements BindingRegistry, ControllerRegistry, EndpointRegistry,
// MinionRegistry, PodRegistry and ServiceRegistry, backed by etcd.
type
Registry
struct
{
storage
.
Storage
Interface
storage
.
Interface
pods
pod
.
Registry
endpoints
endpoint
.
Registry
}
// NewRegistry creates an etcd registry.
func
NewRegistry
(
storage
storage
.
Storage
Interface
,
pods
pod
.
Registry
,
endpoints
endpoint
.
Registry
)
*
Registry
{
func
NewRegistry
(
storage
storage
.
Interface
,
pods
pod
.
Registry
,
endpoints
endpoint
.
Registry
)
*
Registry
{
registry
:=
&
Registry
{
Storage
Interface
:
storage
,
pods
:
pods
,
endpoints
:
endpoints
,
Interface
:
storage
,
pods
:
pods
,
endpoints
:
endpoints
,
}
return
registry
}
...
...
pkg/registry/event/registry.go
View file @
99d6b0e9
...
...
@@ -31,7 +31,7 @@ type registry struct {
// NewEtcdRegistry returns a registry which will store Events in the given
// EtcdStorage. ttl is the time that Events will be retained by the system.
func
NewEtcdRegistry
(
s
storage
.
Storage
Interface
,
ttl
uint64
)
generic
.
Registry
{
func
NewEtcdRegistry
(
s
storage
.
Interface
,
ttl
uint64
)
generic
.
Registry
{
prefix
:=
"/events"
return
registry
{
Etcd
:
&
etcdgeneric
.
Etcd
{
...
...
pkg/registry/generic/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -104,7 +104,7 @@ type Etcd struct {
ReturnDeletedObject
bool
// Used for all etcd access functions
Storage
storage
.
Storage
Interface
Storage
storage
.
Interface
}
// NamespaceKeyRootFunc is the default function for constructing etcd paths to resource directories enforcing namespace rules.
...
...
pkg/registry/limitrange/registry.go
View file @
99d6b0e9
...
...
@@ -30,7 +30,7 @@ type registry struct {
}
// NewEtcdRegistry returns a registry which will store LimitRange in the given storage
func
NewEtcdRegistry
(
s
storage
.
Storage
Interface
)
generic
.
Registry
{
func
NewEtcdRegistry
(
s
storage
.
Interface
)
generic
.
Registry
{
prefix
:=
"/limitranges"
return
registry
{
Etcd
:
&
etcdgeneric
.
Etcd
{
...
...
pkg/registry/minion/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -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.
func
NewStorage
(
s
storage
.
Storage
Interface
,
connection
client
.
ConnectionInfoGetter
)
(
*
REST
,
*
StatusREST
)
{
func
NewStorage
(
s
storage
.
Interface
,
connection
client
.
ConnectionInfoGetter
)
(
*
REST
,
*
StatusREST
)
{
prefix
:=
"/minions"
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
Node
{}
},
...
...
pkg/registry/minion/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -48,7 +48,7 @@ func (fakeConnectionInfoGetter) GetConnectionInfo(host string) (string, uint, ht
return
"http"
,
12345
,
nil
,
nil
}
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
latest
.
Codec
,
etcdtest
.
PathPrefix
())
...
...
pkg/registry/namespace/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -49,7 +49,7 @@ type FinalizeREST struct {
}
// NewStorage returns a RESTStorage object that will work against namespaces
func
NewStorage
(
s
storage
.
Storage
Interface
)
(
*
REST
,
*
StatusREST
,
*
FinalizeREST
)
{
func
NewStorage
(
s
storage
.
Interface
)
(
*
REST
,
*
StatusREST
,
*
FinalizeREST
)
{
prefix
:=
"/namespaces"
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
Namespace
{}
},
...
...
pkg/registry/namespace/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -34,14 +34,14 @@ import (
"github.com/coreos/go-etcd/etcd"
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
latest
.
Codec
,
etcdtest
.
PathPrefix
())
return
fakeEtcdClient
,
etcdStorage
}
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
,
s
:=
newEtcdStorage
(
t
)
storage
,
_
,
_
:=
NewStorage
(
s
)
return
storage
,
fakeEtcdClient
,
s
...
...
pkg/registry/persistentvolume/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -35,7 +35,7 @@ type REST struct {
}
// NewREST returns a RESTStorage object that will work against PersistentVolume objects.
func
NewStorage
(
s
storage
.
Storage
Interface
)
(
*
REST
,
*
StatusREST
)
{
func
NewStorage
(
s
storage
.
Interface
)
(
*
REST
,
*
StatusREST
)
{
prefix
:=
"/persistentvolumes"
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolume
{}
},
...
...
pkg/registry/persistentvolume/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -39,7 +39,7 @@ type testRegistry struct {
*
registrytest
.
GenericRegistry
}
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
latest
.
Codec
,
etcdtest
.
PathPrefix
())
...
...
pkg/registry/persistentvolumeclaim/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -33,7 +33,7 @@ type REST struct {
}
// NewREST returns a RESTStorage object that will work against PersistentVolumeClaim objects.
func
NewStorage
(
s
storage
.
Storage
Interface
)
(
*
REST
,
*
StatusREST
)
{
func
NewStorage
(
s
storage
.
Interface
)
(
*
REST
,
*
StatusREST
)
{
prefix
:=
"/persistentvolumeclaims"
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PersistentVolumeClaim
{}
},
...
...
pkg/registry/persistentvolumeclaim/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -39,7 +39,7 @@ type testRegistry struct {
*
registrytest
.
GenericRegistry
}
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
latest
.
Codec
,
etcdtest
.
PathPrefix
())
...
...
pkg/registry/pod/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -57,7 +57,7 @@ type REST struct {
}
// NewStorage returns a RESTStorage object that will work against pods.
func
NewStorage
(
s
storage
.
Storage
Interface
,
k
client
.
ConnectionInfoGetter
)
PodStorage
{
func
NewStorage
(
s
storage
.
Interface
,
k
client
.
ConnectionInfoGetter
)
PodStorage
{
prefix
:=
"/pods"
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
Pod
{}
},
...
...
pkg/registry/pod/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -41,14 +41,14 @@ import (
"github.com/coreos/go-etcd/etcd"
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
latest
.
Codec
,
etcdtest
.
PathPrefix
())
return
fakeEtcdClient
,
etcdStorage
}
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
BindingREST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
BindingREST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
,
etcdStorage
:=
newEtcdStorage
(
t
)
storage
:=
NewStorage
(
etcdStorage
,
nil
)
return
storage
.
Pod
,
storage
.
Binding
,
storage
.
Status
,
fakeEtcdClient
,
etcdStorage
...
...
pkg/registry/podtemplate/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -33,7 +33,7 @@ type REST struct {
}
// NewREST returns a RESTStorage object that will work against pod templates.
func
NewREST
(
s
storage
.
Storage
Interface
)
*
REST
{
func
NewREST
(
s
storage
.
Interface
)
*
REST
{
prefix
:=
"/podtemplates"
store
:=
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PodTemplate
{}
},
...
...
pkg/registry/podtemplate/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -27,7 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
testapi
.
Codec
(),
etcdtest
.
PathPrefix
())
...
...
pkg/registry/resourcequota/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -33,7 +33,7 @@ type REST struct {
}
// NewStorage returns a RESTStorage object that will work against ResourceQuota objects.
func
NewStorage
(
s
storage
.
Storage
Interface
)
(
*
REST
,
*
StatusREST
)
{
func
NewStorage
(
s
storage
.
Interface
)
(
*
REST
,
*
StatusREST
)
{
prefix
:=
"/resourcequotas"
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ResourceQuota
{}
},
...
...
pkg/registry/resourcequota/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -39,14 +39,14 @@ import (
"github.com/coreos/go-etcd/etcd"
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
latest
.
Codec
,
etcdtest
.
PathPrefix
())
return
fakeEtcdClient
,
etcdStorage
}
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newStorage
(
t
*
testing
.
T
)
(
*
REST
,
*
StatusREST
,
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
,
h
:=
newEtcdStorage
(
t
)
storage
,
statusStorage
:=
NewStorage
(
h
)
return
storage
,
statusStorage
,
fakeEtcdClient
,
h
...
...
pkg/registry/secret/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -33,7 +33,7 @@ type REST struct {
}
// NewStorage returns a registry which will store Secret in the given etcdStorage
func
NewStorage
(
s
storage
.
Storage
Interface
)
*
REST
{
func
NewStorage
(
s
storage
.
Interface
)
*
REST
{
prefix
:=
"/secrets"
store
:=
&
etcdgeneric
.
Etcd
{
...
...
pkg/registry/secret/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -27,7 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
testapi
.
Codec
(),
etcdtest
.
PathPrefix
())
...
...
pkg/registry/service/allocator/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -43,7 +43,7 @@ type Etcd struct {
lock
sync
.
Mutex
alloc
allocator
.
Snapshottable
storage
storage
.
Storage
Interface
storage
storage
.
Interface
last
string
baseKey
string
...
...
@@ -56,7 +56,7 @@ var _ service.RangeRegistry = &Etcd{}
// NewEtcd returns an allocator that is backed by Etcd and can manage
// persisting the snapshot state of allocation after each allocation is made.
func
NewEtcd
(
alloc
allocator
.
Snapshottable
,
baseKey
string
,
kind
string
,
storage
storage
.
Storage
Interface
)
*
Etcd
{
func
NewEtcd
(
alloc
allocator
.
Snapshottable
,
baseKey
string
,
kind
string
,
storage
storage
.
Interface
)
*
Etcd
{
return
&
Etcd
{
alloc
:
alloc
,
storage
:
storage
,
...
...
pkg/registry/service/allocator/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -31,7 +31,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
testapi
.
Codec
(),
etcdtest
.
PathPrefix
())
...
...
pkg/registry/service/ipallocator/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -34,7 +34,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
testapi
.
Codec
(),
etcdtest
.
PathPrefix
())
...
...
pkg/registry/serviceaccount/etcd/etcd.go
View file @
99d6b0e9
...
...
@@ -35,7 +35,7 @@ type REST struct {
const
Prefix
=
"/serviceaccounts"
// NewStorage returns a RESTStorage object that will work against service accounts objects.
func
NewStorage
(
s
storage
.
Storage
Interface
)
*
REST
{
func
NewStorage
(
s
storage
.
Interface
)
*
REST
{
store
:=
&
etcdgeneric
.
Etcd
{
NewFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ServiceAccount
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
ServiceAccountList
{}
},
...
...
pkg/registry/serviceaccount/etcd/etcd_test.go
View file @
99d6b0e9
...
...
@@ -27,7 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools/etcdtest"
)
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Storage
Interface
)
{
func
newEtcdStorage
(
t
*
testing
.
T
)
(
*
tools
.
FakeEtcdClient
,
storage
.
Interface
)
{
fakeEtcdClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeEtcdClient
.
TestIndex
=
true
etcdStorage
:=
tools
.
NewEtcdStorage
(
fakeEtcdClient
,
testapi
.
Codec
(),
etcdtest
.
PathPrefix
())
...
...
pkg/serviceaccount/tokengetter.go
View file @
99d6b0e9
...
...
@@ -73,7 +73,7 @@ func (r *registryGetter) GetSecret(namespace, name string) (*api.Secret, error)
// NewGetterFromStorageInterface returns a ServiceAccountTokenGetter that
// uses the specified storage to retrieve service accounts and secrets.
func
NewGetterFromStorageInterface
(
storage
storage
.
Storage
Interface
)
ServiceAccountTokenGetter
{
func
NewGetterFromStorageInterface
(
storage
storage
.
Interface
)
ServiceAccountTokenGetter
{
return
NewGetterFromRegistries
(
serviceaccount
.
NewRegistry
(
serviceaccountetcd
.
NewStorage
(
storage
)),
secret
.
NewRegistry
(
secretetcd
.
NewStorage
(
storage
)),
...
...
pkg/storage/interfaces.go
View file @
99d6b0e9
...
...
@@ -23,9 +23,9 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
)
//
Storage
Versioner abstracts setting and retrieving metadata fields from database response
// Versioner abstracts setting and retrieving metadata fields from database response
// onto the object ot list.
type
Storage
Versioner
interface
{
type
Versioner
interface
{
// 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
// from database.
...
...
@@ -63,21 +63,21 @@ func Everything(runtime.Object) bool {
return
true
}
// Pass an
StorageUpdateFunc to Storage
Interface.GuaranteedUpdate to make an update
// Pass an
UpdateFunc to
Interface.GuaranteedUpdate to make an update
// that is guaranteed to succeed.
// See the comment for GuaranteedUpdate for more details.
type
Storage
UpdateFunc
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
)
//
Storage
Interface 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.
type
Storage
Interface
interface
{
type
Interface
interface
{
// Returns list of servers addresses of the underyling database.
// TODO: This method is used only in a single place. Consider refactoring and getting rid
// of this method from the interface.
Backends
()
[]
string
// Returns
Storage
Versioner associated with this interface.
Versioner
()
Storage
Versioner
// Returns Versioner associated with this interface.
Versioner
()
Versioner
// 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
...
...
@@ -129,7 +129,7 @@ type StorageInterface interface {
//
// Exmaple:
//
// s := /* implementation of
Storage
Interface */
// s := /* implementation of Interface */
// err := s.GuaranteedUpdate(
// "myKey", &MyType{}, true,
// func(input runtime.Object, res ResponseMeta) (runtime.Object, *uint64, error) {
...
...
@@ -145,5 +145,5 @@ type StorageInterface interface {
// return cur, nil, nil
// }
// })
GuaranteedUpdate
(
key
string
,
ptrToType
runtime
.
Object
,
ignoreNotFound
bool
,
tryUpdate
Storage
UpdateFunc
)
error
GuaranteedUpdate
(
key
string
,
ptrToType
runtime
.
Object
,
ignoreNotFound
bool
,
tryUpdate
UpdateFunc
)
error
}
pkg/tools/etcd_helper.go
View file @
99d6b0e9
...
...
@@ -36,7 +36,7 @@ import (
"github.com/golang/glog"
)
func
NewEtcdStorage
(
client
EtcdClient
,
codec
runtime
.
Codec
,
prefix
string
)
storage
.
Storage
Interface
{
func
NewEtcdStorage
(
client
EtcdClient
,
codec
runtime
.
Codec
,
prefix
string
)
storage
.
Interface
{
return
&
etcdHelper
{
client
:
client
,
codec
:
codec
,
...
...
@@ -47,13 +47,13 @@ func NewEtcdStorage(client EtcdClient, codec runtime.Codec, prefix string) stora
}
}
// etcdHelper is the reference implementation of
Storage
Interface.
// etcdHelper is the reference implementation of
storage.
Interface.
type
etcdHelper
struct
{
client
EtcdClient
codec
runtime
.
Codec
copier
runtime
.
ObjectCopier
// optional, has to be set to perform any atomic operations
versioner
storage
.
Storage
Versioner
versioner
storage
.
Versioner
// prefix for all etcd keys
pathPrefix
string
...
...
@@ -71,17 +71,17 @@ func init() {
metrics
.
Register
()
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
Backends
()
[]
string
{
return
h
.
client
.
GetCluster
()
}
// Implements
Storage
Interface.
func
(
h
*
etcdHelper
)
Versioner
()
storage
.
Storage
Versioner
{
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
Versioner
()
storage
.
Versioner
{
return
h
.
versioner
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
Create
(
key
string
,
obj
,
out
runtime
.
Object
,
ttl
uint64
)
error
{
key
=
h
.
prefixEtcdKey
(
key
)
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
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
Set
(
key
string
,
obj
,
out
runtime
.
Object
,
ttl
uint64
)
error
{
var
response
*
etcd
.
Response
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
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
Delete
(
key
string
,
out
runtime
.
Object
)
error
{
key
=
h
.
prefixEtcdKey
(
key
)
if
_
,
err
:=
conversion
.
EnforcePtr
(
out
);
err
!=
nil
{
...
...
@@ -169,7 +169,7 @@ func (h *etcdHelper) Delete(key string, out runtime.Object) error {
return
err
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
RecursiveDelete
(
key
string
,
recursive
bool
)
error
{
key
=
h
.
prefixEtcdKey
(
key
)
startTime
:=
time
.
Now
()
...
...
@@ -178,7 +178,7 @@ func (h *etcdHelper) RecursiveDelete(key string, recursive bool) error {
return
err
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
Watch
(
key
string
,
resourceVersion
uint64
,
filter
storage
.
FilterFunc
)
(
watch
.
Interface
,
error
)
{
key
=
h
.
prefixEtcdKey
(
key
)
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
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
WatchList
(
key
string
,
resourceVersion
uint64
,
filter
storage
.
FilterFunc
)
(
watch
.
Interface
,
error
)
{
key
=
h
.
prefixEtcdKey
(
key
)
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
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
Get
(
key
string
,
objPtr
runtime
.
Object
,
ignoreNotFound
bool
)
error
{
key
=
h
.
prefixEtcdKey
(
key
)
_
,
_
,
_
,
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
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
GetToList
(
key
string
,
listObj
runtime
.
Object
)
error
{
trace
:=
util
.
NewTrace
(
"GetToList "
+
getTypeName
(
listObj
))
listPtr
,
err
:=
runtime
.
GetItemsPtr
(
listObj
)
...
...
@@ -319,7 +319,7 @@ func (h *etcdHelper) decodeNodeList(nodes []*etcd.Node, slicePtr interface{}) er
return
nil
}
// Implements
Storage
Interface.
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
List
(
key
string
,
listObj
runtime
.
Object
)
error
{
trace
:=
util
.
NewTrace
(
"List "
+
getTypeName
(
listObj
))
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
)
// SimpleUpdateFunc converts SimpleUpdateFunc into
Storage
UpdateFunc
func
SimpleUpdate
(
fn
SimpleUpdateFunc
)
storage
.
Storage
UpdateFunc
{
// SimpleUpdateFunc converts SimpleUpdateFunc into UpdateFunc
func
SimpleUpdate
(
fn
SimpleUpdateFunc
)
storage
.
UpdateFunc
{
return
func
(
input
runtime
.
Object
,
_
storage
.
ResponseMeta
)
(
runtime
.
Object
,
*
uint64
,
error
)
{
out
,
err
:=
fn
(
input
)
return
out
,
nil
,
err
}
}
// Implements
Storage
Interface.
func
(
h
*
etcdHelper
)
GuaranteedUpdate
(
key
string
,
ptrToType
runtime
.
Object
,
ignoreNotFound
bool
,
tryUpdate
storage
.
Storage
UpdateFunc
)
error
{
// Implements
storage.
Interface.
func
(
h
*
etcdHelper
)
GuaranteedUpdate
(
key
string
,
ptrToType
runtime
.
Object
,
ignoreNotFound
bool
,
tryUpdate
storage
.
UpdateFunc
)
error
{
v
,
err
:=
conversion
.
EnforcePtr
(
ptrToType
)
if
err
!=
nil
{
// Panic is appropriate, because this is a programming error.
...
...
pkg/tools/etcd_object.go
View file @
99d6b0e9
...
...
@@ -30,7 +30,7 @@ import (
// for objects that have an embedded ObjectMeta or ListMeta field.
type
APIObjectVersioner
struct
{}
// UpdateObject implements
Storage
Versioner
// UpdateObject implements Versioner
func
(
a
APIObjectVersioner
)
UpdateObject
(
obj
runtime
.
Object
,
expiration
*
time
.
Time
,
resourceVersion
uint64
)
error
{
objectMeta
,
err
:=
api
.
ObjectMetaFor
(
obj
)
if
err
!=
nil
{
...
...
@@ -47,7 +47,7 @@ func (a APIObjectVersioner) UpdateObject(obj runtime.Object, expiration *time.Ti
return
nil
}
// UpdateList implements
Storage
Versioner
// UpdateList implements Versioner
func
(
a
APIObjectVersioner
)
UpdateList
(
obj
runtime
.
Object
,
resourceVersion
uint64
)
error
{
listMeta
,
err
:=
api
.
ListMetaFor
(
obj
)
if
err
!=
nil
||
listMeta
==
nil
{
...
...
@@ -61,7 +61,7 @@ func (a APIObjectVersioner) UpdateList(obj runtime.Object, resourceVersion uint6
return
nil
}
// ObjectResourceVersion implements
Storage
Versioner
// ObjectResourceVersion implements Versioner
func
(
a
APIObjectVersioner
)
ObjectResourceVersion
(
obj
runtime
.
Object
)
(
uint64
,
error
)
{
meta
,
err
:=
api
.
ObjectMetaFor
(
obj
)
if
err
!=
nil
{
...
...
@@ -74,5 +74,5 @@ func (a APIObjectVersioner) ObjectResourceVersion(obj runtime.Object) (uint64, e
return
strconv
.
ParseUint
(
version
,
10
,
64
)
}
// APIObjectVersioner implements
Storage
Versioner
var
_
storage
.
Storage
Versioner
=
APIObjectVersioner
{}
// APIObjectVersioner implements Versioner
var
_
storage
.
Versioner
=
APIObjectVersioner
{}
pkg/tools/etcd_watcher.go
View file @
99d6b0e9
...
...
@@ -74,7 +74,7 @@ func exceptKey(except string) includeFunc {
// etcdWatcher converts a native etcd watch to a watch.Interface.
type
etcdWatcher
struct
{
encoding
runtime
.
Codec
versioner
storage
.
Storage
Versioner
versioner
storage
.
Versioner
transform
TransformFunc
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
// 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
.
Storage
Versioner
,
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
{
encoding
:
encoding
,
versioner
:
versioner
,
...
...
test/integration/framework/etcd_utils.go
View file @
99d6b0e9
...
...
@@ -41,7 +41,7 @@ func NewEtcdClient() *etcd.Client {
return
etcd
.
NewClient
([]
string
{})
}
func
NewEtcdStorage
()
(
storage
.
Storage
Interface
,
error
)
{
func
NewEtcdStorage
()
(
storage
.
Interface
,
error
)
{
return
master
.
NewEtcdStorage
(
NewEtcdClient
(),
testapi
.
Version
(),
etcdtest
.
PathPrefix
())
}
...
...
test/integration/framework/master_utils.go
View file @
99d6b0e9
...
...
@@ -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
storage
.
Storage
Interface
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
,
storage
.
Storage
Interface
)
{
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
storage
.
Storage
Interface
var
etcdStorage
storage
.
Interface
var
err
error
if
masterConfig
==
nil
{
etcdStorage
,
err
=
master
.
NewEtcdStorage
(
NewEtcdClient
(),
""
,
etcdtest
.
PathPrefix
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment