-
Notifications
You must be signed in to change notification settings - Fork 330
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
Optionally generate an init func for an informer #2989
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ package main | |
|
||
import ( | ||
"flag" | ||
"os" | ||
|
||
"k8s.io/klog/v2" | ||
|
||
|
@@ -36,13 +37,17 @@ func main() { | |
genericArgs.AddFlags(pflag.CommandLine) | ||
customArgs.AddFlags(pflag.CommandLine) | ||
flag.Set("logtostderr", "true") | ||
skipInitFuncForInformer := flag.Bool("skipInitFuncForInformer", false, "Skip the init function for informer") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Args can be added here: https://github.com/knative/pkg/blob/main/codegen/cmd/injection-gen/args/args.go There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I was not sure if I should touch those. |
||
pflag.CommandLine.AddGoFlagSet(flag.CommandLine) | ||
pflag.Parse() | ||
|
||
if err := generatorargs.Validate(genericArgs); err != nil { | ||
klog.Fatal("Error: ", err) | ||
} | ||
|
||
if *skipInitFuncForInformer { | ||
os.Setenv(generators.SkipInitFuncForInformerEnv, "true") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed if we setup args properly |
||
// Run it. | ||
if err := genericArgs.Execute( | ||
generators.NameSystems(), | ||
|
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.
Can we pass the flag value to the context map
m
and just do theif
logic in the template?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.
Let me try.
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.
Ok I didn't see it was using go templates behind the scenes, now it makes sense.