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
4a148f99
Commit
4a148f99
authored
Aug 06, 2015
by
Ananya Kumar
Committed by
Vishnu Kannan
Aug 18, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add client code
parent
b0679f18
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
515 additions
and
3 deletions
+515
-3
daemon.go
pkg/client/daemon.go
+92
-0
daemon_test.go
pkg/client/daemon_test.go
+159
-0
fake_daemons.go
pkg/client/testclient/fake_daemons.go
+70
-0
listers.go
pkg/client/unversioned/cache/listers.go
+53
-0
listers_test.go
pkg/client/unversioned/cache/listers_test.go
+122
-0
client.go
pkg/client/unversioned/client.go
+5
-0
doc.go
pkg/client/unversioned/doc.go
+1
-1
helper.go
pkg/client/unversioned/helper.go
+1
-1
resource_quotas_test.go
pkg/client/unversioned/resource_quotas_test.go
+4
-0
testclient.go
pkg/client/unversioned/testclient/testclient.go
+4
-0
etcd_test.go
pkg/registry/daemon/etcd/etcd_test.go
+4
-1
No files found.
pkg/client/daemon.go
0 → 100644
View file @
4a148f99
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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
client
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// DaemonsNamespacer has methods to work with Daemon resources in a namespace
type
DaemonsNamespacer
interface
{
Daemons
(
namespace
string
)
DaemonInterface
}
type
DaemonInterface
interface
{
List
(
selector
labels
.
Selector
)
(
*
api
.
DaemonList
,
error
)
Get
(
name
string
)
(
*
api
.
Daemon
,
error
)
Create
(
ctrl
*
api
.
Daemon
)
(
*
api
.
Daemon
,
error
)
Update
(
ctrl
*
api
.
Daemon
)
(
*
api
.
Daemon
,
error
)
Delete
(
name
string
)
error
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
}
// daemons implements DaemonsNamespacer interface
type
daemons
struct
{
r
*
Client
ns
string
}
func
newDaemons
(
c
*
Client
,
namespace
string
)
*
daemons
{
return
&
daemons
{
c
,
namespace
}
}
func
(
c
*
daemons
)
List
(
selector
labels
.
Selector
)
(
result
*
api
.
DaemonList
,
err
error
)
{
result
=
&
api
.
DaemonList
{}
err
=
c
.
r
.
Get
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"daemons"
)
.
LabelsSelectorParam
(
selector
)
.
Do
()
.
Into
(
result
)
return
}
// Get returns information about a particular daemon.
func
(
c
*
daemons
)
Get
(
name
string
)
(
result
*
api
.
Daemon
,
err
error
)
{
result
=
&
api
.
Daemon
{}
err
=
c
.
r
.
Get
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"daemons"
)
.
Name
(
name
)
.
Do
()
.
Into
(
result
)
return
}
// Create creates a new daemon.
func
(
c
*
daemons
)
Create
(
daemon
*
api
.
Daemon
)
(
result
*
api
.
Daemon
,
err
error
)
{
result
=
&
api
.
Daemon
{}
err
=
c
.
r
.
Post
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"daemons"
)
.
Body
(
daemon
)
.
Do
()
.
Into
(
result
)
return
}
// Update updates an existing daemon.
func
(
c
*
daemons
)
Update
(
daemon
*
api
.
Daemon
)
(
result
*
api
.
Daemon
,
err
error
)
{
result
=
&
api
.
Daemon
{}
err
=
c
.
r
.
Put
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"daemons"
)
.
Name
(
daemon
.
Name
)
.
Body
(
daemon
)
.
Do
()
.
Into
(
result
)
return
}
// Delete deletes an existing daemon.
func
(
c
*
daemons
)
Delete
(
name
string
)
error
{
return
c
.
r
.
Delete
()
.
Namespace
(
c
.
ns
)
.
Resource
(
"daemons"
)
.
Name
(
name
)
.
Do
()
.
Error
()
}
// Watch returns a watch.Interface that watches the requested daemons.
func
(
c
*
daemons
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
return
c
.
r
.
Get
()
.
Prefix
(
"watch"
)
.
Namespace
(
c
.
ns
)
.
Resource
(
"daemons"
)
.
Param
(
"resourceVersion"
,
resourceVersion
)
.
LabelsSelectorParam
(
label
)
.
FieldsSelectorParam
(
field
)
.
Watch
()
}
pkg/client/daemon_test.go
0 → 100644
View file @
4a148f99
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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
client
import
(
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/labels"
)
func
getDCResourceName
()
string
{
return
"daemons"
}
func
TestListDaemons
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceAll
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
testapi
.
ResourcePath
(
getDCResourceName
(),
ns
,
""
),
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
DaemonList
{
Items
:
[]
api
.
Daemon
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"name"
:
"baz"
,
},
},
Spec
:
api
.
DaemonSpec
{
Template
:
&
api
.
PodTemplateSpec
{},
},
},
},
},
},
}
receivedControllerList
,
err
:=
c
.
Setup
()
.
Daemons
(
ns
)
.
List
(
labels
.
Everything
())
c
.
Validate
(
t
,
receivedControllerList
,
err
)
}
func
TestGetDaemon
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
testapi
.
ResourcePath
(
getDCResourceName
(),
ns
,
"foo"
),
Query
:
buildQueryValues
(
nil
)},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Daemon
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"name"
:
"baz"
,
},
},
Spec
:
api
.
DaemonSpec
{
Template
:
&
api
.
PodTemplateSpec
{},
},
},
},
}
receivedController
,
err
:=
c
.
Setup
()
.
Daemons
(
ns
)
.
Get
(
"foo"
)
c
.
Validate
(
t
,
receivedController
,
err
)
}
func
TestGetDaemonWithNoName
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
c
:=
&
testClient
{
Error
:
true
}
receivedPod
,
err
:=
c
.
Setup
()
.
Daemons
(
ns
)
.
Get
(
""
)
if
(
err
!=
nil
)
&&
(
err
.
Error
()
!=
nameRequiredError
)
{
t
.
Errorf
(
"Expected error: %v, but got %v"
,
nameRequiredError
,
err
)
}
c
.
Validate
(
t
,
receivedPod
,
err
)
}
func
TestUpdateDaemon
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
requestController
:=
&
api
.
Daemon
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
},
}
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"PUT"
,
Path
:
testapi
.
ResourcePath
(
getDCResourceName
(),
ns
,
"foo"
),
Query
:
buildQueryValues
(
nil
)},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Daemon
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"name"
:
"baz"
,
},
},
Spec
:
api
.
DaemonSpec
{
Template
:
&
api
.
PodTemplateSpec
{},
},
},
},
}
receivedController
,
err
:=
c
.
Setup
()
.
Daemons
(
ns
)
.
Update
(
requestController
)
c
.
Validate
(
t
,
receivedController
,
err
)
}
func
TestDeleteDaemon
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"DELETE"
,
Path
:
testapi
.
ResourcePath
(
getDCResourceName
(),
ns
,
"foo"
),
Query
:
buildQueryValues
(
nil
)},
Response
:
Response
{
StatusCode
:
200
},
}
err
:=
c
.
Setup
()
.
Daemons
(
ns
)
.
Delete
(
"foo"
)
c
.
Validate
(
t
,
nil
,
err
)
}
func
TestCreateDaemon
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
requestController
:=
&
api
.
Daemon
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
}
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"POST"
,
Path
:
testapi
.
ResourcePath
(
getDCResourceName
(),
ns
,
""
),
Body
:
requestController
,
Query
:
buildQueryValues
(
nil
)},
Response
:
Response
{
StatusCode
:
200
,
Body
:
&
api
.
Daemon
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"name"
:
"baz"
,
},
},
Spec
:
api
.
DaemonSpec
{
Template
:
&
api
.
PodTemplateSpec
{},
},
},
},
}
receivedController
,
err
:=
c
.
Setup
()
.
Daemons
(
ns
)
.
Create
(
requestController
)
c
.
Validate
(
t
,
receivedController
,
err
)
}
pkg/client/testclient/fake_daemons.go
0 → 100644
View file @
4a148f99
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
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
testclient
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
)
// FakeDaemons implements DaemonInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the method you want to test easier.
type
FakeDaemons
struct
{
Fake
*
Fake
Namespace
string
}
const
(
GetDaemonAction
=
"get-daemon"
UpdateDaemonAction
=
"update-daemon"
WatchDaemonAction
=
"watch-daemon"
DeleteDaemonAction
=
"delete-daemon"
ListDaemonAction
=
"list-daemons"
CreateDaemonAction
=
"create-daemon"
)
func
(
c
*
FakeDaemons
)
Get
(
name
string
)
(
*
api
.
Daemon
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewGetAction
(
"daemons"
,
c
.
Namespace
,
name
),
&
api
.
Daemon
{})
return
obj
.
(
*
api
.
Daemon
),
err
}
func
(
c
*
FakeDaemons
)
List
(
label
labels
.
Selector
)
(
*
api
.
DaemonList
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewListAction
(
"daemons"
,
c
.
Namespace
,
label
,
nil
),
&
api
.
DaemonList
{})
return
obj
.
(
*
api
.
DaemonList
),
err
}
func
(
c
*
FakeDaemons
)
Create
(
daemon
*
api
.
Daemon
)
(
*
api
.
Daemon
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewCreateAction
(
"daemons"
,
c
.
Namespace
,
daemon
),
&
api
.
Daemon
{})
return
obj
.
(
*
api
.
Daemon
),
err
}
func
(
c
*
FakeDaemons
)
Update
(
daemon
*
api
.
Daemon
)
(
*
api
.
Daemon
,
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
NewUpdateAction
(
"daemons"
,
c
.
Namespace
,
daemon
),
&
api
.
Daemon
{})
return
obj
.
(
*
api
.
Daemon
),
err
}
func
(
c
*
FakeDaemons
)
Delete
(
name
string
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
NewDeleteAction
(
"daemons"
,
c
.
Namespace
,
name
),
&
api
.
Daemon
{})
return
err
}
func
(
c
*
FakeDaemons
)
Watch
(
label
labels
.
Selector
,
field
fields
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Invokes
(
NewWatchAction
(
"daemons"
,
c
.
Namespace
,
label
,
field
,
resourceVersion
),
nil
)
return
c
.
Fake
.
Watch
,
nil
}
pkg/client/unversioned/cache/listers.go
View file @
4a148f99
...
@@ -225,6 +225,59 @@ func (s *StoreToReplicationControllerLister) GetPodControllers(pod *api.Pod) (co
...
@@ -225,6 +225,59 @@ func (s *StoreToReplicationControllerLister) GetPodControllers(pod *api.Pod) (co
return
return
}
}
// StoreToDaemonLister gives a store List and Exists methods. The store must contain only Daemons.
type
StoreToDaemonLister
struct
{
Store
}
// Exists checks if the given dc exists in the store.
func
(
s
*
StoreToDaemonLister
)
Exists
(
daemon
*
api
.
Daemon
)
(
bool
,
error
)
{
_
,
exists
,
err
:=
s
.
Store
.
Get
(
daemon
)
if
err
!=
nil
{
return
false
,
err
}
return
exists
,
nil
}
// StoreToDaemonLister lists all daemons in the store.
// TODO: converge on the interface in pkg/client
func
(
s
*
StoreToDaemonLister
)
List
()
(
daemons
[]
api
.
Daemon
,
err
error
)
{
for
_
,
c
:=
range
s
.
Store
.
List
()
{
daemons
=
append
(
daemons
,
*
(
c
.
(
*
api
.
Daemon
)))
}
return
daemons
,
nil
}
// GetPodDaemon returns a list of daemon daemons managing a pod. Returns an error iff no matching daemons are found.
func
(
s
*
StoreToDaemonLister
)
GetPodDaemon
(
pod
*
api
.
Pod
)
(
daemons
[]
api
.
Daemon
,
err
error
)
{
var
selector
labels
.
Selector
var
dc
api
.
Daemon
if
len
(
pod
.
Labels
)
==
0
{
err
=
fmt
.
Errorf
(
"No daemons found for pod %v because it has no labels"
,
pod
.
Name
)
return
}
for
_
,
m
:=
range
s
.
Store
.
List
()
{
dc
=
*
m
.
(
*
api
.
Daemon
)
if
dc
.
Namespace
!=
pod
.
Namespace
{
continue
}
labelSet
:=
labels
.
Set
(
dc
.
Spec
.
Selector
)
selector
=
labels
.
Set
(
dc
.
Spec
.
Selector
)
.
AsSelector
()
// If an dc with a nil or empty selector creeps in, it should match nothing, not everything.
if
labelSet
.
AsSelector
()
.
Empty
()
||
!
selector
.
Matches
(
labels
.
Set
(
pod
.
Labels
))
{
continue
}
daemons
=
append
(
daemons
,
dc
)
}
if
len
(
daemons
)
==
0
{
err
=
fmt
.
Errorf
(
"Could not find daemons for pod %s in namespace %s with labels: %v"
,
pod
.
Name
,
pod
.
Namespace
,
pod
.
Labels
)
}
return
}
// StoreToServiceLister makes a Store that has the List method of the client.ServiceInterface
// StoreToServiceLister makes a Store that has the List method of the client.ServiceInterface
// The Store must contain (only) Services.
// The Store must contain (only) Services.
type
StoreToServiceLister
struct
{
type
StoreToServiceLister
struct
{
...
...
pkg/client/unversioned/cache/listers_test.go
View file @
4a148f99
...
@@ -155,6 +155,128 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
...
@@ -155,6 +155,128 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
}
}
}
}
func
TestStoreToDaemonLister
(
t
*
testing
.
T
)
{
store
:=
NewStore
(
MetaNamespaceKeyFunc
)
lister
:=
StoreToDaemonLister
{
store
}
testCases
:=
[]
struct
{
inDCs
[]
*
api
.
Daemon
list
func
()
([]
api
.
Daemon
,
error
)
outDCNames
util
.
StringSet
expectErr
bool
}{
// Basic listing
{
inDCs
:
[]
*
api
.
Daemon
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"basic"
}},
},
list
:
func
()
([]
api
.
Daemon
,
error
)
{
return
lister
.
List
()
},
outDCNames
:
util
.
NewStringSet
(
"basic"
),
},
// Listing multiple controllers
{
inDCs
:
[]
*
api
.
Daemon
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"basic"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"complex"
}},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"complex2"
}},
},
list
:
func
()
([]
api
.
Daemon
,
error
)
{
return
lister
.
List
()
},
outDCNames
:
util
.
NewStringSet
(
"basic"
,
"complex"
,
"complex2"
),
},
// No pod lables
{
inDCs
:
[]
*
api
.
Daemon
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"basic"
,
Namespace
:
"ns"
},
Spec
:
api
.
DaemonSpec
{
Selector
:
map
[
string
]
string
{
"foo"
:
"baz"
},
},
},
},
list
:
func
()
([]
api
.
Daemon
,
error
)
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"pod1"
,
Namespace
:
"ns"
},
}
return
lister
.
GetPodDaemon
(
pod
)
},
outDCNames
:
util
.
NewStringSet
(),
expectErr
:
true
,
},
// No RC selectors
{
inDCs
:
[]
*
api
.
Daemon
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"basic"
,
Namespace
:
"ns"
},
},
},
list
:
func
()
([]
api
.
Daemon
,
error
)
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"pod1"
,
Namespace
:
"ns"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
}
return
lister
.
GetPodDaemon
(
pod
)
},
outDCNames
:
util
.
NewStringSet
(),
expectErr
:
true
,
},
// Matching labels to selectors and namespace
{
inDCs
:
[]
*
api
.
Daemon
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
Spec
:
api
.
DaemonSpec
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
,
Namespace
:
"ns"
},
Spec
:
api
.
DaemonSpec
{
Selector
:
map
[
string
]
string
{
"foo"
:
"bar"
},
},
},
},
list
:
func
()
([]
api
.
Daemon
,
error
)
{
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"pod1"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
},
Namespace
:
"ns"
,
},
}
return
lister
.
GetPodDaemon
(
pod
)
},
outDCNames
:
util
.
NewStringSet
(
"bar"
),
},
}
for
_
,
c
:=
range
testCases
{
for
_
,
r
:=
range
c
.
inDCs
{
store
.
Add
(
r
)
}
gotControllers
,
err
:=
c
.
list
()
if
err
!=
nil
&&
c
.
expectErr
{
continue
}
else
if
c
.
expectErr
{
t
.
Fatalf
(
"Expected error, got none"
)
}
else
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error %#v"
,
err
)
}
gotNames
:=
make
([]
string
,
len
(
gotControllers
))
for
ix
:=
range
gotControllers
{
gotNames
[
ix
]
=
gotControllers
[
ix
]
.
Name
}
if
!
c
.
outDCNames
.
HasAll
(
gotNames
...
)
||
len
(
gotNames
)
!=
len
(
c
.
outDCNames
)
{
t
.
Errorf
(
"Unexpected got controllers %+v expected %+v"
,
gotNames
,
c
.
outDCNames
)
}
}
}
func
TestStoreToPodLister
(
t
*
testing
.
T
)
{
func
TestStoreToPodLister
(
t
*
testing
.
T
)
{
store
:=
NewStore
(
MetaNamespaceKeyFunc
)
store
:=
NewStore
(
MetaNamespaceKeyFunc
)
ids
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
ids
:=
[]
string
{
"foo"
,
"bar"
,
"baz"
}
...
...
pkg/client/unversioned/client.go
View file @
4a148f99
...
@@ -33,6 +33,7 @@ type Interface interface {
...
@@ -33,6 +33,7 @@ type Interface interface {
PodsNamespacer
PodsNamespacer
PodTemplatesNamespacer
PodTemplatesNamespacer
ReplicationControllersNamespacer
ReplicationControllersNamespacer
DaemonsNamespacer
ServicesNamespacer
ServicesNamespacer
EndpointsNamespacer
EndpointsNamespacer
VersionInterface
VersionInterface
...
@@ -52,6 +53,10 @@ func (c *Client) ReplicationControllers(namespace string) ReplicationControllerI
...
@@ -52,6 +53,10 @@ func (c *Client) ReplicationControllers(namespace string) ReplicationControllerI
return
newReplicationControllers
(
c
,
namespace
)
return
newReplicationControllers
(
c
,
namespace
)
}
}
func
(
c
*
Client
)
Daemons
(
namespace
string
)
DaemonInterface
{
return
newDaemons
(
c
,
namespace
)
}
func
(
c
*
Client
)
Nodes
()
NodeInterface
{
func
(
c
*
Client
)
Nodes
()
NodeInterface
{
return
newNodes
(
c
)
return
newNodes
(
c
)
}
}
...
...
pkg/client/unversioned/doc.go
View file @
4a148f99
...
@@ -17,7 +17,7 @@ limitations under the License.
...
@@ -17,7 +17,7 @@ limitations under the License.
/*
/*
Package client contains the implementation of the client side communication with the
Package client contains the implementation of the client side communication with the
Kubernetes master. The Client class provides methods for reading, creating, updating,
Kubernetes master. The Client class provides methods for reading, creating, updating,
and deleting pods, replication controllers, services, and minions.
and deleting pods, replication controllers,
daemons,
services, and minions.
Most consumers should use the Config object to create a Client:
Most consumers should use the Config object to create a Client:
...
...
pkg/client/unversioned/helper.go
View file @
4a148f99
...
@@ -127,7 +127,7 @@ type TLSClientConfig struct {
...
@@ -127,7 +127,7 @@ type TLSClientConfig struct {
}
}
// New creates a Kubernetes client for the given config. This client works with pods,
// New creates a Kubernetes client for the given config. This client works with pods,
// replication controllers and services. It allows operations such as list, get, update
// replication controllers
, daemons,
and services. It allows operations such as list, get, update
// and delete on these objects. An error is returned if the provided configuration
// and delete on these objects. An error is returned if the provided configuration
// is not valid.
// is not valid.
func
New
(
c
*
Config
)
(
*
Client
,
error
)
{
func
New
(
c
*
Config
)
(
*
Client
,
error
)
{
...
...
pkg/client/unversioned/resource_quotas_test.go
View file @
4a148f99
...
@@ -45,6 +45,7 @@ func TestResourceQuotaCreate(t *testing.T) {
...
@@ -45,6 +45,7 @@ func TestResourceQuotaCreate(t *testing.T) {
api
.
ResourcePods
:
resource
.
MustParse
(
"10"
),
api
.
ResourcePods
:
resource
.
MustParse
(
"10"
),
api
.
ResourceServices
:
resource
.
MustParse
(
"10"
),
api
.
ResourceServices
:
resource
.
MustParse
(
"10"
),
api
.
ResourceReplicationControllers
:
resource
.
MustParse
(
"10"
),
api
.
ResourceReplicationControllers
:
resource
.
MustParse
(
"10"
),
api
.
ResourceDaemon
:
resource
.
MustParse
(
"10"
),
api
.
ResourceQuotas
:
resource
.
MustParse
(
"10"
),
api
.
ResourceQuotas
:
resource
.
MustParse
(
"10"
),
},
},
},
},
...
@@ -77,6 +78,7 @@ func TestResourceQuotaGet(t *testing.T) {
...
@@ -77,6 +78,7 @@ func TestResourceQuotaGet(t *testing.T) {
api
.
ResourcePods
:
resource
.
MustParse
(
"10"
),
api
.
ResourcePods
:
resource
.
MustParse
(
"10"
),
api
.
ResourceServices
:
resource
.
MustParse
(
"10"
),
api
.
ResourceServices
:
resource
.
MustParse
(
"10"
),
api
.
ResourceReplicationControllers
:
resource
.
MustParse
(
"10"
),
api
.
ResourceReplicationControllers
:
resource
.
MustParse
(
"10"
),
api
.
ResourceDaemon
:
resource
.
MustParse
(
"10"
),
api
.
ResourceQuotas
:
resource
.
MustParse
(
"10"
),
api
.
ResourceQuotas
:
resource
.
MustParse
(
"10"
),
},
},
},
},
...
@@ -133,6 +135,7 @@ func TestResourceQuotaUpdate(t *testing.T) {
...
@@ -133,6 +135,7 @@ func TestResourceQuotaUpdate(t *testing.T) {
api
.
ResourcePods
:
resource
.
MustParse
(
"10"
),
api
.
ResourcePods
:
resource
.
MustParse
(
"10"
),
api
.
ResourceServices
:
resource
.
MustParse
(
"10"
),
api
.
ResourceServices
:
resource
.
MustParse
(
"10"
),
api
.
ResourceReplicationControllers
:
resource
.
MustParse
(
"10"
),
api
.
ResourceReplicationControllers
:
resource
.
MustParse
(
"10"
),
api
.
ResourceDaemon
:
resource
.
MustParse
(
"10"
),
api
.
ResourceQuotas
:
resource
.
MustParse
(
"10"
),
api
.
ResourceQuotas
:
resource
.
MustParse
(
"10"
),
},
},
},
},
...
@@ -160,6 +163,7 @@ func TestResourceQuotaStatusUpdate(t *testing.T) {
...
@@ -160,6 +163,7 @@ func TestResourceQuotaStatusUpdate(t *testing.T) {
api
.
ResourcePods
:
resource
.
MustParse
(
"10"
),
api
.
ResourcePods
:
resource
.
MustParse
(
"10"
),
api
.
ResourceServices
:
resource
.
MustParse
(
"10"
),
api
.
ResourceServices
:
resource
.
MustParse
(
"10"
),
api
.
ResourceReplicationControllers
:
resource
.
MustParse
(
"10"
),
api
.
ResourceReplicationControllers
:
resource
.
MustParse
(
"10"
),
api
.
ResourceDaemon
:
resource
.
MustParse
(
"10"
),
api
.
ResourceQuotas
:
resource
.
MustParse
(
"10"
),
api
.
ResourceQuotas
:
resource
.
MustParse
(
"10"
),
},
},
},
},
...
...
pkg/client/unversioned/testclient/testclient.go
View file @
4a148f99
...
@@ -114,6 +114,10 @@ func (c *Fake) ReplicationControllers(namespace string) client.ReplicationContro
...
@@ -114,6 +114,10 @@ func (c *Fake) ReplicationControllers(namespace string) client.ReplicationContro
return
&
FakeReplicationControllers
{
Fake
:
c
,
Namespace
:
namespace
}
return
&
FakeReplicationControllers
{
Fake
:
c
,
Namespace
:
namespace
}
}
}
func
(
c
*
Fake
)
Daemons
(
namespace
string
)
client
.
DaemonInterface
{
return
&
FakeDaemons
{
Fake
:
c
,
Namespace
:
namespace
}
}
func
(
c
*
Fake
)
Nodes
()
client
.
NodeInterface
{
func
(
c
*
Fake
)
Nodes
()
client
.
NodeInterface
{
return
&
FakeNodes
{
Fake
:
c
}
return
&
FakeNodes
{
Fake
:
c
}
}
}
...
...
pkg/registry/daemon/etcd/etcd_test.go
View file @
4a148f99
/*
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Copyright 2015 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
...
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