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
57e35b79
Commit
57e35b79
authored
Sep 04, 2015
by
Piotr Szczesniak
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13445 from hurf/ru_out
Make -o option working for rolling-update
parents
30d7f0e1
65bfd354
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
rollingupdate.go
pkg/kubectl/cmd/rollingupdate.go
+28
-7
No files found.
pkg/kubectl/cmd/rollingupdate.go
View file @
57e35b79
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/kubectl"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
...
@@ -138,6 +139,7 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
...
@@ -138,6 +139,7 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
interval
:=
cmdutil
.
GetFlagDuration
(
cmd
,
"poll-interval"
)
interval
:=
cmdutil
.
GetFlagDuration
(
cmd
,
"poll-interval"
)
timeout
:=
cmdutil
.
GetFlagDuration
(
cmd
,
"timeout"
)
timeout
:=
cmdutil
.
GetFlagDuration
(
cmd
,
"timeout"
)
dryrun
:=
cmdutil
.
GetFlagBool
(
cmd
,
"dry-run"
)
dryrun
:=
cmdutil
.
GetFlagBool
(
cmd
,
"dry-run"
)
outputFormat
:=
cmdutil
.
GetFlagString
(
cmd
,
"output"
)
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
DefaultNamespace
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -263,12 +265,17 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
...
@@ -263,12 +265,17 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
}
}
if
dryrun
{
if
dryrun
{
oldRcData
:=
&
bytes
.
Buffer
{}
oldRcData
:=
&
bytes
.
Buffer
{}
if
err
:=
f
.
PrintObject
(
cmd
,
oldRc
,
oldRcData
);
err
!=
nil
{
return
err
}
newRcData
:=
&
bytes
.
Buffer
{}
newRcData
:=
&
bytes
.
Buffer
{}
if
err
:=
f
.
PrintObject
(
cmd
,
newRc
,
newRcData
);
err
!=
nil
{
if
outputFormat
==
""
{
return
err
oldRcData
.
WriteString
(
oldRc
.
Name
)
newRcData
.
WriteString
(
newRc
.
Name
)
}
else
{
if
err
:=
f
.
PrintObject
(
cmd
,
oldRc
,
oldRcData
);
err
!=
nil
{
return
err
}
if
err
:=
f
.
PrintObject
(
cmd
,
newRc
,
newRcData
);
err
!=
nil
{
return
err
}
}
}
fmt
.
Fprintf
(
out
,
"Rolling from:
\n
%s
\n
To:
\n
%s
\n
"
,
string
(
oldRcData
.
Bytes
()),
string
(
newRcData
.
Bytes
()))
fmt
.
Fprintf
(
out
,
"Rolling from:
\n
%s
\n
To:
\n
%s
\n
"
,
string
(
oldRcData
.
Bytes
()),
string
(
newRcData
.
Bytes
()))
return
nil
return
nil
...
@@ -297,11 +304,25 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
...
@@ -297,11 +304,25 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
return
err
return
err
}
}
message
:=
"rolling updated"
if
keepOldName
{
if
keepOldName
{
fmt
.
Fprintf
(
out
,
"%s
\n
"
,
oldName
)
newRc
.
Name
=
oldName
}
else
{
}
else
{
fmt
.
Fprintf
(
out
,
"%s
\n
"
,
newRc
.
Name
)
message
=
fmt
.
Sprintf
(
"rolling updated to %q"
,
newRc
.
Name
)
}
newRc
,
err
=
client
.
ReplicationControllers
(
cmdNamespace
)
.
Get
(
newRc
.
Name
)
if
err
!=
nil
{
return
err
}
if
outputFormat
!=
""
{
return
f
.
PrintObject
(
cmd
,
newRc
,
out
)
}
_
,
kind
,
err
:=
api
.
Scheme
.
ObjectVersionAndKind
(
newRc
)
if
err
!=
nil
{
return
err
}
}
_
,
res
:=
meta
.
KindToResource
(
kind
,
false
)
cmdutil
.
PrintSuccess
(
mapper
,
false
,
out
,
res
,
oldName
,
message
)
return
nil
return
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