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
7480650e
Unverified
Commit
7480650e
authored
Oct 16, 2018
by
Ibrahim Mbaziira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove error output from stdout to stderr
parent
2a733afa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
jsonpath.go
...io/cli-runtime/pkg/genericclioptions/printers/jsonpath.go
+6
-4
get.sh
test/cmd/get.sh
+1
-1
No files found.
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/printers/jsonpath.go
View file @
7480650e
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
printers
package
printers
import
(
import
(
"bytes"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"io"
"io"
...
@@ -136,10 +137,11 @@ func (j *JSONPathPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
...
@@ -136,10 +137,11 @@ func (j *JSONPathPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
}
}
if
err
:=
j
.
JSONPath
.
Execute
(
w
,
queryObj
);
err
!=
nil
{
if
err
:=
j
.
JSONPath
.
Execute
(
w
,
queryObj
);
err
!=
nil
{
fmt
.
Fprintf
(
w
,
"Error executing template: %v. Printing more information for debugging the template:
\n
"
,
err
)
buf
:=
bytes
.
NewBuffer
(
nil
)
fmt
.
Fprintf
(
w
,
"
\t
template was:
\n\t\t
%v
\n
"
,
j
.
rawTemplate
)
fmt
.
Fprintf
(
buf
,
"Error executing template: %v. Printing more information for debugging the template:
\n
"
,
err
)
fmt
.
Fprintf
(
w
,
"
\t
object given to jsonpath engine was:
\n\t\t
%#v
\n\n
"
,
queryObj
)
fmt
.
Fprintf
(
buf
,
"
\t
template was:
\n\t\t
%v
\n
"
,
j
.
rawTemplate
)
return
fmt
.
Errorf
(
"error executing jsonpath %q: %v
\n
"
,
j
.
rawTemplate
,
err
)
fmt
.
Fprintf
(
buf
,
"
\t
object given to jsonpath engine was:
\n\t\t
%#v
\n\n
"
,
queryObj
)
return
fmt
.
Errorf
(
"error executing jsonpath %q: %v
\n
"
,
j
.
rawTemplate
,
buf
.
String
())
}
}
return
nil
return
nil
}
}
test/cmd/get.sh
View file @
7480650e
...
@@ -162,7 +162,7 @@ run_kubectl_get_tests() {
...
@@ -162,7 +162,7 @@ run_kubectl_get_tests() {
kube::test::if_has_string
"
${
output_message
}
"
'valid-pod:'
kube::test::if_has_string
"
${
output_message
}
"
'valid-pod:'
## check --allow-missing-template-keys=false results in an error for a missing key with jsonpath
## check --allow-missing-template-keys=false results in an error for a missing key with jsonpath
output_message
=
$(
!
kubectl get pod valid-pod
--allow-missing-template-keys
=
false
-o
jsonpath
=
'{.missing}'
"
${
kube_flags
[@]
}
"
)
output_message
=
$(
!
kubectl get pod valid-pod
--allow-missing-template-keys
=
false
-o
jsonpath
=
'{.missing}'
2>&1
"
${
kube_flags
[@]
}
"
)
kube::test::if_has_string
"
${
output_message
}
"
'missing is not found'
kube::test::if_has_string
"
${
output_message
}
"
'missing is not found'
## check --allow-missing-template-keys=false results in an error for a missing key with go
## check --allow-missing-template-keys=false results in an error for a missing key with go
...
...
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