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
6410f37a
Commit
6410f37a
authored
Jan 26, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3591 from ddysher/node-client-update
Add node update method to client interface
parents
ae0a39bd
e7122738
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
6 deletions
+51
-6
client_test.go
pkg/client/client_test.go
+21
-0
fake_minions.go
pkg/client/fake_minions.go
+5
-0
minions.go
pkg/client/minions.go
+17
-3
rest_to_nodes.go
pkg/master/rest_to_nodes.go
+8
-3
No files found.
pkg/client/client_test.go
View file @
6410f37a
...
...
@@ -759,6 +759,27 @@ func TestDeleteMinion(t *testing.T) {
c
.
Validate
(
t
,
nil
,
err
)
}
func
TestUpdateMinion
(
t
*
testing
.
T
)
{
requestMinion
:=
&
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
,
},
Spec
:
api
.
NodeSpec
{
Capacity
:
api
.
ResourceList
{
api
.
ResourceCPU
:
resource
.
MustParse
(
"1000m"
),
api
.
ResourceMemory
:
resource
.
MustParse
(
"1Mi"
),
},
},
}
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"PUT"
,
Path
:
"/minions/foo"
},
Response
:
Response
{
StatusCode
:
200
,
Body
:
requestMinion
},
}
response
,
err
:=
c
.
Setup
()
.
Nodes
()
.
Update
(
requestMinion
)
c
.
Validate
(
t
,
response
,
err
)
}
func
TestNewMinionPath
(
t
*
testing
.
T
)
{
c
:=
&
testClient
{
Request
:
testRequest
{
Method
:
"DELETE"
,
Path
:
"/nodes/foo"
},
...
...
pkg/client/fake_minions.go
View file @
6410f37a
...
...
@@ -51,3 +51,8 @@ func (c *FakeNodes) Delete(id string) error {
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"delete-minion"
,
Value
:
id
})
return
nil
}
func
(
c
*
FakeNodes
)
Update
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
c
.
Fake
.
Actions
=
append
(
c
.
Fake
.
Actions
,
FakeAction
{
Action
:
"update-minion"
,
Value
:
minion
})
return
&
api
.
Node
{},
nil
}
pkg/client/minions.go
View file @
6410f37a
...
...
@@ -18,6 +18,7 @@ package client
import
(
"errors"
"fmt"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
)
...
...
@@ -31,6 +32,7 @@ type NodeInterface interface {
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
List
()
(
*
api
.
NodeList
,
error
)
Delete
(
name
string
)
error
Update
(
*
api
.
Node
)
(
*
api
.
Node
,
error
)
}
// nodes implements NodesInterface
...
...
@@ -44,6 +46,7 @@ func newNodes(c *Client) *nodes {
return
&
nodes
{
c
}
}
// resourceName returns node's URL resource name based on resource version.
func
(
c
*
nodes
)
resourceName
()
string
{
if
preV1Beta3
(
c
.
r
.
APIVersion
())
{
return
"minions"
...
...
@@ -51,7 +54,7 @@ func (c *nodes) resourceName() string {
return
"nodes"
}
// Create creates a new
minion
.
// Create creates a new
node
.
func
(
c
*
nodes
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
result
:=
&
api
.
Node
{}
err
:=
c
.
r
.
Post
()
.
Resource
(
c
.
resourceName
())
.
Body
(
minion
)
.
Do
()
.
Into
(
result
)
...
...
@@ -65,7 +68,7 @@ func (c *nodes) List() (*api.NodeList, error) {
return
result
,
err
}
// Get gets an existing
minion
// Get gets an existing
node.
func
(
c
*
nodes
)
Get
(
name
string
)
(
*
api
.
Node
,
error
)
{
if
len
(
name
)
==
0
{
return
nil
,
errors
.
New
(
"name is required parameter to Get"
)
...
...
@@ -76,7 +79,18 @@ func (c *nodes) Get(name string) (*api.Node, error) {
return
result
,
err
}
// Delete deletes an existing
minion
.
// Delete deletes an existing
node
.
func
(
c
*
nodes
)
Delete
(
name
string
)
error
{
return
c
.
r
.
Delete
()
.
Resource
(
c
.
resourceName
())
.
Name
(
name
)
.
Do
()
.
Error
()
}
// Update updates an existing node.
func
(
c
*
nodes
)
Update
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
result
:=
&
api
.
Node
{}
if
len
(
minion
.
ResourceVersion
)
==
0
{
err
:=
fmt
.
Errorf
(
"invalid update object, missing resource version: %v"
,
minion
)
return
nil
,
err
}
err
:=
c
.
r
.
Put
()
.
Resource
(
c
.
resourceName
())
.
Name
(
minion
.
Name
)
.
Body
(
minion
)
.
Do
()
.
Into
(
result
)
return
result
,
err
}
pkg/master/rest_to_nodes.go
View file @
6410f37a
...
...
@@ -48,7 +48,7 @@ func (n *nodeAdaptor) Nodes() client.NodeInterface {
return
n
}
// Create creates a new
minion
.
// Create creates a new
node
.
func
(
n
*
nodeAdaptor
)
Create
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
return
nil
,
errors
.
New
(
"direct creation not implemented"
)
// TODO: apiserver should expose newOperation to make this easier.
...
...
@@ -71,7 +71,7 @@ func (n *nodeAdaptor) List() (*api.NodeList, error) {
return
obj
.
(
*
api
.
NodeList
),
nil
}
// Get gets an existing
minion
// Get gets an existing
node.
func
(
n
*
nodeAdaptor
)
Get
(
name
string
)
(
*
api
.
Node
,
error
)
{
ctx
:=
api
.
NewContext
()
obj
,
err
:=
n
.
storage
.
(
apiserver
.
RESTGetter
)
.
Get
(
ctx
,
name
)
...
...
@@ -81,8 +81,13 @@ func (n *nodeAdaptor) Get(name string) (*api.Node, error) {
return
obj
.
(
*
api
.
Node
),
nil
}
// Delete deletes an existing
minion
.
// Delete deletes an existing
node
.
// TODO: implement
func
(
n
*
nodeAdaptor
)
Delete
(
name
string
)
error
{
return
errors
.
New
(
"direct deletion not implemented"
)
}
// Update updates an existing node.
func
(
n
*
nodeAdaptor
)
Update
(
minion
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
return
nil
,
errors
.
New
(
"direct update not implemented"
)
}
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