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
34860daf
Unverified
Commit
34860daf
authored
Sep 27, 2018
by
k8s-ci-robot
Committed by
GitHub
Sep 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69150 from soltysh/issue69144
Fix panic in kubectl rollout commands
parents
58102b75
96d01da2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
54 deletions
+45
-54
rollout_history.go
pkg/kubectl/cmd/rollout/rollout_history.go
+2
-1
rollout_pause.go
pkg/kubectl/cmd/rollout/rollout_pause.go
+17
-20
rollout_resume.go
pkg/kubectl/cmd/rollout/rollout_resume.go
+10
-14
rollout_status.go
pkg/kubectl/cmd/rollout/rollout_status.go
+4
-4
rollout_undo.go
pkg/kubectl/cmd/rollout/rollout_undo.go
+12
-15
No files found.
pkg/kubectl/cmd/rollout/rollout_history.go
View file @
34860daf
...
@@ -81,6 +81,7 @@ func NewCmdRolloutHistory(f cmdutil.Factory, streams genericclioptions.IOStreams
...
@@ -81,6 +81,7 @@ func NewCmdRolloutHistory(f cmdutil.Factory, streams genericclioptions.IOStreams
Example
:
history_example
,
Example
:
history_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
o
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
o
.
Complete
(
f
,
cmd
,
args
))
cmdutil
.
CheckErr
(
o
.
Validate
())
cmdutil
.
CheckErr
(
o
.
Run
())
cmdutil
.
CheckErr
(
o
.
Run
())
},
},
ValidArgs
:
validArgs
,
ValidArgs
:
validArgs
,
...
@@ -118,7 +119,7 @@ func (o *RolloutHistoryOptions) Complete(f cmdutil.Factory, cmd *cobra.Command,
...
@@ -118,7 +119,7 @@ func (o *RolloutHistoryOptions) Complete(f cmdutil.Factory, cmd *cobra.Command,
func
(
o
*
RolloutHistoryOptions
)
Validate
()
error
{
func
(
o
*
RolloutHistoryOptions
)
Validate
()
error
{
if
len
(
o
.
Resources
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
Filenames
)
{
if
len
(
o
.
Resources
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
Filenames
)
{
return
fmt
.
Errorf
(
"
Required resource not specified.
"
)
return
fmt
.
Errorf
(
"
required resource not specified
"
)
}
}
if
o
.
Revision
<
0
{
if
o
.
Revision
<
0
{
return
fmt
.
Errorf
(
"revision must be a positive integer: %v"
,
o
.
Revision
)
return
fmt
.
Errorf
(
"revision must be a positive integer: %v"
,
o
.
Revision
)
...
...
pkg/kubectl/cmd/rollout/rollout_pause.go
View file @
34860daf
...
@@ -34,9 +34,9 @@ import (
...
@@ -34,9 +34,9 @@ import (
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
)
)
// Pause
Config
is the start of the data required to perform the operation. As new fields are added, add them here instead of
// Pause
Options
is the start of the data required to perform the operation. As new fields are added, add them here instead of
// referencing the cmd.Flags()
// referencing the cmd.Flags()
type
Pause
Config
struct
{
type
Pause
Options
struct
{
PrintFlags
*
genericclioptions
.
PrintFlags
PrintFlags
*
genericclioptions
.
PrintFlags
ToPrinter
func
(
string
)
(
printers
.
ResourcePrinter
,
error
)
ToPrinter
func
(
string
)
(
printers
.
ResourcePrinter
,
error
)
...
@@ -66,7 +66,7 @@ var (
...
@@ -66,7 +66,7 @@ var (
)
)
func
NewCmdRolloutPause
(
f
cmdutil
.
Factory
,
streams
genericclioptions
.
IOStreams
)
*
cobra
.
Command
{
func
NewCmdRolloutPause
(
f
cmdutil
.
Factory
,
streams
genericclioptions
.
IOStreams
)
*
cobra
.
Command
{
o
:=
&
Pause
Config
{
o
:=
&
Pause
Options
{
PrintFlags
:
genericclioptions
.
NewPrintFlags
(
"paused"
)
.
WithTypeSetter
(
scheme
.
Scheme
),
PrintFlags
:
genericclioptions
.
NewPrintFlags
(
"paused"
)
.
WithTypeSetter
(
scheme
.
Scheme
),
IOStreams
:
streams
,
IOStreams
:
streams
,
}
}
...
@@ -80,16 +80,9 @@ func NewCmdRolloutPause(f cmdutil.Factory, streams genericclioptions.IOStreams)
...
@@ -80,16 +80,9 @@ func NewCmdRolloutPause(f cmdutil.Factory, streams genericclioptions.IOStreams)
Long
:
pause_long
,
Long
:
pause_long
,
Example
:
pause_example
,
Example
:
pause_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
allErrs
:=
[]
error
{}
cmdutil
.
CheckErr
(
o
.
Complete
(
f
,
cmd
,
args
))
err
:=
o
.
Complete
(
f
,
cmd
,
args
)
cmdutil
.
CheckErr
(
o
.
Validate
())
if
err
!=
nil
{
cmdutil
.
CheckErr
(
o
.
RunPause
())
allErrs
=
append
(
allErrs
,
err
)
}
err
=
o
.
RunPause
()
if
err
!=
nil
{
allErrs
=
append
(
allErrs
,
err
)
}
cmdutil
.
CheckErr
(
utilerrors
.
Flatten
(
utilerrors
.
NewAggregate
(
allErrs
)))
},
},
ValidArgs
:
validArgs
,
ValidArgs
:
validArgs
,
}
}
...
@@ -101,15 +94,12 @@ func NewCmdRolloutPause(f cmdutil.Factory, streams genericclioptions.IOStreams)
...
@@ -101,15 +94,12 @@ func NewCmdRolloutPause(f cmdutil.Factory, streams genericclioptions.IOStreams)
return
cmd
return
cmd
}
}
func
(
o
*
PauseConfig
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
PauseOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
Filenames
)
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s"
,
cmd
.
Use
)
}
o
.
Pauser
=
polymorphichelpers
.
ObjectPauserFn
o
.
Pauser
=
polymorphichelpers
.
ObjectPauserFn
var
err
error
var
err
error
if
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
();
err
!=
nil
{
o
.
Namespace
,
o
.
EnforceNamespace
,
err
=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -124,7 +114,14 @@ func (o *PauseConfig) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str
...
@@ -124,7 +114,14 @@ func (o *PauseConfig) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str
return
nil
return
nil
}
}
func
(
o
PauseConfig
)
RunPause
()
error
{
func
(
o
*
PauseOptions
)
Validate
()
error
{
if
len
(
o
.
Resources
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
Filenames
)
{
return
fmt
.
Errorf
(
"required resource not specified"
)
}
return
nil
}
func
(
o
PauseOptions
)
RunPause
()
error
{
r
:=
o
.
Builder
()
.
r
:=
o
.
Builder
()
.
WithScheme
(
scheme
.
Scheme
,
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
.
WithScheme
(
scheme
.
Scheme
,
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
.
NamespaceParam
(
o
.
Namespace
)
.
DefaultNamespace
()
.
NamespaceParam
(
o
.
Namespace
)
.
DefaultNamespace
()
.
...
...
pkg/kubectl/cmd/rollout/rollout_resume.go
View file @
34860daf
...
@@ -83,16 +83,9 @@ func NewCmdRolloutResume(f cmdutil.Factory, streams genericclioptions.IOStreams)
...
@@ -83,16 +83,9 @@ func NewCmdRolloutResume(f cmdutil.Factory, streams genericclioptions.IOStreams)
Long
:
resume_long
,
Long
:
resume_long
,
Example
:
resume_example
,
Example
:
resume_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
allErrs
:=
[]
error
{}
cmdutil
.
CheckErr
(
o
.
Complete
(
f
,
cmd
,
args
))
err
:=
o
.
Complete
(
f
,
cmd
,
args
)
cmdutil
.
CheckErr
(
o
.
Validate
())
if
err
!=
nil
{
cmdutil
.
CheckErr
(
o
.
RunResume
())
allErrs
=
append
(
allErrs
,
err
)
}
err
=
o
.
RunResume
()
if
err
!=
nil
{
allErrs
=
append
(
allErrs
,
err
)
}
cmdutil
.
CheckErr
(
utilerrors
.
Flatten
(
utilerrors
.
NewAggregate
(
allErrs
)))
},
},
ValidArgs
:
validArgs
,
ValidArgs
:
validArgs
,
}
}
...
@@ -104,10 +97,6 @@ func NewCmdRolloutResume(f cmdutil.Factory, streams genericclioptions.IOStreams)
...
@@ -104,10 +97,6 @@ func NewCmdRolloutResume(f cmdutil.Factory, streams genericclioptions.IOStreams)
}
}
func
(
o
*
ResumeOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
ResumeOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
Filenames
)
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s"
,
cmd
.
Use
)
}
o
.
Resources
=
args
o
.
Resources
=
args
o
.
Resumer
=
polymorphichelpers
.
ObjectResumerFn
o
.
Resumer
=
polymorphichelpers
.
ObjectResumerFn
...
@@ -128,6 +117,13 @@ func (o *ResumeOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []s
...
@@ -128,6 +117,13 @@ func (o *ResumeOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []s
return
nil
return
nil
}
}
func
(
o
*
ResumeOptions
)
Validate
()
error
{
if
len
(
o
.
Resources
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
Filenames
)
{
return
fmt
.
Errorf
(
"required resource not specified"
)
}
return
nil
}
func
(
o
ResumeOptions
)
RunResume
()
error
{
func
(
o
ResumeOptions
)
RunResume
()
error
{
r
:=
o
.
Builder
()
.
r
:=
o
.
Builder
()
.
WithScheme
(
scheme
.
Scheme
,
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
.
WithScheme
(
scheme
.
Scheme
,
scheme
.
Scheme
.
PrioritizedVersionsAllGroups
()
...
)
.
...
...
pkg/kubectl/cmd/rollout/rollout_status.go
View file @
34860daf
...
@@ -102,7 +102,7 @@ func NewCmdRolloutStatus(f cmdutil.Factory, streams genericclioptions.IOStreams)
...
@@ -102,7 +102,7 @@ func NewCmdRolloutStatus(f cmdutil.Factory, streams genericclioptions.IOStreams)
Example
:
status_example
,
Example
:
status_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
cmdutil
.
CheckErr
(
o
.
Complete
(
f
,
args
))
cmdutil
.
CheckErr
(
o
.
Complete
(
f
,
args
))
cmdutil
.
CheckErr
(
o
.
Validate
(
cmd
,
args
))
cmdutil
.
CheckErr
(
o
.
Validate
())
cmdutil
.
CheckErr
(
o
.
Run
())
cmdutil
.
CheckErr
(
o
.
Run
())
},
},
ValidArgs
:
validArgs
,
ValidArgs
:
validArgs
,
...
@@ -142,9 +142,9 @@ func (o *RolloutStatusOptions) Complete(f cmdutil.Factory, args []string) error
...
@@ -142,9 +142,9 @@ func (o *RolloutStatusOptions) Complete(f cmdutil.Factory, args []string) error
return
nil
return
nil
}
}
func
(
o
*
RolloutStatusOptions
)
Validate
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
RolloutStatusOptions
)
Validate
()
error
{
if
len
(
a
rgs
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
FilenameOptions
.
Filenames
)
{
if
len
(
o
.
BuilderA
rgs
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
FilenameOptions
.
Filenames
)
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"Required resource not specified.
"
)
return
fmt
.
Errorf
(
"required resource not specified
"
)
}
}
if
o
.
Revision
<
0
{
if
o
.
Revision
<
0
{
...
...
pkg/kubectl/cmd/rollout/rollout_undo.go
View file @
34860daf
...
@@ -17,10 +17,11 @@ limitations under the License.
...
@@ -17,10 +17,11 @@ limitations under the License.
package
rollout
package
rollout
import
(
import
(
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/kubectl/polymorphichelpers"
"k8s.io/kubernetes/pkg/kubectl/polymorphichelpers"
utilerrors
"k8s.io/apimachinery/pkg/util/errors"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericclioptions/printers"
"k8s.io/cli-runtime/pkg/genericclioptions/printers"
"k8s.io/cli-runtime/pkg/genericclioptions/resource"
"k8s.io/cli-runtime/pkg/genericclioptions/resource"
...
@@ -84,16 +85,9 @@ func NewCmdRolloutUndo(f cmdutil.Factory, streams genericclioptions.IOStreams) *
...
@@ -84,16 +85,9 @@ func NewCmdRolloutUndo(f cmdutil.Factory, streams genericclioptions.IOStreams) *
Long
:
undo_long
,
Long
:
undo_long
,
Example
:
undo_example
,
Example
:
undo_example
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
allErrs
:=
[]
error
{}
cmdutil
.
CheckErr
(
o
.
Complete
(
f
,
cmd
,
args
))
err
:=
o
.
Complete
(
f
,
cmd
,
args
)
cmdutil
.
CheckErr
(
o
.
Validate
())
if
err
!=
nil
{
cmdutil
.
CheckErr
(
o
.
RunUndo
())
allErrs
=
append
(
allErrs
,
err
)
}
err
=
o
.
RunUndo
()
if
err
!=
nil
{
allErrs
=
append
(
allErrs
,
err
)
}
cmdutil
.
CheckErr
(
utilerrors
.
Flatten
(
utilerrors
.
NewAggregate
(
allErrs
)))
},
},
ValidArgs
:
validArgs
,
ValidArgs
:
validArgs
,
}
}
...
@@ -107,10 +101,6 @@ func NewCmdRolloutUndo(f cmdutil.Factory, streams genericclioptions.IOStreams) *
...
@@ -107,10 +101,6 @@ func NewCmdRolloutUndo(f cmdutil.Factory, streams genericclioptions.IOStreams) *
}
}
func
(
o
*
UndoOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
(
o
*
UndoOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
Filenames
)
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"Required resource not specified."
)
}
o
.
Resources
=
args
o
.
Resources
=
args
o
.
DryRun
=
cmdutil
.
GetDryRunFlag
(
cmd
)
o
.
DryRun
=
cmdutil
.
GetDryRunFlag
(
cmd
)
...
@@ -133,6 +123,13 @@ func (o *UndoOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str
...
@@ -133,6 +123,13 @@ func (o *UndoOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str
return
err
return
err
}
}
func
(
o
*
UndoOptions
)
Validate
()
error
{
if
len
(
o
.
Resources
)
==
0
&&
cmdutil
.
IsFilenameSliceEmpty
(
o
.
Filenames
)
{
return
fmt
.
Errorf
(
"required resource not specified"
)
}
return
nil
}
func
(
o
*
UndoOptions
)
RunUndo
()
error
{
func
(
o
*
UndoOptions
)
RunUndo
()
error
{
r
:=
o
.
Builder
()
.
r
:=
o
.
Builder
()
.
WithScheme
(
legacyscheme
.
Scheme
)
.
WithScheme
(
legacyscheme
.
Scheme
)
.
...
...
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