Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: PodSecurity Admission: Display duplicate warnings only once
Browse files Browse the repository at this point in the history
Signed-off-by: Parthvi Vala <pvala@redhat.com>
valaparthvi committed Apr 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent c57364f commit c66b03f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/kclient/kclient.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@ package kclient

import (
"fmt"
"github.com/redhat-developer/odo/pkg/log"
"k8s.io/kubectl/pkg/util/term"
"strings"

"k8s.io/cli-runtime/pkg/genericclioptions"
@@ -127,6 +129,14 @@ func NewForConfig(config clientcmd.ClientConfig) (client *Client, err error) {
client.KubeClientConfig.QPS = defaultQPS
client.KubeClientConfig.Burst = defaultBurst

// This warning handler ensures that warnings are not duplicated
client.KubeClientConfig.WarningHandler = rest.NewWarningWriter(log.GetStderr(), rest.WarningWriterOptions{
// only print a given warning the first time we receive it
Deduplicate: true,
// highlight the output with color when the output supports it
Color: term.AllowsColorOutput(log.GetStderr()),
})

client.KubeClient, err = kubernetes.NewForConfig(client.KubeClientConfig)
if err != nil {
return nil, err

0 comments on commit c66b03f

Please sign in to comment.