-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor TemplateEngine and ClusterInstance packages #116
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sakhoury The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
02a4e37
to
fcf2419
Compare
/override ci/prow/sonar-pre-submit |
@sakhoury: Overrode contexts on behalf of sakhoury: ci/prow/sonar-pre-submit In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
||
log := te.log.Named("ProcessTemplates") | ||
// Type assertion to handle specific object types | ||
clusterInstance, ok := object.(v1alpha1.ClusterInstance) |
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 this ever be something else? Why not pass the concrete type rather than interface{}
?
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.
The TemplateEngine interface is future-proof designed such that it can accept the processing of an arbitrary CR.
) | ||
|
||
// TemplateEngine defines an interface for processing templates for an abritary object | ||
type TemplateEngine interface { |
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.
I'm curious about your reasons for this change now, are we expecting other kinds of objects to be used to process templates (other than ClusterInstance)?
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.
The SiteConfig Operator can potentially be used to consume and render new CR types other than the ClusterInstance (in the future). Hence, this refactoring, not only logically organizes the existing code for maintainability and readability, it also supports such avenues in the future.
I think also generally the bug fix for the logging state in the template engine (which would be a problem if we run multiple reconciles at once) should be separate from the rest of this refactoring. Especially if we're trying to get the logging change back into 2.12. |
Fair enough! I'll create a separate PR with a fix to the potential template engine logging issue when we support multiple concurrent reconciles. Update: here is the PR #119. |
This commit refactors the TemplateEngine used to render install templates. The following changes are made: - Refactor TemplateEngine into an interface type defined under internal/templates/engine. - Define a concrete ClusterInstance TemplateEngine type that implements the interface. - Refactor the clusterinstance package by separating the ClusterData into its own source file. - Refactor the clusterinstance package by moving commonly used functions and constants to internal/controller/common package. - Reorganized rendered_object.go source file (along with its unit tests) to internal/templates/engine/. - Renamed the imagebasedinstall package to imagebasedinstaller. - Added Red Hat copyright headers to internal/controller/conditions and internal/controller/retry source files. Signed-off-by: Sharat Akhoury <[email protected]>
fcf2419
to
38d004a
Compare
Quality Gate failedFailed conditions |
/override ci/prow/sonar-pre-submit |
@sakhoury: Overrode contexts on behalf of sakhoury: ci/prow/sonar-pre-submit In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
This PR refactors the TemplateEngine used to render install templates. The following changes are made:
Note that no new functionality is added to this PR.
Testing
An end-to-end manual test was performed to verify the SiteConfig Operator functionality.