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
3654d637
Unverified
Commit
3654d637
authored
Dec 08, 2016
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compute apply patch using versioned object
parent
fcf5bbcc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
13 deletions
+8
-13
apply.go
pkg/kubectl/apply.go
+2
-4
apply.go
pkg/kubectl/cmd/apply.go
+4
-7
visitor.go
pkg/kubectl/resource/visitor.go
+2
-2
No files found.
pkg/kubectl/apply.go
View file @
3654d637
...
@@ -17,8 +17,6 @@ limitations under the License.
...
@@ -17,8 +17,6 @@ limitations under the License.
package
kubectl
package
kubectl
import
(
import
(
"encoding/json"
"k8s.io/kubernetes/pkg/api/annotations"
"k8s.io/kubernetes/pkg/api/annotations"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/kubectl/resource"
...
@@ -96,7 +94,7 @@ func GetModifiedConfiguration(info *resource.Info, annotate bool, codec runtime.
...
@@ -96,7 +94,7 @@ func GetModifiedConfiguration(info *resource.Info, annotate bool, codec runtime.
accessor
.
SetAnnotations
(
annots
)
accessor
.
SetAnnotations
(
annots
)
// TODO: this needs to be abstracted - there should be no assumption that versioned object
// TODO: this needs to be abstracted - there should be no assumption that versioned object
// can be marshalled to JSON.
// can be marshalled to JSON.
modified
,
err
=
json
.
Marshal
(
info
.
VersionedObject
)
modified
,
err
=
runtime
.
Encode
(
codec
,
info
.
VersionedObject
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -106,7 +104,7 @@ func GetModifiedConfiguration(info *resource.Info, annotate bool, codec runtime.
...
@@ -106,7 +104,7 @@ func GetModifiedConfiguration(info *resource.Info, annotate bool, codec runtime.
accessor
.
SetAnnotations
(
annots
)
accessor
.
SetAnnotations
(
annots
)
// TODO: this needs to be abstracted - there should be no assumption that versioned object
// TODO: this needs to be abstracted - there should be no assumption that versioned object
// can be marshalled to JSON.
// can be marshalled to JSON.
modified
,
err
=
json
.
Marshal
(
info
.
VersionedObject
)
modified
,
err
=
runtime
.
Encode
(
codec
,
info
.
VersionedObject
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/kubectl/cmd/apply.go
View file @
3654d637
...
@@ -527,14 +527,11 @@ func (p *patcher) patchSimple(obj runtime.Object, modified []byte, source, names
...
@@ -527,14 +527,11 @@ func (p *patcher) patchSimple(obj runtime.Object, modified []byte, source, names
return
nil
,
cmdutil
.
AddSourceToErr
(
fmt
.
Sprintf
(
"retrieving original configuration from:
\n
%v
\n
for:"
,
obj
),
source
,
err
)
return
nil
,
cmdutil
.
AddSourceToErr
(
fmt
.
Sprintf
(
"retrieving original configuration from:
\n
%v
\n
for:"
,
obj
),
source
,
err
)
}
}
// Create the versioned struct from the original from the server for
// Create the versioned struct from the type defined in the restmapping
// strategic patch.
// (which is the API version we'll be submitting the patch to)
// TODO: Move all structs in apply to use raw data. Can be done once
versionedObject
,
err
:=
api
.
Scheme
.
New
(
p
.
mapping
.
GroupVersionKind
)
// builder has a RawResult method which delivers raw data instead of
// internal objects.
versionedObject
,
_
,
err
:=
p
.
decoder
.
Decode
(
current
,
nil
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
cmdutil
.
AddSourceToErr
(
fmt
.
Sprintf
(
"
converting encoded server-side object back to versioned struct:
\n
%v
\n
for:"
,
obj
),
source
,
err
)
return
nil
,
cmdutil
.
AddSourceToErr
(
fmt
.
Sprintf
(
"
getting instance of versioned object for %v:"
,
p
.
mapping
.
GroupVersionKind
),
source
,
err
)
}
}
// Compute a three way strategic merge patch to send to server.
// Compute a three way strategic merge patch to send to server.
...
...
pkg/kubectl/resource/visitor.go
View file @
3654d637
...
@@ -81,9 +81,9 @@ type Info struct {
...
@@ -81,9 +81,9 @@ type Info struct {
// Optional, this is the provided object in a versioned type before defaulting
// Optional, this is the provided object in a versioned type before defaulting
// and conversions into its corresponding internal type. This is useful for
// and conversions into its corresponding internal type. This is useful for
// reflecting on user intent which may be lost after defaulting and conversions.
// reflecting on user intent which may be lost after defaulting and conversions.
VersionedObject
interface
{}
VersionedObject
runtime
.
Object
// Optional, this is the most recent value returned by the server if available
// Optional, this is the most recent value returned by the server if available
runtime
.
Object
Object
runtime
.
Object
// Optional, this is the most recent resource version the server knows about for
// Optional, this is the most recent resource version the server knows about for
// this type of resource. It may not match the resource version of the object,
// this type of resource. It may not match the resource version of the object,
// but if set it should be equal to or newer than the resource version of the
// but if set it should be equal to or newer than the resource version of the
...
...
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