mirror of https://github.com/knative/client.git
Move warning handler from `main()` to `RestConfig()` (#1359)
* Move warning handler from main() to RestConfig() * Add also original code comment
This commit is contained in:
parent
0bbb3ec9d9
commit
a90595961f
|
|
@ -24,8 +24,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
"knative.dev/client/pkg/kn/config"
|
||||
"knative.dev/client/pkg/kn/plugin"
|
||||
"knative.dev/client/pkg/kn/root"
|
||||
|
|
@ -36,14 +34,6 @@ func init() {
|
|||
}
|
||||
|
||||
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,
|
||||
}),
|
||||
)
|
||||
|
||||
os.Exit(runWithExit(os.Args[1:]))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -192,10 +192,13 @@ func (params *KnParams) RestConfig() (*rest.Config, error) {
|
|||
return nil, knerrors.GetError(err)
|
||||
}
|
||||
if params.LogHTTP {
|
||||
// TODO: When we update to the newer version of client-go, replace with
|
||||
// config.Wrap() for future compat.
|
||||
config.WrapTransport = util.NewLoggingTransport
|
||||
config.Wrap(util.NewLoggingTransport)
|
||||
}
|
||||
// Override client-go's warning handler to give us nicely printed warnings.
|
||||
config.WarningHandler = rest.NewWarningWriter(os.Stderr, rest.WarningWriterOptions{
|
||||
// only print a given warning the first time we receive it
|
||||
Deduplicate: true,
|
||||
})
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue