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
00c05053
Commit
00c05053
authored
Jan 07, 2015
by
Eric Tune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ListPods methods to List.
For greater similarity to pkg/client. Does not cover registry's ListPods. Fix an example in a comment.
parent
6cd37637
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
15 deletions
+16
-15
listers.go
pkg/client/cache/listers.go
+6
-5
listers_test.go
pkg/client/cache/listers_test.go
+1
-1
doc.go
pkg/client/doc.go
+1
-1
pods.go
pkg/client/pods.go
+1
-1
clientauth.go
pkg/clientauth/clientauth.go
+1
-1
listers.go
pkg/scheduler/listers.go
+4
-4
predicates.go
pkg/scheduler/predicates.go
+1
-1
spreading.go
pkg/scheduler/spreading.go
+1
-1
No files found.
pkg/client/cache/listers.go
View file @
00c05053
...
@@ -31,7 +31,8 @@ import (
...
@@ -31,7 +31,8 @@ import (
//
//
// Example:
// Example:
// s := cache.NewStore()
// s := cache.NewStore()
// XXX NewReflector(... s ...)
// lw := cache.ListWatch{Client: c, FieldSelector: sel, Resource: "pods"}
// r := cache.NewReflector(lw, &api.Pod{}, s).Run()
// l := StoreToPodLister{s}
// l := StoreToPodLister{s}
// l.List()
// l.List()
type
StoreToPodLister
struct
{
type
StoreToPodLister
struct
{
...
@@ -39,10 +40,10 @@ type StoreToPodLister struct {
...
@@ -39,10 +40,10 @@ type StoreToPodLister struct {
}
}
// TODO Get rid of the selector because that is confusing because the user might not realize that there has already been
// TODO Get rid of the selector because that is confusing because the user might not realize that there has already been
// some selection at the caching stage. Also, consistency will facilitate code generation.
// some selection at the caching stage. Also, consistency will facilitate code generation.
However, the pkg/client
//
TODO: Rename to List() instead of ListPods() for consistency with other resources and with pkg/client.
.
//
is inconsistent too
.
func
(
s
*
StoreToPodLister
)
List
Pods
(
selector
labels
.
Selector
)
(
pods
[]
api
.
Pod
,
err
error
)
{
func
(
s
*
StoreToPodLister
)
List
(
selector
labels
.
Selector
)
(
pods
[]
api
.
Pod
,
err
error
)
{
for
_
,
m
:=
range
s
.
List
()
{
for
_
,
m
:=
range
s
.
Store
.
List
()
{
pod
:=
m
.
(
*
api
.
Pod
)
pod
:=
m
.
(
*
api
.
Pod
)
if
selector
.
Matches
(
labels
.
Set
(
pod
.
Labels
))
{
if
selector
.
Matches
(
labels
.
Set
(
pod
.
Labels
))
{
pods
=
append
(
pods
,
*
pod
)
pods
=
append
(
pods
,
*
pod
)
...
...
pkg/client/cache/listers_test.go
View file @
00c05053
...
@@ -59,7 +59,7 @@ func TestStoreToPodLister(t *testing.T) {
...
@@ -59,7 +59,7 @@ func TestStoreToPodLister(t *testing.T) {
spl
:=
StoreToPodLister
{
store
}
spl
:=
StoreToPodLister
{
store
}
for
_
,
id
:=
range
ids
{
for
_
,
id
:=
range
ids
{
got
,
err
:=
spl
.
List
Pods
(
labels
.
Set
{
"name"
:
id
}
.
AsSelector
())
got
,
err
:=
spl
.
List
(
labels
.
Set
{
"name"
:
id
}
.
AsSelector
())
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
continue
continue
...
...
pkg/client/doc.go
View file @
00c05053
...
@@ -30,7 +30,7 @@ Most consumers should use the Config object to create a Client:
...
@@ -30,7 +30,7 @@ Most consumers should use the Config object to create a Client:
if err != nil {
if err != nil {
// handle error
// handle error
}
}
client.
ListPods
()
client.
Pods(ns).List
()
More advanced consumers may wish to provide their own transport via a http.RoundTripper:
More advanced consumers may wish to provide their own transport via a http.RoundTripper:
...
...
pkg/client/pods.go
View file @
00c05053
...
@@ -52,7 +52,7 @@ func newPods(c *Client, namespace string) *pods {
...
@@ -52,7 +52,7 @@ func newPods(c *Client, namespace string) *pods {
}
}
}
}
// List
Pods
takes a selector, and returns the list of pods that match that selector.
// List takes a selector, and returns the list of pods that match that selector.
func
(
c
*
pods
)
List
(
selector
labels
.
Selector
)
(
result
*
api
.
PodList
,
err
error
)
{
func
(
c
*
pods
)
List
(
selector
labels
.
Selector
)
(
result
*
api
.
PodList
,
err
error
)
{
result
=
&
api
.
PodList
{}
result
=
&
api
.
PodList
{}
err
=
c
.
r
.
Get
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"pods"
)
.
SelectorParam
(
"labels"
,
selector
)
.
Do
()
.
Into
(
result
)
err
=
c
.
r
.
Get
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"pods"
)
.
SelectorParam
(
"labels"
,
selector
)
.
Do
()
.
Into
(
result
)
...
...
pkg/clientauth/clientauth.go
View file @
00c05053
...
@@ -58,7 +58,7 @@ Example:
...
@@ -58,7 +58,7 @@ Example:
clientConfig.Host = "example.com:4901"
clientConfig.Host = "example.com:4901"
clientConfig = info.MergeWithConfig()
clientConfig = info.MergeWithConfig()
client := client.New(clientConfig)
client := client.New(clientConfig)
client.
ListPods
()
client.
Pods(ns).List
()
*/
*/
package
clientauth
package
clientauth
...
...
pkg/scheduler/listers.go
View file @
00c05053
...
@@ -36,15 +36,15 @@ func (f FakeMinionLister) List() (api.NodeList, error) {
...
@@ -36,15 +36,15 @@ func (f FakeMinionLister) List() (api.NodeList, error) {
// PodLister interface represents anything that can list pods for a scheduler.
// PodLister interface represents anything that can list pods for a scheduler.
type
PodLister
interface
{
type
PodLister
interface
{
// TODO: make this exactly the same as client's
ListPods() method...
// TODO: make this exactly the same as client's
Pods(ns).List() method, by returning a api.PodList
List
Pods
(
labels
.
Selector
)
([]
api
.
Pod
,
error
)
List
(
labels
.
Selector
)
([]
api
.
Pod
,
error
)
}
}
// FakePodLister implements PodLister on an []api.Pods for test purposes.
// FakePodLister implements PodLister on an []api.Pods for test purposes.
type
FakePodLister
[]
api
.
Pod
type
FakePodLister
[]
api
.
Pod
// List
Pods
returns []api.Pod matching a query.
// List returns []api.Pod matching a query.
func
(
f
FakePodLister
)
List
Pods
(
s
labels
.
Selector
)
(
selected
[]
api
.
Pod
,
err
error
)
{
func
(
f
FakePodLister
)
List
(
s
labels
.
Selector
)
(
selected
[]
api
.
Pod
,
err
error
)
{
for
_
,
pod
:=
range
f
{
for
_
,
pod
:=
range
f
{
if
s
.
Matches
(
labels
.
Set
(
pod
.
Labels
))
{
if
s
.
Matches
(
labels
.
Set
(
pod
.
Labels
))
{
selected
=
append
(
selected
,
pod
)
selected
=
append
(
selected
,
pod
)
...
...
pkg/scheduler/predicates.go
View file @
00c05053
...
@@ -198,7 +198,7 @@ func getUsedPorts(pods ...api.Pod) map[int]bool {
...
@@ -198,7 +198,7 @@ func getUsedPorts(pods ...api.Pod) map[int]bool {
func
MapPodsToMachines
(
lister
PodLister
)
(
map
[
string
][]
api
.
Pod
,
error
)
{
func
MapPodsToMachines
(
lister
PodLister
)
(
map
[
string
][]
api
.
Pod
,
error
)
{
machineToPods
:=
map
[
string
][]
api
.
Pod
{}
machineToPods
:=
map
[
string
][]
api
.
Pod
{}
// TODO: perform more targeted query...
// TODO: perform more targeted query...
pods
,
err
:=
lister
.
List
Pods
(
labels
.
Everything
())
pods
,
err
:=
lister
.
List
(
labels
.
Everything
())
if
err
!=
nil
{
if
err
!=
nil
{
return
map
[
string
][]
api
.
Pod
{},
err
return
map
[
string
][]
api
.
Pod
{},
err
}
}
...
...
pkg/scheduler/spreading.go
View file @
00c05053
...
@@ -28,7 +28,7 @@ import (
...
@@ -28,7 +28,7 @@ import (
// may not provide optimal spreading for the members of that Service.
// may not provide optimal spreading for the members of that Service.
// TODO: consider if we want to include Service label sets in the scheduling priority.
// TODO: consider if we want to include Service label sets in the scheduling priority.
func
CalculateSpreadPriority
(
pod
api
.
Pod
,
podLister
PodLister
,
minionLister
MinionLister
)
(
HostPriorityList
,
error
)
{
func
CalculateSpreadPriority
(
pod
api
.
Pod
,
podLister
PodLister
,
minionLister
MinionLister
)
(
HostPriorityList
,
error
)
{
pods
,
err
:=
podLister
.
List
Pods
(
labels
.
SelectorFromSet
(
pod
.
Labels
))
pods
,
err
:=
podLister
.
List
(
labels
.
SelectorFromSet
(
pod
.
Labels
))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
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