forked from opendatahub-io/opendatahub-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deploy: refactor whitelisting with custom kustomize RemoverPlugin (op…
…endatahub-io#1123) * deploy: pass resource.Resource to manageResource Do not convert Resource to Unstructured early but just before final changes in Unstructured before operations on the cluster. This will allow to run kustomize filters after getResource() call, meaning after analysing resource state in the cluster. This is supposed to be used to filter out whitelisted fields from the manifests if the resource already exist and leave them as default values if the resource is being created by the operator. Unfortunately, it makes a bit of code duplication since the Resource to Unstructured conversion have to be done for both create and patch branches. Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> * plugins: add RemoverPlugin, field remover Make it the same way is other builtin plugins are done implementing an RNode filter. Since it is supposed to be called actually to a single resource, not the whole ResourceMap, implement extra method TransformResource. Use Pipe*() instead of direct filter calling even that it calls only one filter. - first time to call the methods of the inhereted RNode object of the Resource; - second (PipeE) to automatically skip the result Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> * cluster/gvk: add Deployment GroupVersionKind Will be used to filter Deployments for whitelisted fields. Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> * plugins: remover: add tests Test if the plugin able to remove replicas and resources from Deployment object. Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> * deploy: skipUpdateOnWhitelistedFields: convert to RemoverPlugin Use more universal way to filter whitelisted fields. Make it possible to configure list of the fields as an array of configured RemoverPlugins and define components to remove in a map "Component Name" -> "pointer to the list of the fields". It makes it possible to define them separately and reuse the list of the fields (array of RemoverPlugins) for different components. skipUpdateOnWhitelistedFields now takes Resource, so make the conversion to Unstructured after it. Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> * update: - update in testcase - rename function and variables - move var declaration into removeplugin Signed-off-by: Wen Zhou <wenzhou@redhat.com> * update: old testcase should not get replicas reconciled back Signed-off-by: Wen Zhou <wenzhou@redhat.com> * chore: comments Signed-off-by: Wen Zhou <wenzhou@redhat.com> * update: remove WhitelistedComponent - we make all components resource and replicas configable Signed-off-by: Wen Zhou <wenzhou@redhat.com> * update: add check on annoation for whitelistedfield Signed-off-by: Wen Zhou <wenzhou@redhat.com> --------- Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> Signed-off-by: Wen Zhou <wenzhou@redhat.com> Co-authored-by: Yauheni Kaliuta <ykaliuta@redhat.com>
- Loading branch information
Showing
7 changed files
with
462 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.