* refactor codegen into different packages and use gengo v2
This allows us to run this injection against types that have newer golang features - eg. 'any'
* updated go.mod drops gengo v1
* tweak scripts to support gengov2 framework
* drop verbose output
Generally K8s types have a list type where the 'Items' member is an
array of structs.
ie. https://pkg.go.dev/k8s.io/api@v0.25.3/apps/v1#DeploymentList
type DeploymentList struct {
...
// Items is the list of Deployments.
Items []Deployment `json:"items" protobuf:"bytes,2,rep,name=items"`
}
Istio is an exception where the list contains pointers to structs
type GatewayList struct {
...
Items []*Gateway `json:"items" protobuf:"bytes,2,rep,name=items"`
}
To hint that the list types are pointers you can now pass the flag
'--lister-has-pointer-elem'.
Ideally we could infer this info by inspecting the types but
unfortunately the generator doesn't load this information
* allow multiple values for comment tag keys
this will allow us to support multiple annotation keys
* add OR filter chain
* update codegen to support multiple annotation keys
* Preserve previous code & formatting if the number of annotation keys is 1
- preserve the order of the annotations vs. sorting it
- deprecate and don't remove ClassAnnotationKey to allow migration to happen smoothly
* fix default value for krshape
* include clarifying comment
* This commit contains the actual changes to support dynamic client injection.
* Incorporate n3wscott review nits
* This includes the code-generation for the dynamic client-based injection.
This also includes a number of manually created files of the form `*_expansion.go`, which are needed to satisfy some of the Kubernetes manual type "expansions". At present, these are all simply `panic("NYI")`, but may become more than that in the future.
I noticed doing some tinkering that these were running on every iteration, but the inputs don't change. This sinks the calls to below the loop, and reduces things to a single call for each.
* Fix#2003
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
* Removed useless newline
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
* Removed useless check
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
* Now we don't have any newlines anymore
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
* add filtered InformerFactory and informers which only list and watch resources with the given labels
* rename to RegisterFilteredInformers
* generated files
* typo
* update per comments
* rename file
* rm old files
* Some nits in the genreconciler
- make sure we allocate proper amount of slice space
- `t:=t` is needed only if you're doing goroutines in the loop
- extract constants outside of the loops.
- reformat
* meh, I was wrong
* generate krshaped logic
* add logic to the tag
* Update injection/README.md
Co-authored-by: Matt Moore <mattmoor@vmware.com>
* move var to reconciler
Co-authored-by: Matt Moore <mattmoor@vmware.com>
* genreconciler:nonNamespaced
* Adding a force-kinds flag to the reconciler generator to allow us to generate reconcilers for non-owned types.
* force-kinds --> force-genreconciler-kinds
* some minor nits with the generators for non-knative types needed to be removed.
* remove whitespace
Co-authored-by: Nacho Cano <nachoacano@gmail.com>
* looking at annotations for group overrides.
* checkpoint.
* checkpoint
* I think it is correct.
* ok
* trim down the files.
* simulate tekton
* working test out of checkin
* remove test client
* update docs
* and test.
* lint
* it ok
* update codegen
* fix rando issues
* code in the group for finalizer name.
* Use FinalizeKind
* show the Finalizer interface.
* removing isFinalizing
* sync finalizers before calling reconcilekind
* missed the events change.
* adding a reconciler generator to use as the base reconcilers for all of knative.
* mend
* fix tag names.
* use reconciler events
* trying new thing.
* base working reconciler gen
* working cleaned up reconciler generator.
* fix typo
* fix some ordering.
* fix interface path
* fix whitespace
* update deps.
* updates based on feedback.
* Remove core loop.
* reconcilerImpl
* add NewReconciler
* Fix copyright header
* Comment out finalizers
* remove finalizers from generated code.
This augments the injection codegen with the capability to produce a duck.InformerFactory
attached to context for each type that we process.
Now a `duck.InformerFactory` for "Addressable" can be produced by "Get"ing it from the context.
This is triggered by placing `// +genduck` on the type that implements `duck.Implementable`.
* update codegen so the fatal error messages are more informative
String representation of an untyped nil is 'nil' so the Fatal messages weren't useful
* generate k8s injection code
* generate apiextensions injection code
* use Fatal & move output paths
* switch from Fatal to Panic
* injection creates a single factory