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
cdf75c57
Commit
cdf75c57
authored
Jul 11, 2014
by
brendandburns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #411 from nyaxt/lint_registry
Fixes go lint errors on pkg/registry/controller_registry.go
parents
2ee074f9
f9328914
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
8 deletions
+14
-8
master.go
pkg/master/master.go
+1
-1
controller_registry.go
pkg/registry/controller_registry.go
+8
-2
interfaces.go
pkg/registry/interfaces.go
+3
-3
memory_registry.go
pkg/registry/memory_registry.go
+2
-2
No files found.
pkg/master/master.go
View file @
cdf75c57
...
@@ -87,7 +87,7 @@ func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInf
...
@@ -87,7 +87,7 @@ func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInf
s
:=
scheduler
.
MakeFirstFitScheduler
(
m
.
podRegistry
,
m
.
random
)
s
:=
scheduler
.
MakeFirstFitScheduler
(
m
.
podRegistry
,
m
.
random
)
m
.
storage
=
map
[
string
]
apiserver
.
RESTStorage
{
m
.
storage
=
map
[
string
]
apiserver
.
RESTStorage
{
"pods"
:
registry
.
MakePodRegistryStorage
(
m
.
podRegistry
,
podInfoGetter
,
s
,
m
.
minionRegistry
,
cloud
,
podCache
),
"pods"
:
registry
.
MakePodRegistryStorage
(
m
.
podRegistry
,
podInfoGetter
,
s
,
m
.
minionRegistry
,
cloud
,
podCache
),
"replicationControllers"
:
registry
.
Make
ControllerRegistryStorage
(
m
.
controllerRegistry
,
m
.
podRegistry
),
"replicationControllers"
:
registry
.
New
ControllerRegistryStorage
(
m
.
controllerRegistry
,
m
.
podRegistry
),
"services"
:
registry
.
MakeServiceRegistryStorage
(
m
.
serviceRegistry
,
cloud
,
m
.
minionRegistry
),
"services"
:
registry
.
MakeServiceRegistryStorage
(
m
.
serviceRegistry
,
cloud
,
m
.
minionRegistry
),
"minions"
:
registry
.
MakeMinionRegistryStorage
(
m
.
minionRegistry
),
"minions"
:
registry
.
MakeMinionRegistryStorage
(
m
.
minionRegistry
),
}
}
...
...
pkg/registry/controller_registry.go
View file @
cdf75c57
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
)
)
//
I
mplementation of RESTStorage for the api server.
//
ControllerRegistryStorage is an i
mplementation of RESTStorage for the api server.
type
ControllerRegistryStorage
struct
{
type
ControllerRegistryStorage
struct
{
registry
ControllerRegistry
registry
ControllerRegistry
podRegistry
PodRegistry
podRegistry
PodRegistry
...
@@ -34,7 +34,7 @@ type ControllerRegistryStorage struct {
...
@@ -34,7 +34,7 @@ type ControllerRegistryStorage struct {
pollPeriod
time
.
Duration
pollPeriod
time
.
Duration
}
}
func
Make
ControllerRegistryStorage
(
registry
ControllerRegistry
,
podRegistry
PodRegistry
)
apiserver
.
RESTStorage
{
func
New
ControllerRegistryStorage
(
registry
ControllerRegistry
,
podRegistry
PodRegistry
)
apiserver
.
RESTStorage
{
return
&
ControllerRegistryStorage
{
return
&
ControllerRegistryStorage
{
registry
:
registry
,
registry
:
registry
,
podRegistry
:
podRegistry
,
podRegistry
:
podRegistry
,
...
@@ -42,6 +42,7 @@ func MakeControllerRegistryStorage(registry ControllerRegistry, podRegistry PodR
...
@@ -42,6 +42,7 @@ func MakeControllerRegistryStorage(registry ControllerRegistry, podRegistry PodR
}
}
}
}
// List obtains a list of ReplicationControllers that match selector.
func
(
storage
*
ControllerRegistryStorage
)
List
(
selector
labels
.
Selector
)
(
interface
{},
error
)
{
func
(
storage
*
ControllerRegistryStorage
)
List
(
selector
labels
.
Selector
)
(
interface
{},
error
)
{
result
:=
api
.
ReplicationControllerList
{}
result
:=
api
.
ReplicationControllerList
{}
controllers
,
err
:=
storage
.
registry
.
ListControllers
()
controllers
,
err
:=
storage
.
registry
.
ListControllers
()
...
@@ -55,6 +56,7 @@ func (storage *ControllerRegistryStorage) List(selector labels.Selector) (interf
...
@@ -55,6 +56,7 @@ func (storage *ControllerRegistryStorage) List(selector labels.Selector) (interf
return
result
,
err
return
result
,
err
}
}
// Get obtains the ReplicationController specified by its id.
func
(
storage
*
ControllerRegistryStorage
)
Get
(
id
string
)
(
interface
{},
error
)
{
func
(
storage
*
ControllerRegistryStorage
)
Get
(
id
string
)
(
interface
{},
error
)
{
controller
,
err
:=
storage
.
registry
.
GetController
(
id
)
controller
,
err
:=
storage
.
registry
.
GetController
(
id
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -63,18 +65,21 @@ func (storage *ControllerRegistryStorage) Get(id string) (interface{}, error) {
...
@@ -63,18 +65,21 @@ func (storage *ControllerRegistryStorage) Get(id string) (interface{}, error) {
return
controller
,
err
return
controller
,
err
}
}
// Delete asynchronously deletes the ReplicationController specified by its id.
func
(
storage
*
ControllerRegistryStorage
)
Delete
(
id
string
)
(
<-
chan
interface
{},
error
)
{
func
(
storage
*
ControllerRegistryStorage
)
Delete
(
id
string
)
(
<-
chan
interface
{},
error
)
{
return
apiserver
.
MakeAsync
(
func
()
(
interface
{},
error
)
{
return
apiserver
.
MakeAsync
(
func
()
(
interface
{},
error
)
{
return
api
.
Status
{
Status
:
api
.
StatusSuccess
},
storage
.
registry
.
DeleteController
(
id
)
return
api
.
Status
{
Status
:
api
.
StatusSuccess
},
storage
.
registry
.
DeleteController
(
id
)
}),
nil
}),
nil
}
}
// Extract deserializes user provided data into an api.ReplicationController.
func
(
storage
*
ControllerRegistryStorage
)
Extract
(
body
[]
byte
)
(
interface
{},
error
)
{
func
(
storage
*
ControllerRegistryStorage
)
Extract
(
body
[]
byte
)
(
interface
{},
error
)
{
result
:=
api
.
ReplicationController
{}
result
:=
api
.
ReplicationController
{}
err
:=
api
.
DecodeInto
(
body
,
&
result
)
err
:=
api
.
DecodeInto
(
body
,
&
result
)
return
result
,
err
return
result
,
err
}
}
// Create registers a given new ReplicationController instance to storage.registry.
func
(
storage
*
ControllerRegistryStorage
)
Create
(
obj
interface
{})
(
<-
chan
interface
{},
error
)
{
func
(
storage
*
ControllerRegistryStorage
)
Create
(
obj
interface
{})
(
<-
chan
interface
{},
error
)
{
controller
,
ok
:=
obj
.
(
api
.
ReplicationController
)
controller
,
ok
:=
obj
.
(
api
.
ReplicationController
)
if
!
ok
{
if
!
ok
{
...
@@ -95,6 +100,7 @@ func (storage *ControllerRegistryStorage) Create(obj interface{}) (<-chan interf
...
@@ -95,6 +100,7 @@ func (storage *ControllerRegistryStorage) Create(obj interface{}) (<-chan interf
}),
nil
}),
nil
}
}
// Update replaces a given ReplicationController instance with an existing instance in storage.registry.
func
(
storage
*
ControllerRegistryStorage
)
Update
(
obj
interface
{})
(
<-
chan
interface
{},
error
)
{
func
(
storage
*
ControllerRegistryStorage
)
Update
(
obj
interface
{})
(
<-
chan
interface
{},
error
)
{
controller
,
ok
:=
obj
.
(
api
.
ReplicationController
)
controller
,
ok
:=
obj
.
(
api
.
ReplicationController
)
if
!
ok
{
if
!
ok
{
...
...
pkg/registry/interfaces.go
View file @
cdf75c57
...
@@ -35,13 +35,13 @@ type PodRegistry interface {
...
@@ -35,13 +35,13 @@ type PodRegistry interface {
DeletePod
(
podID
string
)
error
DeletePod
(
podID
string
)
error
}
}
// ControllerRegistry is an interface for things that know how to store Controllers.
// ControllerRegistry is an interface for things that know how to store
Replication
Controllers.
type
ControllerRegistry
interface
{
type
ControllerRegistry
interface
{
ListControllers
()
([]
api
.
ReplicationController
,
error
)
ListControllers
()
([]
api
.
ReplicationController
,
error
)
GetController
(
controllerI
d
string
)
(
*
api
.
ReplicationController
,
error
)
GetController
(
controllerI
D
string
)
(
*
api
.
ReplicationController
,
error
)
CreateController
(
controller
api
.
ReplicationController
)
error
CreateController
(
controller
api
.
ReplicationController
)
error
UpdateController
(
controller
api
.
ReplicationController
)
error
UpdateController
(
controller
api
.
ReplicationController
)
error
DeleteController
(
controllerI
d
string
)
error
DeleteController
(
controllerI
D
string
)
error
}
}
// ServiceRegistry is an interface for things that know how to store services.
// ServiceRegistry is an interface for things that know how to store services.
...
...
pkg/registry/memory_registry.go
View file @
cdf75c57
...
@@ -93,8 +93,8 @@ func (registry *MemoryRegistry) CreateController(controller api.ReplicationContr
...
@@ -93,8 +93,8 @@ func (registry *MemoryRegistry) CreateController(controller api.ReplicationContr
return
nil
return
nil
}
}
func
(
registry
*
MemoryRegistry
)
DeleteController
(
controllerI
d
string
)
error
{
func
(
registry
*
MemoryRegistry
)
DeleteController
(
controllerI
D
string
)
error
{
delete
(
registry
.
controllerData
,
controllerI
d
)
delete
(
registry
.
controllerData
,
controllerI
D
)
return
nil
return
nil
}
}
...
...
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