Skip to content

Commit

Permalink
Improve docs for client-go warning handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
liggitt committed Aug 29, 2020
1 parent d9789c4 commit b0573d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions staging/src/k8s.io/client-go/rest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type Config struct {

// WarningHandler handles warnings in server responses.
// If not set, the default warning handler is used.
// See documentation for SetDefaultWarningHandler() for details.
WarningHandler WarningHandler

// The maximum length of time to wait before giving up on a server request. A value of zero means no timeout.
Expand Down
7 changes: 5 additions & 2 deletions staging/src/k8s.io/client-go/rest/warnings.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ var (
defaultWarningHandlerLock sync.RWMutex
)

// SetDefaultWarningHandler sets the default handler client uses when warning headers are encountered.
// By default, warnings are printed to stderr.
// SetDefaultWarningHandler sets the default handler clients use when warning headers are encountered.
// By default, warnings are logged. Several built-in implementations are provided:
// - NoWarnings suppresses warnings.
// - WarningLogger logs warnings.
// - NewWarningWriter() outputs warnings to the provided writer.
func SetDefaultWarningHandler(l WarningHandler) {
defaultWarningHandlerLock.Lock()
defer defaultWarningHandlerLock.Unlock()
Expand Down

0 comments on commit b0573d5

Please sign in to comment.