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
5cbf89c0
Commit
5cbf89c0
authored
Feb 27, 2015
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plumb through changes on ReplicationController and Service
parent
e1ca63f5
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
51 deletions
+46
-51
registry.go
pkg/registry/controller/registry.go
+2
-2
rest.go
pkg/registry/controller/rest.go
+4
-9
etcd.go
pkg/registry/etcd/etcd.go
+20
-16
etcd_test.go
pkg/registry/etcd/etcd_test.go
+6
-6
controller.go
pkg/registry/registrytest/controller.go
+4
-4
service.go
pkg/registry/registrytest/service.go
+4
-4
registry.go
pkg/registry/service/registry.go
+2
-2
rest.go
pkg/registry/service/rest.go
+4
-8
No files found.
pkg/registry/controller/registry.go
View file @
5cbf89c0
...
@@ -27,7 +27,7 @@ type Registry interface {
...
@@ -27,7 +27,7 @@ type Registry interface {
ListControllers
(
ctx
api
.
Context
)
(
*
api
.
ReplicationControllerList
,
error
)
ListControllers
(
ctx
api
.
Context
)
(
*
api
.
ReplicationControllerList
,
error
)
WatchControllers
(
ctx
api
.
Context
,
label
,
field
labels
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
WatchControllers
(
ctx
api
.
Context
,
label
,
field
labels
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
GetController
(
ctx
api
.
Context
,
controllerID
string
)
(
*
api
.
ReplicationController
,
error
)
GetController
(
ctx
api
.
Context
,
controllerID
string
)
(
*
api
.
ReplicationController
,
error
)
CreateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
error
CreateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
UpdateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
error
UpdateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
DeleteController
(
ctx
api
.
Context
,
controllerID
string
)
error
DeleteController
(
ctx
api
.
Context
,
controllerID
string
)
error
}
}
pkg/registry/controller/rest.go
View file @
5cbf89c0
...
@@ -23,7 +23,6 @@ import (
...
@@ -23,7 +23,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
rc
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
rc
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
...
@@ -60,11 +59,11 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, err
...
@@ -60,11 +59,11 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, err
return
nil
,
err
return
nil
,
err
}
}
if
err
:=
rs
.
registry
.
CreateController
(
ctx
,
controller
);
err
!=
nil
{
out
,
err
:=
rs
.
registry
.
CreateController
(
ctx
,
controller
)
if
err
!=
nil
{
err
=
rest
.
CheckGeneratedNameError
(
rest
.
ReplicationControllers
,
err
,
controller
)
err
=
rest
.
CheckGeneratedNameError
(
rest
.
ReplicationControllers
,
err
,
controller
)
return
apiserver
.
RESTResult
{},
err
}
}
return
rs
.
registry
.
GetController
(
ctx
,
controller
.
Name
)
return
out
,
err
}
}
// Delete asynchronously deletes the ReplicationController specified by its id.
// Delete asynchronously deletes the ReplicationController specified by its id.
...
@@ -124,11 +123,7 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, boo
...
@@ -124,11 +123,7 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, boo
if
errs
:=
validation
.
ValidateReplicationController
(
controller
);
len
(
errs
)
>
0
{
if
errs
:=
validation
.
ValidateReplicationController
(
controller
);
len
(
errs
)
>
0
{
return
nil
,
false
,
errors
.
NewInvalid
(
"replicationController"
,
controller
.
Name
,
errs
)
return
nil
,
false
,
errors
.
NewInvalid
(
"replicationController"
,
controller
.
Name
,
errs
)
}
}
err
:=
rs
.
registry
.
UpdateController
(
ctx
,
controller
)
out
,
err
:=
rs
.
registry
.
UpdateController
(
ctx
,
controller
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
out
,
err
:=
rs
.
registry
.
GetController
(
ctx
,
controller
.
Name
)
return
out
,
false
,
err
return
out
,
false
,
err
}
}
...
...
pkg/registry/etcd/etcd.go
View file @
5cbf89c0
...
@@ -152,23 +152,25 @@ func (r *Registry) GetController(ctx api.Context, controllerID string) (*api.Rep
...
@@ -152,23 +152,25 @@ func (r *Registry) GetController(ctx api.Context, controllerID string) (*api.Rep
}
}
// CreateController creates a new ReplicationController.
// CreateController creates a new ReplicationController.
func
(
r
*
Registry
)
CreateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
error
{
func
(
r
*
Registry
)
CreateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
key
,
err
:=
makeControllerKey
(
ctx
,
controller
.
Name
)
key
,
err
:=
makeControllerKey
(
ctx
,
controller
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
err
}
}
err
=
r
.
CreateObj
(
key
,
controller
,
nil
,
0
)
out
:=
&
api
.
ReplicationController
{}
return
etcderr
.
InterpretCreateError
(
err
,
"replicationController"
,
controller
.
Name
)
err
=
r
.
CreateObj
(
key
,
controller
,
out
,
0
)
return
out
,
etcderr
.
InterpretCreateError
(
err
,
"replicationController"
,
controller
.
Name
)
}
}
// UpdateController replaces an existing ReplicationController.
// UpdateController replaces an existing ReplicationController.
func
(
r
*
Registry
)
UpdateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
error
{
func
(
r
*
Registry
)
UpdateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
key
,
err
:=
makeControllerKey
(
ctx
,
controller
.
Name
)
key
,
err
:=
makeControllerKey
(
ctx
,
controller
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
err
}
}
err
=
r
.
SetObj
(
key
,
controller
,
nil
,
0
)
out
:=
&
api
.
ReplicationController
{}
return
etcderr
.
InterpretUpdateError
(
err
,
"replicationController"
,
controller
.
Name
)
err
=
r
.
SetObj
(
key
,
controller
,
out
,
0
)
return
out
,
etcderr
.
InterpretUpdateError
(
err
,
"replicationController"
,
controller
.
Name
)
}
}
// DeleteController deletes a ReplicationController specified by its ID.
// DeleteController deletes a ReplicationController specified by its ID.
...
@@ -199,13 +201,14 @@ func (r *Registry) ListServices(ctx api.Context) (*api.ServiceList, error) {
...
@@ -199,13 +201,14 @@ func (r *Registry) ListServices(ctx api.Context) (*api.ServiceList, error) {
}
}
// CreateService creates a new Service.
// CreateService creates a new Service.
func
(
r
*
Registry
)
CreateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
error
{
func
(
r
*
Registry
)
CreateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
key
,
err
:=
makeServiceKey
(
ctx
,
svc
.
Name
)
key
,
err
:=
makeServiceKey
(
ctx
,
svc
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
err
}
}
err
=
r
.
CreateObj
(
key
,
svc
,
nil
,
0
)
out
:=
&
api
.
Service
{}
return
etcderr
.
InterpretCreateError
(
err
,
"service"
,
svc
.
Name
)
err
=
r
.
CreateObj
(
key
,
svc
,
out
,
0
)
return
out
,
etcderr
.
InterpretCreateError
(
err
,
"service"
,
svc
.
Name
)
}
}
// GetService obtains a Service specified by its name.
// GetService obtains a Service specified by its name.
...
@@ -270,13 +273,14 @@ func (r *Registry) DeleteService(ctx api.Context, name string) error {
...
@@ -270,13 +273,14 @@ func (r *Registry) DeleteService(ctx api.Context, name string) error {
}
}
// UpdateService replaces an existing Service.
// UpdateService replaces an existing Service.
func
(
r
*
Registry
)
UpdateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
error
{
func
(
r
*
Registry
)
UpdateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
key
,
err
:=
makeServiceKey
(
ctx
,
svc
.
Name
)
key
,
err
:=
makeServiceKey
(
ctx
,
svc
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
err
}
}
err
=
r
.
SetObj
(
key
,
svc
,
nil
,
0
)
out
:=
&
api
.
Service
{}
return
etcderr
.
InterpretUpdateError
(
err
,
"service"
,
svc
.
Name
)
err
=
r
.
SetObj
(
key
,
svc
,
out
,
0
)
return
out
,
etcderr
.
InterpretUpdateError
(
err
,
"service"
,
svc
.
Name
)
}
}
// WatchServices begins watching for new, changed, or deleted service configurations.
// WatchServices begins watching for new, changed, or deleted service configurations.
...
...
pkg/registry/etcd/etcd_test.go
View file @
5cbf89c0
...
@@ -212,7 +212,7 @@ func TestEtcdCreateController(t *testing.T) {
...
@@ -212,7 +212,7 @@ func TestEtcdCreateController(t *testing.T) {
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
key
,
_
:=
makeControllerKey
(
ctx
,
"foo"
)
key
,
_
:=
makeControllerKey
(
ctx
,
"foo"
)
err
:=
registry
.
CreateController
(
ctx
,
&
api
.
ReplicationController
{
_
,
err
:=
registry
.
CreateController
(
ctx
,
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
},
},
...
@@ -242,7 +242,7 @@ func TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
...
@@ -242,7 +242,7 @@ func TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
fakeClient
.
Set
(
key
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}}),
0
)
fakeClient
.
Set
(
key
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}}),
0
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
err
:=
registry
.
CreateController
(
ctx
,
&
api
.
ReplicationController
{
_
,
err
:=
registry
.
CreateController
(
ctx
,
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
},
},
...
@@ -259,7 +259,7 @@ func TestEtcdUpdateController(t *testing.T) {
...
@@ -259,7 +259,7 @@ func TestEtcdUpdateController(t *testing.T) {
key
,
_
:=
makeControllerKey
(
ctx
,
"foo"
)
key
,
_
:=
makeControllerKey
(
ctx
,
"foo"
)
resp
,
_
:=
fakeClient
.
Set
(
key
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}}),
0
)
resp
,
_
:=
fakeClient
.
Set
(
key
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}}),
0
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
err
:=
registry
.
UpdateController
(
ctx
,
&
api
.
ReplicationController
{
_
,
err
:=
registry
.
UpdateController
(
ctx
,
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
ResourceVersion
:
strconv
.
FormatUint
(
resp
.
Node
.
ModifiedIndex
,
10
)},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
ResourceVersion
:
strconv
.
FormatUint
(
resp
.
Node
.
ModifiedIndex
,
10
)},
Spec
:
api
.
ReplicationControllerSpec
{
Spec
:
api
.
ReplicationControllerSpec
{
Replicas
:
2
,
Replicas
:
2
,
...
@@ -417,7 +417,7 @@ func TestEtcdCreateService(t *testing.T) {
...
@@ -417,7 +417,7 @@ func TestEtcdCreateService(t *testing.T) {
ctx
:=
api
.
NewDefaultContext
()
ctx
:=
api
.
NewDefaultContext
()
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
fakeClient
:=
tools
.
NewFakeEtcdClient
(
t
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
err
:=
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
_
,
err
:=
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -447,7 +447,7 @@ func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
...
@@ -447,7 +447,7 @@ func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
key
,
_
:=
makeServiceKey
(
ctx
,
"foo"
)
key
,
_
:=
makeServiceKey
(
ctx
,
"foo"
)
fakeClient
.
Set
(
key
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}}),
0
)
fakeClient
.
Set
(
key
,
runtime
.
EncodeOrDie
(
latest
.
Codec
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}}),
0
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
registry
:=
NewTestEtcdRegistry
(
fakeClient
)
err
:=
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
_
,
err
:=
registry
.
CreateService
(
ctx
,
&
api
.
Service
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
})
})
if
!
errors
.
IsAlreadyExists
(
err
)
{
if
!
errors
.
IsAlreadyExists
(
err
)
{
...
@@ -572,7 +572,7 @@ func TestEtcdUpdateService(t *testing.T) {
...
@@ -572,7 +572,7 @@ func TestEtcdUpdateService(t *testing.T) {
SessionAffinity
:
"None"
,
SessionAffinity
:
"None"
,
},
},
}
}
err
:=
registry
.
UpdateService
(
ctx
,
&
testService
)
_
,
err
:=
registry
.
UpdateService
(
ctx
,
&
testService
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
...
pkg/registry/registrytest/controller.go
View file @
5cbf89c0
...
@@ -49,16 +49,16 @@ func (r *ControllerRegistry) GetController(ctx api.Context, ID string) (*api.Rep
...
@@ -49,16 +49,16 @@ func (r *ControllerRegistry) GetController(ctx api.Context, ID string) (*api.Rep
return
&
api
.
ReplicationController
{},
r
.
Err
return
&
api
.
ReplicationController
{},
r
.
Err
}
}
func
(
r
*
ControllerRegistry
)
CreateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
error
{
func
(
r
*
ControllerRegistry
)
CreateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
r
.
Lock
()
r
.
Lock
()
defer
r
.
Unlock
()
defer
r
.
Unlock
()
return
r
.
Err
return
controller
,
r
.
Err
}
}
func
(
r
*
ControllerRegistry
)
UpdateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
error
{
func
(
r
*
ControllerRegistry
)
UpdateController
(
ctx
api
.
Context
,
controller
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
r
.
Lock
()
r
.
Lock
()
defer
r
.
Unlock
()
defer
r
.
Unlock
()
return
r
.
Err
return
controller
,
r
.
Err
}
}
func
(
r
*
ControllerRegistry
)
DeleteController
(
ctx
api
.
Context
,
ID
string
)
error
{
func
(
r
*
ControllerRegistry
)
DeleteController
(
ctx
api
.
Context
,
ID
string
)
error
{
...
...
pkg/registry/registrytest/service.go
View file @
5cbf89c0
...
@@ -71,14 +71,14 @@ func (r *ServiceRegistry) ListServices(ctx api.Context) (*api.ServiceList, error
...
@@ -71,14 +71,14 @@ func (r *ServiceRegistry) ListServices(ctx api.Context) (*api.ServiceList, error
return
res
,
r
.
Err
return
res
,
r
.
Err
}
}
func
(
r
*
ServiceRegistry
)
CreateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
error
{
func
(
r
*
ServiceRegistry
)
CreateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
r
.
mu
.
Lock
()
r
.
mu
.
Lock
()
defer
r
.
mu
.
Unlock
()
defer
r
.
mu
.
Unlock
()
r
.
Service
=
new
(
api
.
Service
)
r
.
Service
=
new
(
api
.
Service
)
*
r
.
Service
=
*
svc
*
r
.
Service
=
*
svc
r
.
List
.
Items
=
append
(
r
.
List
.
Items
,
*
svc
)
r
.
List
.
Items
=
append
(
r
.
List
.
Items
,
*
svc
)
return
r
.
Err
return
svc
,
r
.
Err
}
}
func
(
r
*
ServiceRegistry
)
GetService
(
ctx
api
.
Context
,
id
string
)
(
*
api
.
Service
,
error
)
{
func
(
r
*
ServiceRegistry
)
GetService
(
ctx
api
.
Context
,
id
string
)
(
*
api
.
Service
,
error
)
{
...
@@ -98,13 +98,13 @@ func (r *ServiceRegistry) DeleteService(ctx api.Context, id string) error {
...
@@ -98,13 +98,13 @@ func (r *ServiceRegistry) DeleteService(ctx api.Context, id string) error {
return
r
.
Err
return
r
.
Err
}
}
func
(
r
*
ServiceRegistry
)
UpdateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
error
{
func
(
r
*
ServiceRegistry
)
UpdateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
{
r
.
mu
.
Lock
()
r
.
mu
.
Lock
()
defer
r
.
mu
.
Unlock
()
defer
r
.
mu
.
Unlock
()
r
.
UpdatedID
=
svc
.
Name
r
.
UpdatedID
=
svc
.
Name
*
r
.
Service
=
*
svc
*
r
.
Service
=
*
svc
return
r
.
Err
return
svc
,
r
.
Err
}
}
func
(
r
*
ServiceRegistry
)
WatchServices
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
labels
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
func
(
r
*
ServiceRegistry
)
WatchServices
(
ctx
api
.
Context
,
label
labels
.
Selector
,
field
labels
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
...
...
pkg/registry/service/registry.go
View file @
5cbf89c0
...
@@ -26,10 +26,10 @@ import (
...
@@ -26,10 +26,10 @@ import (
// Registry is an interface for things that know how to store services.
// Registry is an interface for things that know how to store services.
type
Registry
interface
{
type
Registry
interface
{
ListServices
(
ctx
api
.
Context
)
(
*
api
.
ServiceList
,
error
)
ListServices
(
ctx
api
.
Context
)
(
*
api
.
ServiceList
,
error
)
CreateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
error
CreateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
GetService
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Service
,
error
)
GetService
(
ctx
api
.
Context
,
name
string
)
(
*
api
.
Service
,
error
)
DeleteService
(
ctx
api
.
Context
,
name
string
)
error
DeleteService
(
ctx
api
.
Context
,
name
string
)
error
UpdateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
error
UpdateService
(
ctx
api
.
Context
,
svc
*
api
.
Service
)
(
*
api
.
Service
,
error
)
WatchServices
(
ctx
api
.
Context
,
labels
,
fields
labels
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
WatchServices
(
ctx
api
.
Context
,
labels
,
fields
labels
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
// TODO: endpoints and their implementation should be separated, setting endpoints should be
// TODO: endpoints and their implementation should be separated, setting endpoints should be
...
...
pkg/registry/service/rest.go
View file @
5cbf89c0
...
@@ -115,12 +115,12 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, err
...
@@ -115,12 +115,12 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, err
}
}
}
}
if
err
:=
rs
.
registry
.
CreateService
(
ctx
,
service
);
err
!=
nil
{
out
,
err
:=
rs
.
registry
.
CreateService
(
ctx
,
service
)
if
err
!=
nil
{
rs
.
portalMgr
.
Release
(
net
.
ParseIP
(
service
.
Spec
.
PortalIP
))
rs
.
portalMgr
.
Release
(
net
.
ParseIP
(
service
.
Spec
.
PortalIP
))
err
=
rest
.
CheckGeneratedNameError
(
rest
.
Services
,
err
,
service
)
err
=
rest
.
CheckGeneratedNameError
(
rest
.
Services
,
err
,
service
)
return
nil
,
err
}
}
return
rs
.
registry
.
GetService
(
ctx
,
service
.
Name
)
return
out
,
err
}
}
func
hostsFromMinionList
(
list
*
api
.
NodeList
)
[]
string
{
func
hostsFromMinionList
(
list
*
api
.
NodeList
)
[]
string
{
...
@@ -213,11 +213,7 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, boo
...
@@ -213,11 +213,7 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, boo
}
}
}
}
}
}
err
=
rs
.
registry
.
UpdateService
(
ctx
,
service
)
out
,
err
:=
rs
.
registry
.
UpdateService
(
ctx
,
service
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
out
,
err
:=
rs
.
registry
.
GetService
(
ctx
,
service
.
Name
)
return
out
,
false
,
err
return
out
,
false
,
err
}
}
...
...
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