-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: persist k8s client QPS/Burst values #263
Conversation
This PR addresses issue introduced by kubernetes/cli-runtime#23 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm I have added one comment
examples/trivy.go
Outdated
func WithQPS(qps float32) k8s.ClusterOption { | ||
return func(o *genericclioptions.ConfigFlags) { | ||
o.WrapConfigFn = combineConfigFns(o.WrapConfigFn, func(c *rest.Config) *rest.Config { | ||
c.QPS = qps | ||
return c | ||
}) | ||
} | ||
} | ||
|
||
func WithBurst(burst int) k8s.ClusterOption { | ||
return func(o *genericclioptions.ConfigFlags) { | ||
o.WrapConfigFn = combineConfigFns(o.WrapConfigFn, func(c *rest.Config) *rest.Config { | ||
c.Burst = burst | ||
return c | ||
}) | ||
} | ||
} | ||
|
||
// Helper function to combine multiple config functions | ||
func combineConfigFns(existing, newFn func(*rest.Config) *rest.Config) func(*rest.Config) *rest.Config { | ||
if existing == nil { | ||
return newFn | ||
} | ||
return func(c *rest.Config) *rest.Config { | ||
if modified := existing(c); modified != nil { | ||
return newFn(modified) | ||
} | ||
return newFn(c) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these option function should be in k8s.go file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I have moved them over to k8s.go
file.
lgtm 🚀 |
This PR intents to allow end users to use custom QPS/Burst value with
trivy-kubernetes
library with wrapper functionsOutput after QPS/Burst value set to 100/100 (after this PR)
Output with no overrides(before this PR)
@chen-keinan This PR fixes the issues we discussed in #262