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
09b64d36
Unverified
Commit
09b64d36
authored
Nov 17, 2017
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rollingupdate should use explicit casting
It needs both internal and versioned - use the new helpers to detect that
parent
8f4b6c87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
34 deletions
+18
-34
rollingupdate.go
pkg/kubectl/cmd/rollingupdate.go
+18
-34
No files found.
pkg/kubectl/cmd/rollingupdate.go
View file @
09b64d36
...
@@ -201,39 +201,35 @@ func RunRollingUpdate(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args
...
@@ -201,39 +201,35 @@ func RunRollingUpdate(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args
}
}
request
:=
f
.
NewBuilder
()
.
request
:=
f
.
NewBuilder
()
.
Internal
()
.
Unstructured
()
.
Schema
(
schema
)
.
Schema
(
schema
)
.
NamespaceParam
(
cmdNamespace
)
.
DefaultNamespace
()
.
NamespaceParam
(
cmdNamespace
)
.
DefaultNamespace
()
.
FilenameParam
(
enforceNamespace
,
&
resource
.
FilenameOptions
{
Recursive
:
false
,
Filenames
:
[]
string
{
filename
}})
.
FilenameParam
(
enforceNamespace
,
&
resource
.
FilenameOptions
{
Recursive
:
false
,
Filenames
:
[]
string
{
filename
}})
.
Flatten
()
.
Do
()
Do
()
obj
,
err
:=
request
.
Object
()
infos
,
err
:=
request
.
Infos
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
var
ok
bool
// Handle filename input from stdin.
// Handle filename input from stdin. The resource builder always returns an api.List
if
len
(
infos
)
>
1
{
// when creating resource(s) from a stream.
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s specifies multiple items"
,
filename
)
if
list
,
ok
:=
obj
.
(
*
v1
.
List
);
ok
{
if
len
(
list
.
Items
)
>
1
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s specifies multiple items"
,
filename
)
}
if
len
(
list
.
Items
)
==
0
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"please make sure %s exists and is not empty"
,
filename
)
}
obj
=
list
.
Items
[
0
]
.
Object
}
}
newRc
,
ok
=
obj
.
(
*
api
.
ReplicationController
)
if
len
(
infos
)
==
0
{
if
!
ok
{
return
cmdutil
.
UsageErrorf
(
cmd
,
"please make sure %s exists and is not empty"
,
filename
)
glog
.
V
(
4
)
.
Infof
(
"Object %T is not a ReplicationController"
,
obj
)
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s contains a %v not a ReplicationController"
,
filename
,
obj
.
GetObjectKind
()
.
GroupVersionKind
())
}
}
infos
,
err
:=
request
.
Infos
()
if
err
!=
nil
||
len
(
infos
)
!=
1
{
switch
t
:=
infos
[
0
]
.
AsVersioned
()
.
(
type
)
{
glog
.
V
(
2
)
.
Infof
(
"was not able to recover adequate information to discover if .spec.replicas was defaulted"
)
case
*
v1
.
ReplicationController
:
}
else
{
replicasDefaulted
=
t
.
Spec
.
Replicas
==
nil
replicasDefaulted
=
isReplicasDefaulted
(
infos
[
0
])
newRc
,
_
=
infos
[
0
]
.
AsInternal
()
.
(
*
api
.
ReplicationController
)
}
if
newRc
==
nil
{
glog
.
V
(
4
)
.
Infof
(
"Object %T is not a ReplicationController"
,
infos
[
0
]
.
Object
)
return
cmdutil
.
UsageErrorf
(
cmd
,
"%s contains a %v not a ReplicationController"
,
filename
,
infos
[
0
]
.
Object
.
GetObjectKind
()
.
GroupVersionKind
())
}
}
}
}
// If the --image option is specified, we need to create a new rc with at least one different selector
// If the --image option is specified, we need to create a new rc with at least one different selector
// than the old rc. This selector is the hash of the rc, with a suffix to provide uniqueness for
// than the old rc. This selector is the hash of the rc, with a suffix to provide uniqueness for
// same-image updates.
// same-image updates.
...
@@ -391,15 +387,3 @@ func findNewName(args []string, oldRc *api.ReplicationController) string {
...
@@ -391,15 +387,3 @@ func findNewName(args []string, oldRc *api.ReplicationController) string {
}
}
return
""
return
""
}
}
func
isReplicasDefaulted
(
info
*
resource
.
Info
)
bool
{
if
info
==
nil
{
// was unable to recover versioned info
return
false
}
switch
t
:=
info
.
AsVersioned
()
.
(
type
)
{
case
*
v1
.
ReplicationController
:
return
t
.
Spec
.
Replicas
==
nil
}
return
false
}
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