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
5ec2a4c3
Commit
5ec2a4c3
authored
Jan 26, 2017
by
juanvallejo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only output "No resources found." for human readable printers
parent
9ea94806
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
4 deletions
+59
-4
test.sh
hack/lib/test.sh
+19
-1
test-cmd-util.sh
hack/make-rules/test-cmd-util.sh
+40
-0
get.go
pkg/kubectl/cmd/get.go
+0
-3
No files found.
hack/lib/test.sh
View file @
5ec2a4c3
...
@@ -224,7 +224,7 @@ kube::test::if_has_string() {
...
@@ -224,7 +224,7 @@ kube::test::if_has_string() {
local
message
=
$1
local
message
=
$1
local
match
=
$2
local
match
=
$2
if
[[
$(
echo
"
$message
"
|
grep
"
$match
"
)
]]
;
then
if
echo
"
$message
"
|
grep
-q
"
$match
"
;
then
echo
"Successful"
echo
"Successful"
echo
"message:
$message
"
echo
"message:
$message
"
echo
"has:
$match
"
echo
"has:
$match
"
...
@@ -238,6 +238,24 @@ kube::test::if_has_string() {
...
@@ -238,6 +238,24 @@ kube::test::if_has_string() {
fi
fi
}
}
kube::test::if_has_not_string
()
{
local
message
=
$1
local
match
=
$2
if
echo
"
$message
"
|
grep
-q
"
$match
"
;
then
echo
"FAIL!"
echo
"message:
$message
"
echo
"has:
$match
"
caller
return
1
else
echo
"Successful"
echo
"message:
$message
"
echo
"has not:
$match
"
return
0
fi
}
# Returns true if the required resource is part of supported resources.
# Returns true if the required resource is part of supported resources.
# Expects env vars:
# Expects env vars:
# SUPPORTED_RESOURCES: Array of all resources supported by the apiserver. "*"
# SUPPORTED_RESOURCES: Array of all resources supported by the apiserver. "*"
...
...
hack/make-rules/test-cmd-util.sh
View file @
5ec2a4c3
...
@@ -1037,6 +1037,46 @@ run_kubectl_get_tests() {
...
@@ -1037,6 +1037,46 @@ run_kubectl_get_tests() {
# Post-condition: POD abc should error since it doesn't exist
# Post-condition: POD abc should error since it doesn't exist
kube::test::if_has_string
"
${
output_message
}
"
'pods "abc" not found'
kube::test::if_has_string
"
${
output_message
}
"
'pods "abc" not found'
### Test retrieval of pods when none exist with non-human readable output format flag specified
# Pre-condition: no pods exist
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# Command
output_message
=
$(
kubectl get pods 2>&1
"
${
kube_flags
[@]
}
"
-o
json
)
# Post-condition: The text "No resources found" should not be part of the output
kube::test::if_has_not_string
"
${
output_message
}
"
'No resources found'
# Command
output_message
=
$(
kubectl get pods 2>&1
"
${
kube_flags
[@]
}
"
-o
yaml
)
# Post-condition: The text "No resources found" should not be part of the output
kube::test::if_has_not_string
"
${
output_message
}
"
'No resources found'
# Command
output_message
=
$(
kubectl get pods 2>&1
"
${
kube_flags
[@]
}
"
-o
name
)
# Post-condition: The text "No resources found" should not be part of the output
kube::test::if_has_not_string
"
${
output_message
}
"
'No resources found'
# Command
output_message
=
$(
kubectl get pods 2>&1
"
${
kube_flags
[@]
}
"
-o
jsonpath
=
'{.items}'
)
# Post-condition: The text "No resources found" should not be part of the output
kube::test::if_has_not_string
"
${
output_message
}
"
'No resources found'
# Command
output_message
=
$(
kubectl get pods 2>&1
"
${
kube_flags
[@]
}
"
-o
go-template
=
'{{.items}}'
)
# Post-condition: The text "No resources found" should not be part of the output
kube::test::if_has_not_string
"
${
output_message
}
"
'No resources found'
# Command
output_message
=
$(
kubectl get pods 2>&1
"
${
kube_flags
[@]
}
"
-o
custom-columns
=
NAME:.metadata.name
)
# Post-condition: The text "No resources found" should not be part of the output
kube::test::if_has_not_string
"
${
output_message
}
"
'No resources found'
### Test retrieval of pods when none exist, with human-readable output format flag specified
# Pre-condition: no pods exist
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# Command
output_message
=
$(
kubectl get pods 2>&1
"
${
kube_flags
[@]
}
"
)
# Post-condition: The text "No resources found" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'No resources found'
# Command
output_message
=
$(
kubectl get pods 2>&1
"
${
kube_flags
[@]
}
"
-o
wide
)
# Post-condition: The text "No resources found" should be part of the output
kube::test::if_has_string
"
${
output_message
}
"
'No resources found'
### Test retrieval of non-existing POD with json output flag specified
### Test retrieval of non-existing POD with json output flag specified
# Pre-condition: no POD exists
# Pre-condition: no POD exists
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
...
...
pkg/kubectl/cmd/get.go
View file @
5ec2a4c3
...
@@ -319,9 +319,6 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
...
@@ -319,9 +319,6 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
}
}
errs
=
append
(
errs
,
err
)
errs
=
append
(
errs
,
err
)
}
}
if
len
(
infos
)
==
0
&&
len
(
errs
)
==
0
{
outputEmptyListWarning
(
errOut
)
}
res
:=
""
res
:=
""
if
len
(
infos
)
>
0
{
if
len
(
infos
)
>
0
{
...
...
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