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
ee092225
Commit
ee092225
authored
Sep 27, 2016
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
run copy.sh
parent
d3bba2cf
Hide whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
448 additions
and
182 deletions
+448
-182
client_pool.go
staging/src/k8s.io/client-go/1.5/dynamic/client_pool.go
+42
-15
interfaces.go
staging/src/k8s.io/client-go/1.5/pkg/api/meta/interfaces.go
+1
-2
types.go
staging/src/k8s.io/client-go/1.5/pkg/api/types.go
+1
-1
generated.proto
staging/src/k8s.io/client-go/1.5/pkg/api/v1/generated.proto
+1
-1
types.go
staging/src/k8s.io/client-go/1.5/pkg/api/v1/types.go
+1
-1
types_swagger_doc_generated.go
...o/client-go/1.5/pkg/api/v1/types_swagger_doc_generated.go
+1
-1
zz_generated.conversion.go
...8s.io/client-go/1.5/pkg/api/v1/zz_generated.conversion.go
+9
-0
zz_generated.conversion.go
...-go/1.5/pkg/apis/apps/v1alpha1/zz_generated.conversion.go
+45
-0
types.generated.go
...client-go/1.5/pkg/apis/componentconfig/types.generated.go
+0
-0
types.go
...rc/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.go
+5
-3
defaults.go
...ient-go/1.5/pkg/apis/componentconfig/v1alpha1/defaults.go
+3
-0
types.go
.../client-go/1.5/pkg/apis/componentconfig/v1alpha1/types.go
+5
-3
zz_generated.conversion.go
.../apis/componentconfig/v1alpha1/zz_generated.conversion.go
+2
-0
zz_generated.deepcopy.go
...kg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go
+1
-0
zz_generated.deepcopy.go
...-go/1.5/pkg/apis/componentconfig/zz_generated.deepcopy.go
+1
-0
zz_generated.conversion.go
....5/pkg/apis/extensions/v1beta1/zz_generated.conversion.go
+81
-0
helpers.go
staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/helpers.go
+68
-0
policy.go
staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/policy.go
+4
-0
nodename.go
staging/src/k8s.io/client-go/1.5/pkg/types/nodename.go
+43
-0
errors.go
staging/src/k8s.io/client-go/1.5/pkg/util/errors/errors.go
+14
-0
http.go
staging/src/k8s.io/client-go/1.5/pkg/util/net/http.go
+4
-2
request_test.go
staging/src/k8s.io/client-go/1.5/rest/request_test.go
+2
-0
controller.go
staging/src/k8s.io/client-go/1.5/tools/cache/controller.go
+1
-1
controller_test.go
...g/src/k8s.io/client-go/1.5/tools/cache/controller_test.go
+1
-1
delta_fifo.go
staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo.go
+1
-1
delta_fifo_test.go
...g/src/k8s.io/client-go/1.5/tools/cache/delta_fifo_test.go
+1
-1
doc.go
staging/src/k8s.io/client-go/1.5/tools/cache/doc.go
+1
-1
expiration_cache.go
.../src/k8s.io/client-go/1.5/tools/cache/expiration_cache.go
+1
-1
expiration_cache_fakes.go
...8s.io/client-go/1.5/tools/cache/expiration_cache_fakes.go
+1
-1
expiration_cache_test.go
...k8s.io/client-go/1.5/tools/cache/expiration_cache_test.go
+1
-1
fake_custom_store.go
...src/k8s.io/client-go/1.5/tools/cache/fake_custom_store.go
+1
-1
fifo.go
staging/src/k8s.io/client-go/1.5/tools/cache/fifo.go
+1
-1
fifo_test.go
staging/src/k8s.io/client-go/1.5/tools/cache/fifo_test.go
+1
-1
index.go
staging/src/k8s.io/client-go/1.5/tools/cache/index.go
+1
-1
index_test.go
staging/src/k8s.io/client-go/1.5/tools/cache/index_test.go
+1
-1
listers.go
staging/src/k8s.io/client-go/1.5/tools/cache/listers.go
+2
-111
listers_core.go
staging/src/k8s.io/client-go/1.5/tools/cache/listers_core.go
+80
-10
listers_test.go
staging/src/k8s.io/client-go/1.5/tools/cache/listers_test.go
+9
-9
listwatch.go
staging/src/k8s.io/client-go/1.5/tools/cache/listwatch.go
+1
-1
processor_listener_test.go
...s.io/client-go/1.5/tools/cache/processor_listener_test.go
+1
-1
reflector.go
staging/src/k8s.io/client-go/1.5/tools/cache/reflector.go
+1
-1
reflector_test.go
...ng/src/k8s.io/client-go/1.5/tools/cache/reflector_test.go
+1
-1
shared_informer.go
...g/src/k8s.io/client-go/1.5/tools/cache/shared_informer.go
+1
-1
store.go
staging/src/k8s.io/client-go/1.5/tools/cache/store.go
+1
-1
store_test.go
staging/src/k8s.io/client-go/1.5/tools/cache/store_test.go
+1
-1
thread_safe_store.go
...src/k8s.io/client-go/1.5/tools/cache/thread_safe_store.go
+1
-1
undelta_store.go
...ing/src/k8s.io/client-go/1.5/tools/cache/undelta_store.go
+1
-1
undelta_store_test.go
...rc/k8s.io/client-go/1.5/tools/cache/undelta_store_test.go
+1
-1
No files found.
staging/src/k8s.io/client-go/1.5/dynamic/client_pool.go
View file @
ee092225
...
...
@@ -20,6 +20,7 @@ import (
"sync"
"k8s.io/client-go/1.5/pkg/api"
"k8s.io/client-go/1.5/pkg/api/meta"
"k8s.io/client-go/1.5/pkg/api/unversioned"
"k8s.io/client-go/1.5/pkg/runtime"
"k8s.io/client-go/1.5/pkg/runtime/serializer"
...
...
@@ -28,46 +29,72 @@ import (
// ClientPool manages a pool of dynamic clients.
type
ClientPool
interface
{
// ClientForGroupVersion returns a client configured for the specified groupVersion.
ClientForGroupVersion
(
groupVersion
unversioned
.
GroupVersion
)
(
*
Client
,
error
)
// ClientForGroupVersionKind returns a client configured for the specified groupVersionResource.
// Resource may be empty.
ClientForGroupVersionResource
(
resource
unversioned
.
GroupVersionResource
)
(
*
Client
,
error
)
// ClientForGroupVersionKind returns a client configured for the specified groupVersionKind.
// Kind may be empty.
ClientForGroupVersionKind
(
kind
unversioned
.
GroupVersionKind
)
(
*
Client
,
error
)
}
// APIPathResolverFunc knows how to convert a groupVersion to its API path.
type
APIPathResolverFunc
func
(
groupVersion
unversioned
.
GroupVersion
)
string
// APIPathResolverFunc knows how to convert a groupVersion to its API path. The Kind field is
// optional.
type
APIPathResolverFunc
func
(
kind
unversioned
.
GroupVersionKind
)
string
// LegacyAPIPathResolverFunc can resolve paths properly with the legacy API.
func
LegacyAPIPathResolverFunc
(
groupVersion
unversioned
.
GroupVersion
)
string
{
if
len
(
groupVersion
.
Group
)
==
0
{
func
LegacyAPIPathResolverFunc
(
kind
unversioned
.
GroupVersionKind
)
string
{
if
len
(
kind
.
Group
)
==
0
{
return
"/api"
}
return
"/apis"
}
// clientPoolImpl implements Factory
// clientPoolImpl implements ClientPool and caches clients for the resource group versions
// is asked to retrieve. This type is thread safe.
type
clientPoolImpl
struct
{
lock
sync
.
RWMutex
config
*
rest
.
Config
clients
map
[
unversioned
.
GroupVersion
]
*
Client
apiPathResolverFunc
APIPathResolverFunc
mapper
meta
.
RESTMapper
}
// NewClientPool returns a ClientPool from the specified config
func
NewClientPool
(
config
*
rest
.
Config
,
apiPathResolverFunc
APIPathResolverFunc
)
ClientPool
{
// NewClientPool returns a ClientPool from the specified config. It reuses clients for the the same
// group version. It is expected this type may be wrapped by specific logic that special cases certain
// resources or groups.
func
NewClientPool
(
config
*
rest
.
Config
,
mapper
meta
.
RESTMapper
,
apiPathResolverFunc
APIPathResolverFunc
)
ClientPool
{
confCopy
:=
*
config
return
&
clientPoolImpl
{
config
:
&
confCopy
,
clients
:
map
[
unversioned
.
GroupVersion
]
*
Client
{},
apiPathResolverFunc
:
apiPathResolverFunc
,
mapper
:
mapper
,
}
}
// ClientForGroupVersion returns a client for the specified groupVersion, creates one if none exists
func
(
c
*
clientPoolImpl
)
ClientForGroupVersion
(
groupVersion
unversioned
.
GroupVersion
)
(
*
Client
,
error
)
{
// ClientForGroupVersionResource uses the provided RESTMapper to identify the appropriate resource. Resource may
// be empty. If no matching kind is found the underlying client for that group is still returned.
func
(
c
*
clientPoolImpl
)
ClientForGroupVersionResource
(
resource
unversioned
.
GroupVersionResource
)
(
*
Client
,
error
)
{
kinds
,
err
:=
c
.
mapper
.
KindsFor
(
resource
)
if
err
!=
nil
{
if
meta
.
IsNoMatchError
(
err
)
{
return
c
.
ClientForGroupVersionKind
(
unversioned
.
GroupVersionKind
{
Group
:
resource
.
Group
,
Version
:
resource
.
Version
})
}
return
nil
,
err
}
return
c
.
ClientForGroupVersionKind
(
kinds
[
0
])
}
// ClientForGroupVersion returns a client for the specified groupVersion, creates one if none exists. Kind
// in the GroupVersionKind may be empty.
func
(
c
*
clientPoolImpl
)
ClientForGroupVersionKind
(
kind
unversioned
.
GroupVersionKind
)
(
*
Client
,
error
)
{
c
.
lock
.
Lock
()
defer
c
.
lock
.
Unlock
()
gv
:=
kind
.
GroupVersion
()
// do we have a client already configured?
if
existingClient
,
found
:=
c
.
clients
[
g
roupVersion
];
found
{
if
existingClient
,
found
:=
c
.
clients
[
g
v
];
found
{
return
existingClient
,
nil
}
...
...
@@ -76,10 +103,10 @@ func (c *clientPoolImpl) ClientForGroupVersion(groupVersion unversioned.GroupVer
conf
:=
&
confCopy
// we need to set the api path based on group version, if no group, default to legacy path
conf
.
APIPath
=
c
.
apiPathResolverFunc
(
groupVersion
)
conf
.
APIPath
=
c
.
apiPathResolverFunc
(
kind
)
// we need to make a client
conf
.
GroupVersion
=
&
g
roupVersion
conf
.
GroupVersion
=
&
g
v
if
conf
.
NegotiatedSerializer
==
nil
{
streamingInfo
,
_
:=
api
.
Codecs
.
StreamingSerializerForMediaType
(
"application/json;stream=watch"
,
nil
)
...
...
@@ -90,6 +117,6 @@ func (c *clientPoolImpl) ClientForGroupVersion(groupVersion unversioned.GroupVer
if
err
!=
nil
{
return
nil
,
err
}
c
.
clients
[
g
roupVersion
]
=
dynamicClient
c
.
clients
[
g
v
]
=
dynamicClient
return
dynamicClient
,
nil
}
staging/src/k8s.io/client-go/1.5/pkg/api/meta/interfaces.go
View file @
ee092225
...
...
@@ -160,8 +160,7 @@ type RESTMapping struct {
// to API groups. In other words, kinds and resources should not be assumed to be
// unique across groups.
//
// TODO(caesarxuchao): Add proper multi-group support so that kinds & resources are
// scoped to groups. See http://issues.k8s.io/12413 and http://issues.k8s.io/10009.
// TODO: split into sub-interfaces
type
RESTMapper
interface
{
// KindFor takes a partial resource and returns the single match. Returns an error if there are multiple matches
KindFor
(
resource
unversioned
.
GroupVersionResource
)
(
unversioned
.
GroupVersionKind
,
error
)
...
...
staging/src/k8s.io/client-go/1.5/pkg/api/types.go
View file @
ee092225
...
...
@@ -2568,7 +2568,7 @@ type SerializedReference struct {
type
EventSource
struct
{
// Component from which the event is generated.
Component
string
`json:"component,omitempty"`
//
Host
name on which the event is generated.
//
Node
name on which the event is generated.
Host
string
`json:"host,omitempty"`
}
...
...
staging/src/k8s.io/client-go/1.5/pkg/api/v1/generated.proto
View file @
ee092225
...
...
@@ -769,7 +769,7 @@ message EventSource {
// Component from which the event is generated.
optional
string
component
=
1
;
//
Host
name on which the event is generated.
//
Node
name on which the event is generated.
optional
string
host
=
2
;
}
...
...
staging/src/k8s.io/client-go/1.5/pkg/api/v1/types.go
View file @
ee092225
...
...
@@ -3017,7 +3017,7 @@ type SerializedReference struct {
type
EventSource
struct
{
// Component from which the event is generated.
Component
string
`json:"component,omitempty" protobuf:"bytes,1,opt,name=component"`
//
Host
name on which the event is generated.
//
Node
name on which the event is generated.
Host
string
`json:"host,omitempty" protobuf:"bytes,2,opt,name=host"`
}
...
...
staging/src/k8s.io/client-go/1.5/pkg/api/v1/types_swagger_doc_generated.go
View file @
ee092225
...
...
@@ -477,7 +477,7 @@ func (EventList) SwaggerDoc() map[string]string {
var
map_EventSource
=
map
[
string
]
string
{
""
:
"EventSource contains information for an event."
,
"component"
:
"Component from which the event is generated."
,
"host"
:
"
Host
name on which the event is generated."
,
"host"
:
"
Node
name on which the event is generated."
,
}
func
(
EventSource
)
SwaggerDoc
()
map
[
string
]
string
{
...
...
staging/src/k8s.io/client-go/1.5/pkg/api/v1/zz_generated.conversion.go
View file @
ee092225
...
...
@@ -4926,6 +4926,9 @@ func autoConvert_v1_PodSecurityContext_To_api_PodSecurityContext(in *PodSecurity
}
func
autoConvert_api_PodSecurityContext_To_v1_PodSecurityContext
(
in
*
api
.
PodSecurityContext
,
out
*
PodSecurityContext
,
s
conversion
.
Scope
)
error
{
// INFO: in.HostNetwork opted out of conversion generation
// INFO: in.HostPID opted out of conversion generation
// INFO: in.HostIPC opted out of conversion generation
if
in
.
SELinuxOptions
!=
nil
{
in
,
out
:=
&
in
.
SELinuxOptions
,
&
out
.
SELinuxOptions
*
out
=
new
(
SELinuxOptions
)
...
...
@@ -5017,7 +5020,11 @@ func autoConvert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conv
out
.
DNSPolicy
=
api
.
DNSPolicy
(
in
.
DNSPolicy
)
out
.
NodeSelector
=
in
.
NodeSelector
out
.
ServiceAccountName
=
in
.
ServiceAccountName
// INFO: in.DeprecatedServiceAccount opted out of conversion generation
out
.
NodeName
=
in
.
NodeName
// INFO: in.HostNetwork opted out of conversion generation
// INFO: in.HostPID opted out of conversion generation
// INFO: in.HostIPC opted out of conversion generation
if
in
.
SecurityContext
!=
nil
{
in
,
out
:=
&
in
.
SecurityContext
,
&
out
.
SecurityContext
*
out
=
new
(
api
.
PodSecurityContext
)
...
...
@@ -5995,6 +6002,7 @@ func autoConvert_v1_Secret_To_api_Secret(in *Secret, out *api.Secret, s conversi
return
err
}
out
.
Data
=
in
.
Data
// INFO: in.StringData opted out of conversion generation
out
.
Type
=
api
.
SecretType
(
in
.
Type
)
return
nil
}
...
...
@@ -6503,6 +6511,7 @@ func autoConvert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.Ser
out
.
ClusterIP
=
in
.
ClusterIP
out
.
Type
=
api
.
ServiceType
(
in
.
Type
)
out
.
ExternalIPs
=
in
.
ExternalIPs
// INFO: in.DeprecatedPublicIPs opted out of conversion generation
out
.
SessionAffinity
=
api
.
ServiceAffinity
(
in
.
SessionAffinity
)
out
.
LoadBalancerIP
=
in
.
LoadBalancerIP
out
.
LoadBalancerSourceRanges
=
in
.
LoadBalancerSourceRanges
...
...
staging/src/k8s.io/client-go/1.5/pkg/apis/apps/v1alpha1/zz_generated.conversion.go
View file @
ee092225
...
...
@@ -22,6 +22,7 @@ package v1alpha1
import
(
api
"k8s.io/client-go/1.5/pkg/api"
v1
"k8s.io/client-go/1.5/pkg/api/v1"
apps
"k8s.io/client-go/1.5/pkg/apis/apps"
conversion
"k8s.io/client-go/1.5/pkg/conversion"
runtime
"k8s.io/client-go/1.5/pkg/runtime"
...
...
@@ -139,6 +140,50 @@ func Convert_apps_PetSetList_To_v1alpha1_PetSetList(in *apps.PetSetList, out *Pe
return
autoConvert_apps_PetSetList_To_v1alpha1_PetSetList
(
in
,
out
,
s
)
}
func
autoConvert_v1alpha1_PetSetSpec_To_apps_PetSetSpec
(
in
*
PetSetSpec
,
out
*
apps
.
PetSetSpec
,
s
conversion
.
Scope
)
error
{
// WARNING: in.Replicas requires manual conversion: inconvertible types (*int32 vs int)
out
.
Selector
=
in
.
Selector
if
err
:=
v1
.
Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec
(
&
in
.
Template
,
&
out
.
Template
,
s
);
err
!=
nil
{
return
err
}
if
in
.
VolumeClaimTemplates
!=
nil
{
in
,
out
:=
&
in
.
VolumeClaimTemplates
,
&
out
.
VolumeClaimTemplates
*
out
=
make
([]
api
.
PersistentVolumeClaim
,
len
(
*
in
))
for
i
:=
range
*
in
{
// TODO: Inefficient conversion - can we improve it?
if
err
:=
s
.
Convert
(
&
(
*
in
)[
i
],
&
(
*
out
)[
i
],
0
);
err
!=
nil
{
return
err
}
}
}
else
{
out
.
VolumeClaimTemplates
=
nil
}
out
.
ServiceName
=
in
.
ServiceName
return
nil
}
func
autoConvert_apps_PetSetSpec_To_v1alpha1_PetSetSpec
(
in
*
apps
.
PetSetSpec
,
out
*
PetSetSpec
,
s
conversion
.
Scope
)
error
{
// WARNING: in.Replicas requires manual conversion: inconvertible types (int vs *int32)
out
.
Selector
=
in
.
Selector
if
err
:=
v1
.
Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec
(
&
in
.
Template
,
&
out
.
Template
,
s
);
err
!=
nil
{
return
err
}
if
in
.
VolumeClaimTemplates
!=
nil
{
in
,
out
:=
&
in
.
VolumeClaimTemplates
,
&
out
.
VolumeClaimTemplates
*
out
=
make
([]
v1
.
PersistentVolumeClaim
,
len
(
*
in
))
for
i
:=
range
*
in
{
// TODO: Inefficient conversion - can we improve it?
if
err
:=
s
.
Convert
(
&
(
*
in
)[
i
],
&
(
*
out
)[
i
],
0
);
err
!=
nil
{
return
err
}
}
}
else
{
out
.
VolumeClaimTemplates
=
nil
}
out
.
ServiceName
=
in
.
ServiceName
return
nil
}
func
autoConvert_v1alpha1_PetSetStatus_To_apps_PetSetStatus
(
in
*
PetSetStatus
,
out
*
apps
.
PetSetStatus
,
s
conversion
.
Scope
)
error
{
out
.
ObservedGeneration
=
in
.
ObservedGeneration
out
.
Replicas
=
int
(
in
.
Replicas
)
...
...
staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.generated.go
View file @
ee092225
This source diff could not be displayed because it is too large. You can
view the blob
instead.
staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.go
View file @
ee092225
...
...
@@ -66,12 +66,14 @@ type KubeProxyConfiguration struct {
// Must be greater than 0. Only applicable for proxyMode=userspace.
UDPIdleTimeout
unversioned
.
Duration
`json:"udpTimeoutMilliseconds"`
// conntrackMax is the maximum number of NAT connections to track (0 to
// leave as-is). This takes precedence over conntrackMaxPerCore.
// leave as-is). This takes precedence over conntrackMaxPerCore
and conntrackMin
.
ConntrackMax
int32
`json:"conntrackMax"`
// conntrackMaxPerCore is the maximum number of NAT connections to track
// per CPU core (0 to leave as-is). This value is only considered if
// conntrackMax == 0.
// per CPU core (0 to leave the limit as-is and ignore conntrackMin).
ConntrackMaxPerCore
int32
`json:"conntrackMaxPerCore"`
// conntrackMin is the minimum value of connect-tracking records to allocate,
// regardless of conntrackMaxPerCore (set conntrackMaxPerCore=0 to leave the limit as-is).
ConntrackMin
int32
`json:"conntrackMin"`
// conntrackTCPEstablishedTimeout is how long an idle TCP connection will be kept open
// (e.g. '250ms', '2s'). Must be greater than 0.
ConntrackTCPEstablishedTimeout
unversioned
.
Duration
`json:"conntrackTCPEstablishedTimeout"`
...
...
staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/defaults.go
View file @
ee092225
...
...
@@ -89,6 +89,9 @@ func SetDefaults_KubeProxyConfiguration(obj *KubeProxyConfiguration) {
if
obj
.
ConntrackMaxPerCore
==
0
{
obj
.
ConntrackMaxPerCore
=
32
*
1024
}
if
obj
.
ConntrackMin
==
0
{
obj
.
ConntrackMin
=
128
*
1024
}
}
if
obj
.
IPTablesMasqueradeBit
==
nil
{
temp
:=
int32
(
14
)
...
...
staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/types.go
View file @
ee092225
...
...
@@ -63,12 +63,14 @@ type KubeProxyConfiguration struct {
// Must be greater than 0. Only applicable for proxyMode=userspace.
UDPIdleTimeout
unversioned
.
Duration
`json:"udpTimeoutMilliseconds"`
// conntrackMax is the maximum number of NAT connections to track (0 to
// leave as-is). This takes precedence over conntrackMaxPerCore.
// leave as-is). This takes precedence over conntrackMaxPerCore
and conntrackMin
.
ConntrackMax
int32
`json:"conntrackMax"`
// conntrackMaxPerCore is the maximum number of NAT connections to track
// per CPU core (0 to leave as-is). This value is only considered if
// conntrackMax == 0.
// per CPU core (0 to leave the limit as-is and ignore conntrackMin).
ConntrackMaxPerCore
int32
`json:"conntrackMaxPerCore"`
// conntrackMin is the minimum value of connect-tracking records to allocate,
// regardless of conntrackMaxPerCore (set conntrackMaxPerCore=0 to leave the limit as-is).
ConntrackMin
int32
`json:"conntrackMin"`
// conntrackTCPEstablishedTimeout is how long an idle TCP connection will be kept open
// (e.g. '250ms', '2s'). Must be greater than 0.
ConntrackTCPEstablishedTimeout
unversioned
.
Duration
`json:"conntrackTCPEstablishedTimeout"`
...
...
staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go
View file @
ee092225
...
...
@@ -69,6 +69,7 @@ func autoConvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyCon
out
.
UDPIdleTimeout
=
in
.
UDPIdleTimeout
out
.
ConntrackMax
=
in
.
ConntrackMax
out
.
ConntrackMaxPerCore
=
in
.
ConntrackMaxPerCore
out
.
ConntrackMin
=
in
.
ConntrackMin
out
.
ConntrackTCPEstablishedTimeout
=
in
.
ConntrackTCPEstablishedTimeout
return
nil
}
...
...
@@ -98,6 +99,7 @@ func autoConvert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyCon
out
.
UDPIdleTimeout
=
in
.
UDPIdleTimeout
out
.
ConntrackMax
=
in
.
ConntrackMax
out
.
ConntrackMaxPerCore
=
in
.
ConntrackMaxPerCore
out
.
ConntrackMin
=
in
.
ConntrackMin
out
.
ConntrackTCPEstablishedTimeout
=
in
.
ConntrackTCPEstablishedTimeout
return
nil
}
...
...
staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go
View file @
ee092225
...
...
@@ -75,6 +75,7 @@ func DeepCopy_v1alpha1_KubeProxyConfiguration(in interface{}, out interface{}, c
out
.
UDPIdleTimeout
=
in
.
UDPIdleTimeout
out
.
ConntrackMax
=
in
.
ConntrackMax
out
.
ConntrackMaxPerCore
=
in
.
ConntrackMaxPerCore
out
.
ConntrackMin
=
in
.
ConntrackMin
out
.
ConntrackTCPEstablishedTimeout
=
in
.
ConntrackTCPEstablishedTimeout
return
nil
}
...
...
staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/zz_generated.deepcopy.go
View file @
ee092225
...
...
@@ -163,6 +163,7 @@ func DeepCopy_componentconfig_KubeProxyConfiguration(in interface{}, out interfa
out
.
UDPIdleTimeout
=
in
.
UDPIdleTimeout
out
.
ConntrackMax
=
in
.
ConntrackMax
out
.
ConntrackMaxPerCore
=
in
.
ConntrackMaxPerCore
out
.
ConntrackMin
=
in
.
ConntrackMin
out
.
ConntrackTCPEstablishedTimeout
=
in
.
ConntrackTCPEstablishedTimeout
return
nil
}
...
...
staging/src/k8s.io/client-go/1.5/pkg/apis/extensions/v1beta1/zz_generated.conversion.go
View file @
ee092225
...
...
@@ -941,6 +941,22 @@ func Convert_autoscaling_HorizontalPodAutoscalerList_To_v1beta1_HorizontalPodAut
return
autoConvert_autoscaling_HorizontalPodAutoscalerList_To_v1beta1_HorizontalPodAutoscalerList
(
in
,
out
,
s
)
}
func
autoConvert_v1beta1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec
(
in
*
HorizontalPodAutoscalerSpec
,
out
*
autoscaling
.
HorizontalPodAutoscalerSpec
,
s
conversion
.
Scope
)
error
{
// WARNING: in.ScaleRef requires manual conversion: does not exist in peer-type
out
.
MinReplicas
=
in
.
MinReplicas
out
.
MaxReplicas
=
in
.
MaxReplicas
// WARNING: in.CPUUtilization requires manual conversion: does not exist in peer-type
return
nil
}
func
autoConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1beta1_HorizontalPodAutoscalerSpec
(
in
*
autoscaling
.
HorizontalPodAutoscalerSpec
,
out
*
HorizontalPodAutoscalerSpec
,
s
conversion
.
Scope
)
error
{
// WARNING: in.ScaleTargetRef requires manual conversion: does not exist in peer-type
out
.
MinReplicas
=
in
.
MinReplicas
out
.
MaxReplicas
=
in
.
MaxReplicas
// WARNING: in.TargetCPUUtilizationPercentage requires manual conversion: does not exist in peer-type
return
nil
}
func
autoConvert_v1beta1_HorizontalPodAutoscalerStatus_To_autoscaling_HorizontalPodAutoscalerStatus
(
in
*
HorizontalPodAutoscalerStatus
,
out
*
autoscaling
.
HorizontalPodAutoscalerStatus
,
s
conversion
.
Scope
)
error
{
out
.
ObservedGeneration
=
in
.
ObservedGeneration
out
.
LastScaleTime
=
in
.
LastScaleTime
...
...
@@ -1432,6 +1448,46 @@ func Convert_batch_JobList_To_v1beta1_JobList(in *batch.JobList, out *JobList, s
return
autoConvert_batch_JobList_To_v1beta1_JobList
(
in
,
out
,
s
)
}
func
autoConvert_v1beta1_JobSpec_To_batch_JobSpec
(
in
*
JobSpec
,
out
*
batch
.
JobSpec
,
s
conversion
.
Scope
)
error
{
out
.
Parallelism
=
in
.
Parallelism
out
.
Completions
=
in
.
Completions
out
.
ActiveDeadlineSeconds
=
in
.
ActiveDeadlineSeconds
if
in
.
Selector
!=
nil
{
in
,
out
:=
&
in
.
Selector
,
&
out
.
Selector
*
out
=
new
(
unversioned
.
LabelSelector
)
if
err
:=
Convert_v1beta1_LabelSelector_To_unversioned_LabelSelector
(
*
in
,
*
out
,
s
);
err
!=
nil
{
return
err
}
}
else
{
out
.
Selector
=
nil
}
// WARNING: in.AutoSelector requires manual conversion: does not exist in peer-type
if
err
:=
v1
.
Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec
(
&
in
.
Template
,
&
out
.
Template
,
s
);
err
!=
nil
{
return
err
}
return
nil
}
func
autoConvert_batch_JobSpec_To_v1beta1_JobSpec
(
in
*
batch
.
JobSpec
,
out
*
JobSpec
,
s
conversion
.
Scope
)
error
{
out
.
Parallelism
=
in
.
Parallelism
out
.
Completions
=
in
.
Completions
out
.
ActiveDeadlineSeconds
=
in
.
ActiveDeadlineSeconds
if
in
.
Selector
!=
nil
{
in
,
out
:=
&
in
.
Selector
,
&
out
.
Selector
*
out
=
new
(
LabelSelector
)
if
err
:=
Convert_unversioned_LabelSelector_To_v1beta1_LabelSelector
(
*
in
,
*
out
,
s
);
err
!=
nil
{
return
err
}
}
else
{
out
.
Selector
=
nil
}
// WARNING: in.ManualSelector requires manual conversion: does not exist in peer-type
if
err
:=
v1
.
Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec
(
&
in
.
Template
,
&
out
.
Template
,
s
);
err
!=
nil
{
return
err
}
return
nil
}
func
autoConvert_v1beta1_JobStatus_To_batch_JobStatus
(
in
*
JobStatus
,
out
*
batch
.
JobStatus
,
s
conversion
.
Scope
)
error
{
if
in
.
Conditions
!=
nil
{
in
,
out
:=
&
in
.
Conditions
,
&
out
.
Conditions
...
...
@@ -2282,6 +2338,18 @@ func Convert_extensions_RollbackConfig_To_v1beta1_RollbackConfig(in *extensions.
return
autoConvert_extensions_RollbackConfig_To_v1beta1_RollbackConfig
(
in
,
out
,
s
)
}
func
autoConvert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment
(
in
*
RollingUpdateDeployment
,
out
*
extensions
.
RollingUpdateDeployment
,
s
conversion
.
Scope
)
error
{
// WARNING: in.MaxUnavailable requires manual conversion: inconvertible types (*k8s.io/kubernetes/pkg/util/intstr.IntOrString vs k8s.io/kubernetes/pkg/util/intstr.IntOrString)
// WARNING: in.MaxSurge requires manual conversion: inconvertible types (*k8s.io/kubernetes/pkg/util/intstr.IntOrString vs k8s.io/kubernetes/pkg/util/intstr.IntOrString)
return
nil
}
func
autoConvert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment
(
in
*
extensions
.
RollingUpdateDeployment
,
out
*
RollingUpdateDeployment
,
s
conversion
.
Scope
)
error
{
// WARNING: in.MaxUnavailable requires manual conversion: inconvertible types (k8s.io/kubernetes/pkg/util/intstr.IntOrString vs *k8s.io/kubernetes/pkg/util/intstr.IntOrString)
// WARNING: in.MaxSurge requires manual conversion: inconvertible types (k8s.io/kubernetes/pkg/util/intstr.IntOrString vs *k8s.io/kubernetes/pkg/util/intstr.IntOrString)
return
nil
}
func
autoConvert_v1beta1_RunAsUserStrategyOptions_To_extensions_RunAsUserStrategyOptions
(
in
*
RunAsUserStrategyOptions
,
out
*
extensions
.
RunAsUserStrategyOptions
,
s
conversion
.
Scope
)
error
{
out
.
Rule
=
extensions
.
RunAsUserStrategy
(
in
.
Rule
)
if
in
.
Ranges
!=
nil
{
...
...
@@ -2420,6 +2488,19 @@ func Convert_extensions_ScaleSpec_To_v1beta1_ScaleSpec(in *extensions.ScaleSpec,
return
autoConvert_extensions_ScaleSpec_To_v1beta1_ScaleSpec
(
in
,
out
,
s
)
}
func
autoConvert_v1beta1_ScaleStatus_To_extensions_ScaleStatus
(
in
*
ScaleStatus
,
out
*
extensions
.
ScaleStatus
,
s
conversion
.
Scope
)
error
{
out
.
Replicas
=
in
.
Replicas
// WARNING: in.Selector requires manual conversion: inconvertible types (map[string]string vs *k8s.io/kubernetes/pkg/api/unversioned.LabelSelector)
// WARNING: in.TargetSelector requires manual conversion: does not exist in peer-type
return
nil
}
func
autoConvert_extensions_ScaleStatus_To_v1beta1_ScaleStatus
(
in
*
extensions
.
ScaleStatus
,
out
*
ScaleStatus
,
s
conversion
.
Scope
)
error
{
out
.
Replicas
=
in
.
Replicas
// WARNING: in.Selector requires manual conversion: inconvertible types (*k8s.io/kubernetes/pkg/api/unversioned.LabelSelector vs map[string]string)
return
nil
}
func
autoConvert_v1beta1_SupplementalGroupsStrategyOptions_To_extensions_SupplementalGroupsStrategyOptions
(
in
*
SupplementalGroupsStrategyOptions
,
out
*
extensions
.
SupplementalGroupsStrategyOptions
,
s
conversion
.
Scope
)
error
{
out
.
Rule
=
extensions
.
SupplementalGroupsStrategyType
(
in
.
Rule
)
if
in
.
Ranges
!=
nil
{
...
...
staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/helpers.go
View file @
ee092225
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
rbac
import
(
"fmt"
"strings"
"k8s.io/client-go/1.5/pkg/api/unversioned"
...
...
@@ -94,3 +95,70 @@ func NonResourceURLMatches(rule PolicyRule, requestedURL string) bool {
return
false
}
// +k8s:deepcopy-gen=false
// PolicyRuleBuilder let's us attach methods. A no-no for API types.
// We use it to construct rules in code. It's more compact than trying to write them
// out in a literal and allows us to perform some basic checking during construction
type
PolicyRuleBuilder
struct
{
PolicyRule
PolicyRule
}
func
NewRule
(
verbs
...
string
)
*
PolicyRuleBuilder
{
return
&
PolicyRuleBuilder
{
PolicyRule
:
PolicyRule
{
Verbs
:
verbs
},
}
}
func
(
r
*
PolicyRuleBuilder
)
Groups
(
groups
...
string
)
*
PolicyRuleBuilder
{
r
.
PolicyRule
.
APIGroups
=
append
(
r
.
PolicyRule
.
APIGroups
,
groups
...
)
return
r
}
func
(
r
*
PolicyRuleBuilder
)
Resources
(
resources
...
string
)
*
PolicyRuleBuilder
{
r
.
PolicyRule
.
Resources
=
append
(
r
.
PolicyRule
.
Resources
,
resources
...
)
return
r
}
func
(
r
*
PolicyRuleBuilder
)
Names
(
names
...
string
)
*
PolicyRuleBuilder
{
r
.
PolicyRule
.
ResourceNames
=
append
(
r
.
PolicyRule
.
ResourceNames
,
names
...
)
return
r
}
func
(
r
*
PolicyRuleBuilder
)
URLs
(
urls
...
string
)
*
PolicyRuleBuilder
{
r
.
PolicyRule
.
NonResourceURLs
=
append
(
r
.
PolicyRule
.
NonResourceURLs
,
urls
...
)
return
r
}
func
(
r
*
PolicyRuleBuilder
)
RuleOrDie
()
PolicyRule
{
ret
,
err
:=
r
.
Rule
()
if
err
!=
nil
{
panic
(
err
)
}
return
ret
}
func
(
r
*
PolicyRuleBuilder
)
Rule
()
(
PolicyRule
,
error
)
{
if
len
(
r
.
PolicyRule
.
Verbs
)
==
0
{
return
PolicyRule
{},
fmt
.
Errorf
(
"verbs are required: %#v"
,
r
.
PolicyRule
)
}
switch
{
case
len
(
r
.
PolicyRule
.
NonResourceURLs
)
>
0
:
if
len
(
r
.
PolicyRule
.
APIGroups
)
!=
0
||
len
(
r
.
PolicyRule
.
Resources
)
!=
0
||
len
(
r
.
PolicyRule
.
ResourceNames
)
!=
0
{
return
PolicyRule
{},
fmt
.
Errorf
(
"non-resource rule may not have apiGroups, resources, or resourceNames: %#v"
,
r
.
PolicyRule
)
}
case
len
(
r
.
PolicyRule
.
Resources
)
>
0
:
if
len
(
r
.
PolicyRule
.
NonResourceURLs
)
!=
0
{
return
PolicyRule
{},
fmt
.
Errorf
(
"resource rule may not have nonResourceURLs: %#v"
,
r
.
PolicyRule
)
}
if
len
(
r
.
PolicyRule
.
APIGroups
)
==
0
{
// this a common bug
return
PolicyRule
{},
fmt
.
Errorf
(
"resource rule must have apiGroups: %#v"
,
r
.
PolicyRule
)
}
default
:
return
PolicyRule
{},
fmt
.
Errorf
(
"a rule must have either nonResourceURLs or resources: %#v"
,
r
.
PolicyRule
)
}
return
r
.
PolicyRule
,
nil
}
staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/policy.go
View file @
ee092225
...
...
@@ -21,6 +21,10 @@ import (
)
const
(
// PodInfraOOMAdj is very docker specific. For arbitrary runtime, it may not make
// sense to set sandbox level oom score, e.g. a sandbox could only be a namespace
// without a process.
// TODO: Handle infra container oom score adj in a runtime agnostic way.
PodInfraOOMAdj
int
=
-
998
KubeletOOMScoreAdj
int
=
-
999
DockerOOMScoreAdj
int
=
-
999
...
...
staging/src/k8s.io/client-go/1.5/pkg/types/nodename.go
0 → 100644
View file @
ee092225
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
types
// NodeName is a type that holds a api.Node's Name identifier.
// Being a type captures intent and helps make sure that the node name
// is not confused with similar concepts (the hostname, the cloud provider id,
// the cloud provider name etc)
//
// To clarify the various types:
//
// * Node.Name is the Name field of the Node in the API. This should be stored in a NodeName.
// Unfortunately, because Name is part of ObjectMeta, we can't store it as a NodeName at the API level.
//
// * Hostname is the hostname of the local machine (from uname -n).
// However, some components allow the user to pass in a --hostname-override flag,
// which will override this in most places. In the absence of anything more meaningful,
// kubelet will use Hostname as the Node.Name when it creates the Node.
//
// * The cloudproviders have the own names: GCE has InstanceName, AWS has InstanceId.
//
// For GCE, InstanceName is the Name of an Instance object in the GCE API. On GCE, Instance.Name becomes the
// Hostname, and thus it makes sense also to use it as the Node.Name. But that is GCE specific, and it is up
// to the cloudprovider how to do this mapping.
//
// For AWS, the InstanceID is not yet suitable for use as a Node.Name, so we actually use the
// PrivateDnsName for the Node.Name. And this is _not_ always the same as the hostname: if
// we are using a custom DHCP domain it won't be.
type
NodeName
string
staging/src/k8s.io/client-go/1.5/pkg/util/errors/errors.go
View file @
ee092225
...
...
@@ -147,6 +147,20 @@ func Flatten(agg Aggregate) Aggregate {
return
NewAggregate
(
result
)
}
// Reduce will return err or, if err is an Aggregate and only has one item,
// the first item in the aggregate.
func
Reduce
(
err
error
)
error
{
if
agg
,
ok
:=
err
.
(
Aggregate
);
ok
&&
err
!=
nil
{
switch
len
(
agg
.
Errors
())
{
case
1
:
return
agg
.
Errors
()[
0
]
case
0
:
return
nil
}
}
return
err
}
// AggregateGoroutines runs the provided functions in parallel, stuffing all
// non-nil errors into the returned Aggregate.
// Returns nil if all the functions complete successfully.
...
...
staging/src/k8s.io/client-go/1.5/pkg/util/net/http.go
View file @
ee092225
...
...
@@ -77,8 +77,10 @@ func SetOldTransportDefaults(t *http.Transport) *http.Transport {
// for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
func
SetTransportDefaults
(
t
*
http
.
Transport
)
*
http
.
Transport
{
t
=
SetOldTransportDefaults
(
t
)
// Allow HTTP2 clients but default off for now
if
s
:=
os
.
Getenv
(
"ENABLE_HTTP2"
);
len
(
s
)
>
0
{
// Allow clients to disable http2 if needed.
if
s
:=
os
.
Getenv
(
"DISABLE_HTTP2"
);
len
(
s
)
>
0
{
glog
.
Infof
(
"HTTP2 has been explicitly disabled"
)
}
else
{
if
err
:=
http2
.
ConfigureTransport
(
t
);
err
!=
nil
{
glog
.
Warningf
(
"Transport failed http2 configuration: %v"
,
err
)
}
...
...
staging/src/k8s.io/client-go/1.5/rest/request_test.go
View file @
ee092225
...
...
@@ -1209,6 +1209,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
defer
file
.
Close
()
defer
os
.
Remove
(
file
.
Name
())
_
,
err
=
file
.
Write
(
reqBodyExpected
)
if
err
!=
nil
{
...
...
@@ -1402,6 +1403,7 @@ func TestBody(t *testing.T) {
t
.
Fatalf
(
"TempFile.WriteString error: %v"
,
err
)
}
f
.
Close
()
defer
os
.
Remove
(
f
.
Name
())
var
nilObject
*
api
.
DeleteOptions
typedObject
:=
interface
{}(
nilObject
)
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/controller.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"sync"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/controller_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"fmt"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"errors"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"fmt"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/doc.go
View file @
ee092225
...
...
@@ -21,4 +21,4 @@ limitations under the License.
// list currently available nodes), and one that additionally acts as
// a FIFO queue (for example, to allow a scheduler to process incoming
// pods).
package
testing
// import "k8s.io/client-go/1.5/tools/cache"
package
cache
// import "k8s.io/client-go/1.5/tools/cache"
staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"sync"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_fakes.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"k8s.io/client-go/1.5/pkg/util/clock"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"reflect"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/fake_custom_store.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
// FakeStore lets you define custom functions for store operations
type
FakeCustomStore
struct
{
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/fifo.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"sync"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/fifo_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"fmt"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/index.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"fmt"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/index_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"strings"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/listers.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"fmt"
...
...
@@ -32,6 +32,7 @@ import (
"k8s.io/client-go/1.5/pkg/labels"
)
// AppendFunc is used to add a matching item to whatever list the caller is using
type
AppendFunc
func
(
interface
{})
func
ListAll
(
store
Store
,
selector
labels
.
Selector
,
appendFn
AppendFunc
)
error
{
...
...
@@ -136,116 +137,6 @@ func (s storeToNodeConditionLister) List() (nodes []*api.Node, err error) {
return
}
// StoreToReplicationControllerLister gives a store List and Exists methods. The store must contain only ReplicationControllers.
type
StoreToReplicationControllerLister
struct
{
Indexer
}
// Exists checks if the given rc exists in the store.
func
(
s
*
StoreToReplicationControllerLister
)
Exists
(
controller
*
api
.
ReplicationController
)
(
bool
,
error
)
{
_
,
exists
,
err
:=
s
.
Indexer
.
Get
(
controller
)
if
err
!=
nil
{
return
false
,
err
}
return
exists
,
nil
}
// StoreToReplicationControllerLister lists all controllers in the store.
// TODO: converge on the interface in pkg/client
func
(
s
*
StoreToReplicationControllerLister
)
List
()
(
controllers
[]
api
.
ReplicationController
,
err
error
)
{
for
_
,
c
:=
range
s
.
Indexer
.
List
()
{
controllers
=
append
(
controllers
,
*
(
c
.
(
*
api
.
ReplicationController
)))
}
return
controllers
,
nil
}
func
(
s
*
StoreToReplicationControllerLister
)
ReplicationControllers
(
namespace
string
)
storeReplicationControllersNamespacer
{
return
storeReplicationControllersNamespacer
{
s
.
Indexer
,
namespace
}
}
type
storeReplicationControllersNamespacer
struct
{
indexer
Indexer
namespace
string
}
func
(
s
storeReplicationControllersNamespacer
)
List
(
selector
labels
.
Selector
)
([]
api
.
ReplicationController
,
error
)
{
controllers
:=
[]
api
.
ReplicationController
{}
if
s
.
namespace
==
api
.
NamespaceAll
{
for
_
,
m
:=
range
s
.
indexer
.
List
()
{
rc
:=
*
(
m
.
(
*
api
.
ReplicationController
))
if
selector
.
Matches
(
labels
.
Set
(
rc
.
Labels
))
{
controllers
=
append
(
controllers
,
rc
)
}
}
return
controllers
,
nil
}
key
:=
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
s
.
namespace
}}
items
,
err
:=
s
.
indexer
.
Index
(
NamespaceIndex
,
key
)
if
err
!=
nil
{
// Ignore error; do slow search without index.
glog
.
Warningf
(
"can not retrieve list of objects using index : %v"
,
err
)
for
_
,
m
:=
range
s
.
indexer
.
List
()
{
rc
:=
*
(
m
.
(
*
api
.
ReplicationController
))
if
s
.
namespace
==
rc
.
Namespace
&&
selector
.
Matches
(
labels
.
Set
(
rc
.
Labels
))
{
controllers
=
append
(
controllers
,
rc
)
}
}
return
controllers
,
nil
}
for
_
,
m
:=
range
items
{
rc
:=
*
(
m
.
(
*
api
.
ReplicationController
))
if
selector
.
Matches
(
labels
.
Set
(
rc
.
Labels
))
{
controllers
=
append
(
controllers
,
rc
)
}
}
return
controllers
,
nil
}
func
(
s
storeReplicationControllersNamespacer
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
obj
,
exists
,
err
:=
s
.
indexer
.
GetByKey
(
s
.
namespace
+
"/"
+
name
)
if
err
!=
nil
{
return
nil
,
err
}
if
!
exists
{
return
nil
,
errors
.
NewNotFound
(
api
.
Resource
(
"replicationcontroller"
),
name
)
}
return
obj
.
(
*
api
.
ReplicationController
),
nil
}
// GetPodControllers returns a list of replication controllers managing a pod. Returns an error only if no matching controllers are found.
func
(
s
*
StoreToReplicationControllerLister
)
GetPodControllers
(
pod
*
api
.
Pod
)
(
controllers
[]
api
.
ReplicationController
,
err
error
)
{
var
selector
labels
.
Selector
var
rc
api
.
ReplicationController
if
len
(
pod
.
Labels
)
==
0
{
err
=
fmt
.
Errorf
(
"no controllers found for pod %v because it has no labels"
,
pod
.
Name
)
return
}
key
:=
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
pod
.
Namespace
}}
items
,
err
:=
s
.
Indexer
.
Index
(
NamespaceIndex
,
key
)
if
err
!=
nil
{
return
}
for
_
,
m
:=
range
items
{
rc
=
*
m
.
(
*
api
.
ReplicationController
)
selector
=
labels
.
Set
(
rc
.
Spec
.
Selector
)
.
AsSelectorPreValidated
()
// If an rc with a nil or empty selector creeps in, it should match nothing, not everything.
if
selector
.
Empty
()
||
!
selector
.
Matches
(
labels
.
Set
(
pod
.
Labels
))
{
continue
}
controllers
=
append
(
controllers
,
rc
)
}
if
len
(
controllers
)
==
0
{
err
=
fmt
.
Errorf
(
"could not find controller for pod %s in namespace %s with labels: %v"
,
pod
.
Name
,
pod
.
Namespace
,
pod
.
Labels
)
}
return
}
// StoreToDeploymentLister gives a store List and Exists methods. The store must contain only Deployments.
type
StoreToDeploymentLister
struct
{
Indexer
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/listers_core.go
View file @
ee092225
...
...
@@ -14,9 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"fmt"
"k8s.io/client-go/1.5/pkg/api"
"k8s.io/client-go/1.5/pkg/api/errors"
"k8s.io/client-go/1.5/pkg/labels"
...
...
@@ -25,24 +27,24 @@ import (
// TODO: generate these classes and methods for all resources of interest using
// a script. Can use "go generate" once 1.4 is supported by all users.
// StoreToPodLister makes a Store have the List method of the client.PodInterface
// The Store must contain (only) Pods.
//
// Lister makes an Index have the List method. The Stores must contain only the expected type
// Example:
// s := cache.NewStore()
// lw := cache.ListWatch{Client: c, FieldSelector: sel, Resource: "pods"}
// r := cache.NewReflector(lw, &api.Pod{}, s).Run()
// l := StoreToPodLister{s}
// l.List()
// StoreToPodLister helps list pods
type
StoreToPodLister
struct
{
Indexer
Indexer
}
func
(
s
*
StoreToPodLister
)
List
(
selector
labels
.
Selector
)
(
pods
[]
*
api
.
Pod
,
err
error
)
{
func
(
s
*
StoreToPodLister
)
List
(
selector
labels
.
Selector
)
(
ret
[]
*
api
.
Pod
,
err
error
)
{
err
=
ListAll
(
s
.
Indexer
,
selector
,
func
(
m
interface
{})
{
pods
=
append
(
pods
,
m
.
(
*
api
.
Pod
))
ret
=
append
(
ret
,
m
.
(
*
api
.
Pod
))
})
return
pods
,
err
return
ret
,
err
}
func
(
s
*
StoreToPodLister
)
Pods
(
namespace
string
)
storePodsNamespacer
{
...
...
@@ -54,11 +56,11 @@ type storePodsNamespacer struct {
namespace
string
}
func
(
s
storePodsNamespacer
)
List
(
selector
labels
.
Selector
)
(
pods
[]
*
api
.
Pod
,
err
error
)
{
func
(
s
storePodsNamespacer
)
List
(
selector
labels
.
Selector
)
(
ret
[]
*
api
.
Pod
,
err
error
)
{
err
=
ListAllByNamespace
(
s
.
Indexer
,
s
.
namespace
,
selector
,
func
(
m
interface
{})
{
pods
=
append
(
pods
,
m
.
(
*
api
.
Pod
))
ret
=
append
(
ret
,
m
.
(
*
api
.
Pod
))
})
return
pods
,
err
return
ret
,
err
}
func
(
s
storePodsNamespacer
)
Get
(
name
string
)
(
*
api
.
Pod
,
error
)
{
...
...
@@ -133,3 +135,71 @@ func (s *StoreToServiceLister) GetPodServices(pod *api.Pod) (services []*api.Ser
return
services
,
nil
}
// StoreToReplicationControllerLister helps list rcs
type
StoreToReplicationControllerLister
struct
{
Indexer
Indexer
}
func
(
s
*
StoreToReplicationControllerLister
)
List
(
selector
labels
.
Selector
)
(
ret
[]
*
api
.
ReplicationController
,
err
error
)
{
err
=
ListAll
(
s
.
Indexer
,
selector
,
func
(
m
interface
{})
{
ret
=
append
(
ret
,
m
.
(
*
api
.
ReplicationController
))
})
return
ret
,
err
}
func
(
s
*
StoreToReplicationControllerLister
)
ReplicationControllers
(
namespace
string
)
storeReplicationControllersNamespacer
{
return
storeReplicationControllersNamespacer
{
s
.
Indexer
,
namespace
}
}
type
storeReplicationControllersNamespacer
struct
{
indexer
Indexer
namespace
string
}
func
(
s
storeReplicationControllersNamespacer
)
List
(
selector
labels
.
Selector
)
(
ret
[]
*
api
.
ReplicationController
,
err
error
)
{
err
=
ListAllByNamespace
(
s
.
indexer
,
s
.
namespace
,
selector
,
func
(
m
interface
{})
{
ret
=
append
(
ret
,
m
.
(
*
api
.
ReplicationController
))
})
return
ret
,
err
}
func
(
s
storeReplicationControllersNamespacer
)
Get
(
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
obj
,
exists
,
err
:=
s
.
indexer
.
GetByKey
(
s
.
namespace
+
"/"
+
name
)
if
err
!=
nil
{
return
nil
,
err
}
if
!
exists
{
return
nil
,
errors
.
NewNotFound
(
api
.
Resource
(
"replicationcontroller"
),
name
)
}
return
obj
.
(
*
api
.
ReplicationController
),
nil
}
// GetPodControllers returns a list of replication controllers managing a pod. Returns an error only if no matching controllers are found.
func
(
s
*
StoreToReplicationControllerLister
)
GetPodControllers
(
pod
*
api
.
Pod
)
(
controllers
[]
*
api
.
ReplicationController
,
err
error
)
{
if
len
(
pod
.
Labels
)
==
0
{
err
=
fmt
.
Errorf
(
"no controllers found for pod %v because it has no labels"
,
pod
.
Name
)
return
}
key
:=
&
api
.
ReplicationController
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
pod
.
Namespace
}}
items
,
err
:=
s
.
Indexer
.
Index
(
NamespaceIndex
,
key
)
if
err
!=
nil
{
return
}
for
_
,
m
:=
range
items
{
rc
:=
m
.
(
*
api
.
ReplicationController
)
selector
:=
labels
.
Set
(
rc
.
Spec
.
Selector
)
.
AsSelectorPreValidated
()
// If an rc with a nil or empty selector creeps in, it should match nothing, not everything.
if
selector
.
Empty
()
||
!
selector
.
Matches
(
labels
.
Set
(
pod
.
Labels
))
{
continue
}
controllers
=
append
(
controllers
,
rc
)
}
if
len
(
controllers
)
==
0
{
err
=
fmt
.
Errorf
(
"could not find controller for pod %s in namespace %s with labels: %v"
,
pod
.
Name
,
pod
.
Namespace
,
pod
.
Labels
)
}
return
}
staging/src/k8s.io/client-go/1.5/tools/cache/listers_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"testing"
...
...
@@ -128,7 +128,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
testCases
:=
[]
struct
{
description
string
inRCs
[]
*
api
.
ReplicationController
list
func
(
StoreToReplicationControllerLister
)
([]
api
.
ReplicationController
,
error
)
list
func
(
StoreToReplicationControllerLister
)
([]
*
api
.
ReplicationController
,
error
)
outRCNames
sets
.
String
expectErr
bool
onlyIfIndexedByNamespace
bool
...
...
@@ -143,7 +143,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"hmm"
,
Namespace
:
"hmm"
},
},
},
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
api
.
ReplicationController
,
error
)
{
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
*
api
.
ReplicationController
,
error
)
{
return
lister
.
ReplicationControllers
(
api
.
NamespaceAll
)
.
List
(
labels
.
Set
{}
.
AsSelectorPreValidated
())
},
outRCNames
:
sets
.
NewString
(
"hmm"
,
"foo"
),
...
...
@@ -158,7 +158,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"hmm"
,
Namespace
:
"hmm"
},
},
},
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
api
.
ReplicationController
,
error
)
{
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
*
api
.
ReplicationController
,
error
)
{
return
lister
.
ReplicationControllers
(
"hmm"
)
.
List
(
labels
.
Set
{}
.
AsSelectorPreValidated
())
},
outRCNames
:
sets
.
NewString
(
"hmm"
),
...
...
@@ -168,8 +168,8 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
inRCs
:
[]
*
api
.
ReplicationController
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"basic"
}},
},
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
api
.
ReplicationController
,
error
)
{
return
lister
.
List
()
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
*
api
.
ReplicationController
,
error
)
{
return
lister
.
List
(
labels
.
Everything
()
)
},
outRCNames
:
sets
.
NewString
(
"basic"
),
},
...
...
@@ -183,7 +183,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
},
},
},
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
api
.
ReplicationController
,
error
)
{
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
*
api
.
ReplicationController
,
error
)
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"pod1"
,
Namespace
:
"ns"
},
}
...
...
@@ -199,7 +199,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"basic"
,
Namespace
:
"ns"
},
},
},
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
api
.
ReplicationController
,
error
)
{
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
*
api
.
ReplicationController
,
error
)
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"pod1"
,
...
...
@@ -228,7 +228,7 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
},
},
},
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
api
.
ReplicationController
,
error
)
{
list
:
func
(
lister
StoreToReplicationControllerLister
)
([]
*
api
.
ReplicationController
,
error
)
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"pod1"
,
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/listwatch.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"time"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/processor_listener_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"testing"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/reflector.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"errors"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/reflector_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"errors"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/shared_informer.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"fmt"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/store.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"fmt"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/store_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"testing"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/thread_safe_store.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"fmt"
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
// UndeltaStore listens to incremental updates and sends complete state on every change.
// It implements the Store interface so that it can receive a stream of mirrored objects
...
...
staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store_test.go
View file @
ee092225
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
testing
package
cache
import
(
"reflect"
...
...
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