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
48086eb7
Unverified
Commit
48086eb7
authored
Oct 09, 2018
by
k8s-ci-robot
Committed by
GitHub
Oct 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69543 from seans3/rollback-fix
kubectl rollback: remove duplicated code for printing pod template
parents
637ba154
20a54b31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
28 deletions
+8
-28
rollback.go
pkg/kubectl/rollback.go
+8
-28
No files found.
pkg/kubectl/rollback.go
View file @
48086eb7
...
...
@@ -36,12 +36,10 @@ import (
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes"
api
"k8s.io/kubernetes/pkg/apis/core"
apiv1
"k8s.io/kubernetes/pkg/apis/core/v1"
kapps
"k8s.io/kubernetes/pkg/kubectl/apps"
"k8s.io/kubernetes/pkg/kubectl/scheme"
sliceutil
"k8s.io/kubernetes/pkg/kubectl/util/slice"
printersinternal
"k8s.io/kubernetes/pkg/printers/internalversion"
// kubectl should not be taking dependencies on logic in the controllers
deploymentutil
"k8s.io/kubernetes/pkg/controller/deployment/util"
)
...
...
@@ -229,14 +227,7 @@ func simpleDryRun(deployment *appsv1.Deployment, c kubernetes.Interface, toRevis
if
!
ok
{
return
""
,
revisionNotFoundErr
(
toRevision
)
}
buf
:=
bytes
.
NewBuffer
([]
byte
{})
internalTemplate
:=
&
api
.
PodTemplateSpec
{}
if
err
:=
apiv1
.
Convert_v1_PodTemplateSpec_To_core_PodTemplateSpec
(
template
,
internalTemplate
,
nil
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to convert podtemplate, %v"
,
err
)
}
w
:=
printersinternal
.
NewPrefixWriter
(
buf
)
printersinternal
.
DescribePodTemplate
(
internalTemplate
,
w
)
return
buf
.
String
(),
nil
return
printTemplate
(
template
)
}
// Sort the revisionToSpec map by revision
...
...
@@ -247,15 +238,7 @@ func simpleDryRun(deployment *appsv1.Deployment, c kubernetes.Interface, toRevis
sliceutil
.
SortInts64
(
revisions
)
template
,
_
:=
revisionToSpec
[
revisions
[
len
(
revisions
)
-
2
]]
buf
:=
bytes
.
NewBuffer
([]
byte
{})
buf
.
WriteString
(
"
\n
"
)
internalTemplate
:=
&
api
.
PodTemplateSpec
{}
if
err
:=
apiv1
.
Convert_v1_PodTemplateSpec_To_core_PodTemplateSpec
(
template
,
internalTemplate
,
nil
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to convert podtemplate, %v"
,
err
)
}
w
:=
printersinternal
.
NewPrefixWriter
(
buf
)
printersinternal
.
DescribePodTemplate
(
internalTemplate
,
w
)
return
buf
.
String
(),
nil
return
printTemplate
(
template
)
}
type
DaemonSetRollbacker
struct
{
...
...
@@ -473,14 +456,11 @@ func findHistory(toRevision int64, allHistory []*appsv1.ControllerRevision) *app
// printPodTemplate converts a given pod template into a human-readable string.
func
printPodTemplate
(
specTemplate
*
corev1
.
PodTemplateSpec
)
(
string
,
error
)
{
content
:=
bytes
.
NewBuffer
([]
byte
{})
w
:=
printersinternal
.
NewPrefixWriter
(
content
)
internalTemplate
:=
&
api
.
PodTemplateSpec
{}
if
err
:=
apiv1
.
Convert_v1_PodTemplateSpec_To_core_PodTemplateSpec
(
specTemplate
,
internalTemplate
,
nil
);
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to convert podtemplate while printing: %v"
,
err
)
}
printersinternal
.
DescribePodTemplate
(
internalTemplate
,
w
)
return
fmt
.
Sprintf
(
"will roll back to %s"
,
content
.
String
()),
nil
podSpec
,
err
:=
printTemplate
(
specTemplate
)
if
err
!=
nil
{
return
""
,
err
}
return
fmt
.
Sprintf
(
"will roll back to %s"
,
podSpec
),
nil
}
func
revisionNotFoundErr
(
r
int64
)
error
{
...
...
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