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
97d7e7e2
Commit
97d7e7e2
authored
Mar 02, 2015
by
Brian Grant
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4819 from mikedanese/validate-api-version
Validate api version in kubectl --patch and --override
parents
00ca7352
25fac68e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
helpers.go
pkg/kubectl/cmd/util/helpers.go
+7
-4
helpers_test.go
pkg/kubectl/cmd/util/helpers_test.go
+6
-0
No files found.
pkg/kubectl/cmd/util/helpers.go
View file @
97d7e7e2
...
...
@@ -26,7 +26,7 @@ import (
"strings"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api
/latest
"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/evanphx/json-patch"
...
...
@@ -161,10 +161,13 @@ func Merge(dst runtime.Object, fragment, kind string) (runtime.Object, error) {
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"apiVersion must be a string"
)
}
i
,
err
:=
latest
.
InterfacesFor
(
versionString
)
if
err
!=
nil
{
return
nil
,
err
}
codec
:=
runtime
.
CodecFor
(
api
.
Scheme
,
versionString
)
// encode dst into versioned json and apply fragment directly too it
target
,
err
:=
c
odec
.
Encode
(
dst
)
target
,
err
:=
i
.
C
odec
.
Encode
(
dst
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -172,7 +175,7 @@ func Merge(dst runtime.Object, fragment, kind string) (runtime.Object, error) {
if
err
!=
nil
{
return
nil
,
err
}
out
,
err
:=
c
odec
.
Decode
(
patched
)
out
,
err
:=
i
.
C
odec
.
Decode
(
patched
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/kubectl/cmd/util/helpers_test.go
View file @
97d7e7e2
...
...
@@ -131,6 +131,12 @@ func TestMerge(t *testing.T) {
},
},
{
kind
:
"Service"
,
obj
:
&
api
.
Service
{},
fragment
:
`{ "apiVersion": "badVersion" }`
,
expectErr
:
true
,
},
{
kind
:
"Service"
,
obj
:
&
api
.
Service
{
Spec
:
api
.
ServiceSpec
{
...
...
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