Prettify printing of webhook warnings (#1353)

This commit is contained in:
Markus Thömmes 2021-06-24 16:04:46 +02:00 committed by GitHub
parent 46297a770e
commit 95dc71c631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -12,6 +12,14 @@
| https://github.com/knative/client/pull/[#] | https://github.com/knative/client/pull/[#]
//// ////
## Unreleased
[cols="1,10,3", options="header", width="100%"]
| | Description | PR
| 🎁
| Prettify printing of webhook warnings
| https://github.com/knative/client/pull/1353[#1353]
## v0.23.0 (2021-05-18) ## v0.23.0 (2021-05-18)
[cols="1,10,3", options="header", width="100%"] [cols="1,10,3", options="header", width="100%"]
|=== |===

View File

@ -24,6 +24,7 @@ import (
"time" "time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/client-go/rest"
"knative.dev/client/pkg/kn/config" "knative.dev/client/pkg/kn/config"
"knative.dev/client/pkg/kn/plugin" "knative.dev/client/pkg/kn/plugin"
@ -35,6 +36,14 @@ func init() {
} }
func main() { func main() {
// Override client-go's warning handler to give us nicely printed warnings.
rest.SetDefaultWarningHandler(
rest.NewWarningWriter(os.Stderr, rest.WarningWriterOptions{
// only print a given warning the first time we receive it
Deduplicate: true,
}),
)
err := run(os.Args[1:]) err := run(os.Args[1:])
if err != nil && len(os.Args) > 1 { if err != nil && len(os.Args) > 1 {
printError(err) printError(err)