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
dc2e12d2
Commit
dc2e12d2
authored
Jul 11, 2016
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
manual changes to patch subresource
parent
d4df1681
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
12 deletions
+54
-12
generator_fake_for_type.go
...idl/client-gen/generators/fake/generator_fake_for_type.go
+5
-3
generator_for_type.go
cmd/libs/go2idl/client-gen/generators/generator_for_type.go
+3
-2
fake_testtype.go
.../typed/testgroup.k8s.io/unversioned/fake/fake_testtype.go
+3
-2
testgroup_test.go
...tset/typed/testgroup.k8s.io/unversioned/testgroup_test.go
+22
-0
testtype.go
...lclientset/typed/testgroup.k8s.io/unversioned/testtype.go
+3
-2
actions.go
pkg/client/testing/core/actions.go
+17
-2
test_utils.go
pkg/controller/node/test_utils.go
+1
-1
No files found.
cmd/libs/go2idl/client-gen/generators/fake/generator_fake_for_type.go
View file @
dc2e12d2
...
...
@@ -134,6 +134,8 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
"NewRootUpdateSubresourceAction"
:
c
.
Universe
.
Function
(
types
.
Name
{
Package
:
pkgTestingCore
,
Name
:
"NewRootUpdateSubresourceAction"
}),
"NewRootPatchAction"
:
c
.
Universe
.
Function
(
types
.
Name
{
Package
:
pkgTestingCore
,
Name
:
"NewRootPatchAction"
}),
"NewPatchAction"
:
c
.
Universe
.
Function
(
types
.
Name
{
Package
:
pkgTestingCore
,
Name
:
"NewPatchAction"
}),
"NewRootPatchSubresourceAction"
:
c
.
Universe
.
Function
(
types
.
Name
{
Package
:
pkgTestingCore
,
Name
:
"NewRootPatchSubresourceAction"
}),
"NewPatchSubresourceAction"
:
c
.
Universe
.
Function
(
types
.
Name
{
Package
:
pkgTestingCore
,
Name
:
"NewPatchSubresourceAction"
}),
}
noMethods
:=
extractBoolTagOrDie
(
"noMethods"
,
t
.
SecondClosestCommentLines
)
==
true
...
...
@@ -301,10 +303,10 @@ func (c *Fake$.type|publicPlural$) Watch(opts $.apiListOptions|raw$) ($.watchInt
var
patchTemplate
=
`
// Patch applies the patch and returns the patched $.type|private$.
func (c *Fake$.type|publicPlural$) Patch(name string, pt $.PatchType|raw$, data []byte) (result *$.type|raw$, err error) {
func (c *Fake$.type|publicPlural$) Patch(name string, pt $.PatchType|raw$, data []byte
, subresources ...string
) (result *$.type|raw$, err error) {
obj, err := c.Fake.
$if .namespaced$Invokes($.NewPatch
Action|raw$($.type|allLowercasePlural$Resource, c.ns, name, data
), &$.type|raw${})
$else$Invokes($.NewRootPatch
Action|raw$($.type|allLowercasePlural$Resource, name, data
), &$.type|raw${})$end$
$if .namespaced$Invokes($.NewPatch
SubresourceAction|raw$($.type|allLowercasePlural$Resource, c.ns, name, data, subresources...
), &$.type|raw${})
$else$Invokes($.NewRootPatch
SubresourceAction|raw$($.type|allLowercasePlural$Resource, name, data, subresources...
), &$.type|raw${})$end$
if obj == nil {
return nil, err
}
...
...
cmd/libs/go2idl/client-gen/generators/generator_for_type.go
View file @
dc2e12d2
...
...
@@ -161,7 +161,7 @@ var interfaceTemplate3 = `
Get(name string) (*$.type|raw$, error)
List(opts $.apiListOptions|raw$) (*$.type|raw$List, error)
Watch(opts $.apiListOptions|raw$) ($.watchInterface|raw$, error)
Patch(name string, pt $.PatchType|raw$, data []byte) (result *$.type|raw$, err error)`
Patch(name string, pt $.PatchType|raw$, data []byte
, subresources ...string
) (result *$.type|raw$, err error)`
var
interfaceTemplate4
=
`
$.type|public$Expansion
...
...
@@ -315,11 +315,12 @@ func (c *$.type|privatePlural$) Watch(opts $.apiListOptions|raw$) ($.watchInterf
var
patchTemplate
=
`
// Patch applies the patch and returns the patched $.type|private$.
func (c *$.type|privatePlural$) Patch(name string, pt $.PatchType|raw$, data []byte) (result *$.type|raw$, err error) {
func (c *$.type|privatePlural$) Patch(name string, pt $.PatchType|raw$, data []byte
, subresources ...string
) (result *$.type|raw$, err error) {
result = &$.type|raw${}
err = c.client.Patch(pt).
$if .namespaced$Namespace(c.ns).$end$
Resource("$.type|allLowercasePlural$").
SubResource(subresources...).
Name(name).
Body(data).
Do().
...
...
cmd/libs/go2idl/client-gen/testoutput/clientset_generated/test_internalclientset/typed/testgroup.k8s.io/unversioned/fake/fake_testtype.go
View file @
dc2e12d2
...
...
@@ -23,6 +23,7 @@ import (
core
"k8s.io/kubernetes/pkg/client/testing/core"
labels
"k8s.io/kubernetes/pkg/labels"
watch
"k8s.io/kubernetes/pkg/watch"
"path"
)
// FakeTestTypes implements TestTypeInterface
...
...
@@ -116,9 +117,9 @@ func (c *FakeTestTypes) Watch(opts api.ListOptions) (watch.Interface, error) {
}
// Patch applies the patch and returns the patched testType.
func
(
c
*
FakeTestTypes
)
Patch
(
name
string
,
pt
api
.
PatchType
,
data
[]
byte
)
(
result
*
testgroup_k8s_io
.
TestType
,
err
error
)
{
func
(
c
*
FakeTestTypes
)
Patch
(
name
string
,
pt
api
.
PatchType
,
data
[]
byte
,
subresources
...
string
)
(
result
*
testgroup_k8s_io
.
TestType
,
err
error
)
{
obj
,
err
:=
c
.
Fake
.
Invokes
(
core
.
NewPatch
Action
(
testtypesResource
,
c
.
ns
,
name
,
data
),
&
testgroup_k8s_io
.
TestType
{})
Invokes
(
core
.
NewPatch
SubresourceAction
(
testtypesResource
,
c
.
ns
,
name
,
data
,
path
.
Join
(
subresources
...
)
),
&
testgroup_k8s_io
.
TestType
{})
if
obj
==
nil
{
return
nil
,
err
...
...
cmd/libs/go2idl/client-gen/testoutput/clientset_generated/test_internalclientset/typed/testgroup.k8s.io/unversioned/testgroup_test.go
View file @
dc2e12d2
...
...
@@ -267,3 +267,25 @@ func TestPatchTestType(t *testing.T) {
receivedTestType
,
err
:=
c
.
Setup
(
t
)
.
TestTypes
(
ns
)
.
Patch
(
requestTestType
.
Name
,
api
.
StrategicMergePatchType
,
[]
byte
{})
c
.
simpleClient
.
Validate
(
t
,
receivedTestType
,
err
)
}
func
TestPatchSubresourcesTestType
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
requestTestType
:=
&
testgroup
.
TestType
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
ResourceVersion
:
"1"
,
Labels
:
map
[
string
]
string
{
"foo"
:
"bar"
,
"name"
:
"baz"
,
},
},
}
c
:=
DecoratedSimpleClient
{
simpleClient
:
simple
.
Client
{
Request
:
simple
.
Request
{
Method
:
"PATCH"
,
Path
:
testHelper
.
ResourcePath
(
"testtypes"
,
ns
,
"foo/status"
),
Query
:
simple
.
BuildQueryValues
(
nil
)},
Response
:
simple
.
Response
{
StatusCode
:
http
.
StatusOK
,
Body
:
requestTestType
},
},
}
receivedTestType
,
err
:=
c
.
Setup
(
t
)
.
TestTypes
(
ns
)
.
Patch
(
requestTestType
.
Name
,
api
.
StrategicMergePatchType
,
[]
byte
{},
"status"
)
c
.
simpleClient
.
Validate
(
t
,
receivedTestType
,
err
)
}
cmd/libs/go2idl/client-gen/testoutput/clientset_generated/test_internalclientset/typed/testgroup.k8s.io/unversioned/testtype.go
View file @
dc2e12d2
...
...
@@ -38,7 +38,7 @@ type TestTypeInterface interface {
Get
(
name
string
)
(
*
testgroup_k8s_io
.
TestType
,
error
)
List
(
opts
api
.
ListOptions
)
(
*
testgroup_k8s_io
.
TestTypeList
,
error
)
Watch
(
opts
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
Patch
(
name
string
,
pt
api
.
PatchType
,
data
[]
byte
)
(
result
*
testgroup_k8s_io
.
TestType
,
err
error
)
Patch
(
name
string
,
pt
api
.
PatchType
,
data
[]
byte
,
subresources
...
string
)
(
result
*
testgroup_k8s_io
.
TestType
,
err
error
)
TestTypeExpansion
}
...
...
@@ -151,11 +151,12 @@ func (c *testTypes) Watch(opts api.ListOptions) (watch.Interface, error) {
}
// Patch applies the patch and returns the patched testType.
func
(
c
*
testTypes
)
Patch
(
name
string
,
pt
api
.
PatchType
,
data
[]
byte
)
(
result
*
testgroup_k8s_io
.
TestType
,
err
error
)
{
func
(
c
*
testTypes
)
Patch
(
name
string
,
pt
api
.
PatchType
,
data
[]
byte
,
subresources
...
string
)
(
result
*
testgroup_k8s_io
.
TestType
,
err
error
)
{
result
=
&
testgroup_k8s_io
.
TestType
{}
err
=
c
.
client
.
Patch
(
pt
)
.
Namespace
(
c
.
ns
)
.
Resource
(
"testtypes"
)
.
SubResource
(
subresources
...
)
.
Name
(
name
)
.
Body
(
data
)
.
Do
()
.
...
...
pkg/client/testing/core/actions.go
View file @
dc2e12d2
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
core
import
(
"path"
"strings"
"k8s.io/kubernetes/pkg/api"
...
...
@@ -139,11 +140,25 @@ func NewPatchAction(resource unversioned.GroupVersionResource, namespace string,
return
action
}
func
New
PatchSubresourceAction
(
resource
unversioned
.
GroupVersionResource
,
subresource
string
)
PatchActionImpl
{
func
New
RootPatchSubresourceAction
(
resource
unversioned
.
GroupVersionResource
,
name
string
,
patch
[]
byte
,
subresources
...
string
)
PatchActionImpl
{
action
:=
PatchActionImpl
{}
action
.
Verb
=
"patch"
action
.
Resource
=
resource
action
.
Subresource
=
subresource
action
.
Subresource
=
path
.
Join
(
subresources
...
)
action
.
Name
=
name
action
.
Patch
=
patch
return
action
}
func
NewPatchSubresourceAction
(
resource
unversioned
.
GroupVersionResource
,
namespace
,
name
string
,
patch
[]
byte
,
subresources
...
string
)
PatchActionImpl
{
action
:=
PatchActionImpl
{}
action
.
Verb
=
"patch"
action
.
Resource
=
resource
action
.
Subresource
=
path
.
Join
(
subresources
...
)
action
.
Namespace
=
namespace
action
.
Name
=
name
action
.
Patch
=
patch
return
action
}
...
...
pkg/controller/node/test_utils.go
View file @
dc2e12d2
...
...
@@ -186,7 +186,7 @@ func (m *FakeNodeHandler) Watch(opts api.ListOptions) (watch.Interface, error) {
return
nil
,
nil
}
func
(
m
*
FakeNodeHandler
)
Patch
(
name
string
,
pt
api
.
PatchType
,
data
[]
byte
)
(
*
api
.
Node
,
error
)
{
func
(
m
*
FakeNodeHandler
)
Patch
(
name
string
,
pt
api
.
PatchType
,
data
[]
byte
,
subresources
...
string
)
(
*
api
.
Node
,
error
)
{
return
nil
,
nil
}
...
...
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