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
0a435c81
Commit
0a435c81
authored
Feb 12, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4313 from derekwaynecarr/client_watch_namespaces
Add ability to watch namespaces from client
parents
b2d50ce1
73aa0cc1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
fake_namespaces.go
pkg/client/fake_namespaces.go
+6
-0
namespaces.go
pkg/client/namespaces.go
+13
-0
namespaces_test.go
pkg/client/namespaces_test.go
+10
-0
No files found.
pkg/client/fake_namespaces.go
View file @
0a435c81
...
...
@@ -19,6 +19,7 @@ package client
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
)
// FakeNamespaces implements NamespacesInterface. Meant to be embedded into a struct to get a default
...
...
@@ -51,3 +52,8 @@ func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-namespace"
,
Value
:
namespace
.
Name
})
return
&
api
.
Namespace
{},
nil
}
func
(
c
*
FakeNamespaces
)
Watch
(
label
,
field
labels
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"watch-namespaces"
,
Value
:
resourceVersion
})
return
c
.
Fake
.
Watch
,
nil
}
pkg/client/namespaces.go
View file @
0a435c81
...
...
@@ -22,6 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
)
type
NamespacesInterface
interface
{
...
...
@@ -34,6 +35,7 @@ type NamespaceInterface interface {
List
(
selector
labels
.
Selector
)
(
*
api
.
NamespaceList
,
error
)
Delete
(
name
string
)
error
Update
(
item
*
api
.
Namespace
)
(
*
api
.
Namespace
,
error
)
Watch
(
label
,
field
labels
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
}
// namespaces implements NamespacesInterface
...
...
@@ -86,3 +88,14 @@ func (c *namespaces) Get(name string) (*api.Namespace, error) {
func
(
c
*
namespaces
)
Delete
(
name
string
)
error
{
return
c
.
r
.
Delete
()
.
Resource
(
"namespaces"
)
.
Name
(
name
)
.
Do
()
.
Error
()
}
// Watch returns a watch.Interface that watches the requested namespaces.
func
(
c
*
namespaces
)
Watch
(
label
,
field
labels
.
Selector
,
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
return
c
.
r
.
Get
()
.
Prefix
(
"watch"
)
.
Resource
(
"namespaces"
)
.
Param
(
"resourceVersion"
,
resourceVersion
)
.
SelectorParam
(
"labels"
,
label
)
.
SelectorParam
(
"fields"
,
field
)
.
Watch
()
}
pkg/client/namespaces_test.go
View file @
0a435c81
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
client
import
(
"net/url"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
...
@@ -132,3 +133,12 @@ func TestNamespaceDelete(t *testing.T) {
err
:=
c
.
Setup
()
.
Namespaces
()
.
Delete
(
"foo"
)
c
.
Validate
(
t
,
nil
,
err
)
}
func
TestNamespaceWatch
(
t
*
testing
.
T
)
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"GET"
,
Path
:
"/watch/namespaces"
,
Query
:
url
.
Values
{
"resourceVersion"
:
[]
string
{}}},
Response
:
Response
{
StatusCode
:
200
},
}
_
,
err
:=
c
.
Setup
()
.
Namespaces
()
.
Watch
(
labels
.
Everything
(),
labels
.
Everything
(),
""
)
c
.
Validate
(
t
,
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