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
88e17d74
Commit
88e17d74
authored
Aug 31, 2016
by
Michael Fraenkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require force when using grace period or timeout
parent
d877967c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
test-cmd.sh
hack/make-rules/test-cmd.sh
+9
-0
replace.go
pkg/kubectl/cmd/replace.go
+8
-0
No files found.
hack/make-rules/test-cmd.sh
View file @
88e17d74
...
@@ -750,6 +750,15 @@ runTests() {
...
@@ -750,6 +750,15 @@ runTests() {
kubectl replace
"
${
kube_flags
[@]
}
"
--force
-f
/tmp/tmp-valid-pod.json
kubectl replace
"
${
kube_flags
[@]
}
"
--force
-f
/tmp/tmp-valid-pod.json
# Post-condition: spec.container.name = "replaced-k8s-serve-hostname"
# Post-condition: spec.container.name = "replaced-k8s-serve-hostname"
kube::test::get_object_assert
'pod valid-pod'
"{{(index .spec.containers 0).name}}"
'replaced-k8s-serve-hostname'
kube::test::get_object_assert
'pod valid-pod'
"{{(index .spec.containers 0).name}}"
'replaced-k8s-serve-hostname'
## check replace --grace-period requires --force
output_message
=
$(
!
kubectl replace
"
${
kube_flags
[@]
}
"
--grace-period
=
1
-f
/tmp/tmp-valid-pod.json 2>&1
)
kube::test::if_has_string
"
${
output_message
}
"
'\-\-grace-period must have \-\-force specified'
## check replace --timeout requires --force
output_message
=
$(
!
kubectl replace
"
${
kube_flags
[@]
}
"
--timeout
=
1s
-f
/tmp/tmp-valid-pod.json 2>&1
)
kube::test::if_has_string
"
${
output_message
}
"
'\-\-timeout must have \-\-force specified'
#cleaning
#cleaning
rm
/tmp/tmp-valid-pod.json
rm
/tmp/tmp-valid-pod.json
...
...
pkg/kubectl/cmd/replace.go
View file @
88e17d74
...
@@ -120,6 +120,14 @@ func RunReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
...
@@ -120,6 +120,14 @@ func RunReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
return
forceReplace
(
f
,
out
,
cmd
,
args
,
shortOutput
,
options
)
return
forceReplace
(
f
,
out
,
cmd
,
args
,
shortOutput
,
options
)
}
}
if
cmdutil
.
GetFlagInt
(
cmd
,
"grace-period"
)
>=
0
{
return
fmt
.
Errorf
(
"--grace-period must have --force specified"
)
}
if
cmdutil
.
GetFlagDuration
(
cmd
,
"timeout"
)
!=
0
{
return
fmt
.
Errorf
(
"--timeout must have --force specified"
)
}
mapper
,
typer
:=
f
.
Object
(
cmdutil
.
GetIncludeThirdPartyAPIs
(
cmd
))
mapper
,
typer
:=
f
.
Object
(
cmdutil
.
GetIncludeThirdPartyAPIs
(
cmd
))
r
:=
resource
.
NewBuilder
(
mapper
,
typer
,
resource
.
ClientMapperFunc
(
f
.
ClientForMapping
),
f
.
Decoder
(
true
))
.
r
:=
resource
.
NewBuilder
(
mapper
,
typer
,
resource
.
ClientMapperFunc
(
f
.
ClientForMapping
),
f
.
Decoder
(
true
))
.
Schema
(
schema
)
.
Schema
(
schema
)
.
...
...
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