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
59fc1200
Unverified
Commit
59fc1200
authored
Aug 22, 2018
by
Maciej Szulik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix NameFromCommandArgs when passing command after --
parent
974978a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
create.go
pkg/kubectl/cmd/create/create.go
+7
-2
apps.sh
test/cmd/apps.sh
+10
-0
No files found.
pkg/kubectl/cmd/create/create.go
View file @
59fc1200
...
@@ -328,8 +328,13 @@ func createAndRefresh(info *resource.Info) error {
...
@@ -328,8 +328,13 @@ func createAndRefresh(info *resource.Info) error {
// NameFromCommandArgs is a utility function for commands that assume the first argument is a resource name
// NameFromCommandArgs is a utility function for commands that assume the first argument is a resource name
func
NameFromCommandArgs
(
cmd
*
cobra
.
Command
,
args
[]
string
)
(
string
,
error
)
{
func
NameFromCommandArgs
(
cmd
*
cobra
.
Command
,
args
[]
string
)
(
string
,
error
)
{
if
len
(
args
)
!=
1
{
argsLen
:=
cmd
.
ArgsLenAtDash
()
return
""
,
cmdutil
.
UsageErrorf
(
cmd
,
"exactly one NAME is required, got %d"
,
len
(
args
))
// ArgsLenAtDash returns -1 when -- was not specified
if
argsLen
==
-
1
{
argsLen
=
len
(
args
)
}
if
argsLen
!=
1
{
return
""
,
cmdutil
.
UsageErrorf
(
cmd
,
"exactly one NAME is required, got %d"
,
argsLen
)
}
}
return
args
[
0
],
nil
return
args
[
0
],
nil
}
}
...
...
test/cmd/apps.sh
View file @
59fc1200
...
@@ -212,6 +212,16 @@ run_deployment_tests() {
...
@@ -212,6 +212,16 @@ run_deployment_tests() {
# Clean up
# Clean up
kubectl delete deployment test-nginx-apps
"
${
kube_flags
[@]
}
"
kubectl delete deployment test-nginx-apps
"
${
kube_flags
[@]
}
"
### Test kubectl create deployment with image and command
# Pre-Condition: No deployment exists.
kube::test::get_object_assert deployment
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# Command
kubectl create deployment nginx-with-command
--image
=
k8s.gcr.io/nginx:test-cmd
--
/bin/sleep infinity
# Post-Condition: Deployment "nginx" is created.
kube::test::get_object_assert
'deploy nginx-with-command'
"{{
$container_name_field
}}"
'nginx'
# Clean up
kubectl delete deployment nginx-with-command
"
${
kube_flags
[@]
}
"
### Test kubectl create deployment should not fail validation
### Test kubectl create deployment should not fail validation
# Pre-Condition: No deployment exists.
# Pre-Condition: No deployment exists.
kube::test::get_object_assert deployment
"{{range.items}}{{
$id_field
}}:{{end}}"
''
kube::test::get_object_assert deployment
"{{range.items}}{{
$id_field
}}:{{end}}"
''
...
...
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