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
654ceb6e
Commit
654ceb6e
authored
Oct 08, 2015
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
run grep-sed
parent
29d3351b
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
13 additions
and
13 deletions
+13
-13
integration.go
cmd/integration/integration.go
+2
-2
api_installer.go
pkg/apiserver/api_installer.go
+1
-1
index.go
pkg/apiserver/index.go
+1
-1
resthandler.go
pkg/apiserver/resthandler.go
+3
-3
resthandler_test.go
pkg/apiserver/resthandler_test.go
+1
-1
fake.go
pkg/client/unversioned/fake/fake.go
+1
-1
restclient.go
pkg/client/unversioned/restclient.go
+1
-1
interfaces.go
pkg/kubectl/interfaces.go
+1
-1
helper.go
pkg/kubectl/resource/helper.go
+1
-1
interfaces.go
pkg/kubectl/resource/interfaces.go
+1
-1
No files found.
cmd/integration/integration.go
View file @
654ceb6e
...
@@ -667,7 +667,7 @@ func runPatchTest(c *client.Client) {
...
@@ -667,7 +667,7 @@ func runPatchTest(c *client.Client) {
glog
.
Fatalf
(
"Failed creating patchservice: %v"
,
err
)
glog
.
Fatalf
(
"Failed creating patchservice: %v"
,
err
)
}
}
patchBodies
:=
map
[
string
]
map
[
api
.
PatchType
]
struct
{
patchBodies
:=
map
[
string
]
map
[
unversioned
.
PatchType
]
struct
{
AddLabelBody
[]
byte
AddLabelBody
[]
byte
RemoveLabelBody
[]
byte
RemoveLabelBody
[]
byte
RemoveAllLabelsBody
[]
byte
RemoveAllLabelsBody
[]
byte
...
@@ -693,7 +693,7 @@ func runPatchTest(c *client.Client) {
...
@@ -693,7 +693,7 @@ func runPatchTest(c *client.Client) {
pb
:=
patchBodies
[
c
.
APIVersion
()]
pb
:=
patchBodies
[
c
.
APIVersion
()]
execPatch
:=
func
(
pt
api
.
PatchType
,
body
[]
byte
)
error
{
execPatch
:=
func
(
pt
unversioned
.
PatchType
,
body
[]
byte
)
error
{
return
c
.
Patch
(
pt
)
.
return
c
.
Patch
(
pt
)
.
Resource
(
resource
)
.
Resource
(
resource
)
.
Namespace
(
api
.
NamespaceDefault
)
.
Namespace
(
api
.
NamespaceDefault
)
.
...
...
pkg/apiserver/api_installer.go
View file @
654ceb6e
...
@@ -481,7 +481,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
...
@@ -481,7 +481,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
Operation
(
"patch"
+
namespaced
+
kind
+
strings
.
Title
(
subresource
))
.
Operation
(
"patch"
+
namespaced
+
kind
+
strings
.
Title
(
subresource
))
.
Produces
(
append
(
storageMeta
.
ProducesMIMETypes
(
action
.
Verb
),
"application/json"
)
...
)
.
Produces
(
append
(
storageMeta
.
ProducesMIMETypes
(
action
.
Verb
),
"application/json"
)
...
)
.
Returns
(
http
.
StatusOK
,
"OK"
,
versionedObject
)
.
Returns
(
http
.
StatusOK
,
"OK"
,
versionedObject
)
.
Reads
(
api
.
Patch
{})
.
Reads
(
unversioned
.
Patch
{})
.
Writes
(
versionedObject
)
Writes
(
versionedObject
)
addParams
(
route
,
action
.
Params
)
addParams
(
route
,
action
.
Params
)
ws
.
Route
(
route
)
ws
.
Route
(
route
)
...
...
pkg/apiserver/index.go
View file @
654ceb6e
...
@@ -41,6 +41,6 @@ func IndexHandler(container *restful.Container, muxHelper *MuxHelper) func(http.
...
@@ -41,6 +41,6 @@ func IndexHandler(container *restful.Container, muxHelper *MuxHelper) func(http.
// Extract the paths handled using mux handler.
// Extract the paths handled using mux handler.
handledPaths
=
append
(
handledPaths
,
muxHelper
.
RegisteredPaths
...
)
handledPaths
=
append
(
handledPaths
,
muxHelper
.
RegisteredPaths
...
)
sort
.
Strings
(
handledPaths
)
sort
.
Strings
(
handledPaths
)
writeRawJSON
(
status
,
api
.
RootPaths
{
Paths
:
handledPaths
},
w
)
writeRawJSON
(
status
,
unversioned
.
RootPaths
{
Paths
:
handledPaths
},
w
)
}
}
}
}
pkg/apiserver/resthandler.go
View file @
654ceb6e
...
@@ -407,7 +407,7 @@ func PatchResource(r rest.Patcher, scope RequestScope, typer runtime.ObjectTyper
...
@@ -407,7 +407,7 @@ func PatchResource(r rest.Patcher, scope RequestScope, typer runtime.ObjectTyper
if
idx
:=
strings
.
Index
(
contentType
,
";"
);
idx
>
0
{
if
idx
:=
strings
.
Index
(
contentType
,
";"
);
idx
>
0
{
contentType
=
contentType
[
:
idx
]
contentType
=
contentType
[
:
idx
]
}
}
patchType
:=
api
.
PatchType
(
contentType
)
patchType
:=
unversioned
.
PatchType
(
contentType
)
patchJS
,
err
:=
readBody
(
req
.
Request
)
patchJS
,
err
:=
readBody
(
req
.
Request
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -432,7 +432,7 @@ func PatchResource(r rest.Patcher, scope RequestScope, typer runtime.ObjectTyper
...
@@ -432,7 +432,7 @@ func PatchResource(r rest.Patcher, scope RequestScope, typer runtime.ObjectTyper
}
}
// patchResource divides PatchResource for easier unit testing
// patchResource divides PatchResource for easier unit testing
func
patchResource
(
ctx
api
.
Context
,
timeout
time
.
Duration
,
versionedObj
runtime
.
Object
,
patcher
rest
.
Patcher
,
name
string
,
patchType
api
.
PatchType
,
patchJS
[]
byte
,
namer
ScopeNamer
,
codec
runtime
.
Codec
)
(
runtime
.
Object
,
error
)
{
func
patchResource
(
ctx
api
.
Context
,
timeout
time
.
Duration
,
versionedObj
runtime
.
Object
,
patcher
rest
.
Patcher
,
name
string
,
patchType
unversioned
.
PatchType
,
patchJS
[]
byte
,
namer
ScopeNamer
,
codec
runtime
.
Codec
)
(
runtime
.
Object
,
error
)
{
namespace
:=
api
.
NamespaceValue
(
ctx
)
namespace
:=
api
.
NamespaceValue
(
ctx
)
original
,
err
:=
patcher
.
Get
(
ctx
,
name
)
original
,
err
:=
patcher
.
Get
(
ctx
,
name
)
...
@@ -806,7 +806,7 @@ func setListSelfLink(obj runtime.Object, req *restful.Request, namer ScopeNamer)
...
@@ -806,7 +806,7 @@ func setListSelfLink(obj runtime.Object, req *restful.Request, namer ScopeNamer)
}
}
func
getPatchedJS
(
patchType
api
.
PatchType
,
originalJS
,
patchJS
[]
byte
,
obj
runtime
.
Object
)
([]
byte
,
error
)
{
func
getPatchedJS
(
patchType
unversioned
.
PatchType
,
originalJS
,
patchJS
[]
byte
,
obj
runtime
.
Object
)
([]
byte
,
error
)
{
switch
patchType
{
switch
patchType
{
case
api
.
JSONPatchType
:
case
api
.
JSONPatchType
:
patchObj
,
err
:=
jsonpatch
.
DecodePatch
(
patchJS
)
patchObj
,
err
:=
jsonpatch
.
DecodePatch
(
patchJS
)
...
...
pkg/apiserver/resthandler_test.go
View file @
654ceb6e
...
@@ -169,7 +169,7 @@ func (tc *patchTestCase) Run(t *testing.T) {
...
@@ -169,7 +169,7 @@ func (tc *patchTestCase) Run(t *testing.T) {
return
return
}
}
for
_
,
patchType
:=
range
[]
api
.
PatchType
{
api
.
JSONPatchType
,
api
.
MergePatchType
,
api
.
StrategicMergePatchType
}
{
for
_
,
patchType
:=
range
[]
unversioned
.
PatchType
{
api
.
JSONPatchType
,
api
.
MergePatchType
,
api
.
StrategicMergePatchType
}
{
// TODO SUPPORT THIS!
// TODO SUPPORT THIS!
if
patchType
==
api
.
JSONPatchType
{
if
patchType
==
api
.
JSONPatchType
{
continue
continue
...
...
pkg/client/unversioned/fake/fake.go
View file @
654ceb6e
...
@@ -51,7 +51,7 @@ func (c *RESTClient) Put() *unversioned.Request {
...
@@ -51,7 +51,7 @@ func (c *RESTClient) Put() *unversioned.Request {
return
unversioned
.
NewRequest
(
c
,
"PUT"
,
&
url
.
URL
{
Host
:
"localhost"
},
testapi
.
Default
.
Version
(),
c
.
Codec
)
return
unversioned
.
NewRequest
(
c
,
"PUT"
,
&
url
.
URL
{
Host
:
"localhost"
},
testapi
.
Default
.
Version
(),
c
.
Codec
)
}
}
func
(
c
*
RESTClient
)
Patch
(
_
api
.
PatchType
)
*
unversioned
.
Request
{
func
(
c
*
RESTClient
)
Patch
(
_
unversioned
.
PatchType
)
*
unversioned
.
Request
{
return
unversioned
.
NewRequest
(
c
,
"PATCH"
,
&
url
.
URL
{
Host
:
"localhost"
},
testapi
.
Default
.
Version
(),
c
.
Codec
)
return
unversioned
.
NewRequest
(
c
,
"PATCH"
,
&
url
.
URL
{
Host
:
"localhost"
},
testapi
.
Default
.
Version
(),
c
.
Codec
)
}
}
...
...
pkg/client/unversioned/restclient.go
View file @
654ceb6e
...
@@ -105,7 +105,7 @@ func (c *RESTClient) Put() *Request {
...
@@ -105,7 +105,7 @@ func (c *RESTClient) Put() *Request {
}
}
// Patch begins a PATCH request. Short for c.Verb("Patch").
// Patch begins a PATCH request. Short for c.Verb("Patch").
func
(
c
*
RESTClient
)
Patch
(
pt
api
.
PatchType
)
*
Request
{
func
(
c
*
RESTClient
)
Patch
(
pt
unversioned
.
PatchType
)
*
Request
{
return
c
.
Verb
(
"PATCH"
)
.
SetHeader
(
"Content-Type"
,
string
(
pt
))
return
c
.
Verb
(
"PATCH"
)
.
SetHeader
(
"Content-Type"
,
string
(
pt
))
}
}
...
...
pkg/kubectl/interfaces.go
View file @
654ceb6e
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
type
RESTClient
interface
{
type
RESTClient
interface
{
Get
()
*
client
.
Request
Get
()
*
client
.
Request
Post
()
*
client
.
Request
Post
()
*
client
.
Request
Patch
(
api
.
PatchType
)
*
client
.
Request
Patch
(
unversioned
.
PatchType
)
*
client
.
Request
Delete
()
*
client
.
Request
Delete
()
*
client
.
Request
Put
()
*
client
.
Request
Put
()
*
client
.
Request
}
}
pkg/kubectl/resource/helper.go
View file @
654ceb6e
...
@@ -131,7 +131,7 @@ func (m *Helper) Create(namespace string, modify bool, data []byte) (runtime.Obj
...
@@ -131,7 +131,7 @@ func (m *Helper) Create(namespace string, modify bool, data []byte) (runtime.Obj
func
(
m
*
Helper
)
createResource
(
c
RESTClient
,
resource
,
namespace
string
,
data
[]
byte
)
(
runtime
.
Object
,
error
)
{
func
(
m
*
Helper
)
createResource
(
c
RESTClient
,
resource
,
namespace
string
,
data
[]
byte
)
(
runtime
.
Object
,
error
)
{
return
c
.
Post
()
.
NamespaceIfScoped
(
namespace
,
m
.
NamespaceScoped
)
.
Resource
(
resource
)
.
Body
(
data
)
.
Do
()
.
Get
()
return
c
.
Post
()
.
NamespaceIfScoped
(
namespace
,
m
.
NamespaceScoped
)
.
Resource
(
resource
)
.
Body
(
data
)
.
Do
()
.
Get
()
}
}
func
(
m
*
Helper
)
Patch
(
namespace
,
name
string
,
pt
api
.
PatchType
,
data
[]
byte
)
(
runtime
.
Object
,
error
)
{
func
(
m
*
Helper
)
Patch
(
namespace
,
name
string
,
pt
unversioned
.
PatchType
,
data
[]
byte
)
(
runtime
.
Object
,
error
)
{
return
m
.
RESTClient
.
Patch
(
pt
)
.
return
m
.
RESTClient
.
Patch
(
pt
)
.
NamespaceIfScoped
(
namespace
,
m
.
NamespaceScoped
)
.
NamespaceIfScoped
(
namespace
,
m
.
NamespaceScoped
)
.
Resource
(
m
.
Resource
)
.
Resource
(
m
.
Resource
)
.
...
...
pkg/kubectl/resource/interfaces.go
View file @
654ceb6e
...
@@ -27,7 +27,7 @@ import (
...
@@ -27,7 +27,7 @@ import (
type
RESTClient
interface
{
type
RESTClient
interface
{
Get
()
*
client
.
Request
Get
()
*
client
.
Request
Post
()
*
client
.
Request
Post
()
*
client
.
Request
Patch
(
api
.
PatchType
)
*
client
.
Request
Patch
(
unversioned
.
PatchType
)
*
client
.
Request
Delete
()
*
client
.
Request
Delete
()
*
client
.
Request
Put
()
*
client
.
Request
Put
()
*
client
.
Request
}
}
...
...
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