Skip to content

chore: refactor the status/condition updating into an interface with functions#73

Merged
diranged merged 4 commits intomainfrom
status_interface
Dec 15, 2022
Merged

chore: refactor the status/condition updating into an interface with functions#73
diranged merged 4 commits intomainfrom
status_interface

Conversation

@diranged
Copy link
Copy Markdown
Owner

@diranged diranged commented Dec 14, 2022

This change begins refactoring the reconciler code. The existing reconciler code makes heavy use of embedded structs to mimic an inheritance model. Go doesn't have an inheritance model, and generally discourages this in favor of interfaces.

This code moves the updateStatus, updateCondition, setReadyStatus and refetch methods out of the BaseReconciler{} struct and into their own packages where they are pure functions. These functions work by checking that the objects passed in match the hasStatusReconciler interface.

The ultimate goal is to create generic RequestReconciler and TemplateReconciler controllers that can be configured dynamically on startup to decide which custom resources they are monitoring for, and which IBuilder is used for them. This pattern will make it simpler to add in our own custom controllers in the future, or even support a pluggable controller model.

Note: The naming of hasStatusReconciler is ugly - but it's a private interface so we can refactor it any time once we have a better name.

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 14, 2022

Pull Request Test Coverage Report for Build 3699328265

  • 131 of 196 (66.84%) changed or added relevant lines in 11 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.7%) to 44.125%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/v1alpha1/condition_types.go 0 2 0.0%
internal/controllers/base_request_controller.go 83 85 97.65%
internal/controllers/internal/status/update_status.go 15 18 83.33%
internal/controllers/pod_access_request_controller.go 14 18 77.78%
internal/controllers/internal/status/update_condition.go 0 17 0.0%
internal/controllers/exec_access_request_controller.go 0 18 0.0%
internal/controllers/internal/status/set_ready_status.go 0 19 0.0%
Files with Coverage Reduction New Missed Lines %
internal/controllers/exec_access_request_controller.go 1 0%
Totals Coverage Status
Change from base Build 3698939000: -0.7%
Covered Lines: 860
Relevant Lines: 1949

💛 - Coveralls

@github-actions github-actions bot added documentation Improvements or additions to documentation repo labels Dec 14, 2022
@diranged diranged requested a review from LaikaN57 December 14, 2022 22:43
@diranged diranged marked this pull request as ready for review December 14, 2022 22:43
@diranged diranged requested a review from stlava December 15, 2022 01:49
@diranged diranged merged commit e98e681 into main Dec 15, 2022
@diranged diranged deleted the status_interface branch December 15, 2022 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants