You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(investigation): Rework ResourceBuilder for improved usability
This commit refactors the \`ResourceBuilder\` to be more user-friendly and robust. The previous implementation required callers to manage dependencies between resources manually and was prone to runtime errors if resources were not requested in the correct order.
The key changes include:
- A new \`NewResourceBuilder\` constructor now handles the initial setup of required components like OCM and PagerDuty clients, simplifying the builder's API.
- The \`Build()\` method now lazily initializes resources only when they are explicitly requested via \`With...\` methods. This includes deferring the \`GetClusterInfo\` call until necessary.
- Dependency management is now handled internally by the builder. For example, requesting an AWS client via \`WithAwsClient()\` will automatically ensure the cluster object is also built.
- Investigation \`Run\` methods have been updated to explicitly declare their resource dependencies using the new builder methods.
This refactoring resolves several build and runtime errors, improves the developer experience by providing a clearer and safer API, and makes investigations easier to write and maintain.
Co-authored-by: Aider <using Gemini>
iferr!=nil&&strings.Contains(err.Error(), "no cluster found") {
122
-
logging.Warnf("No cluster found with ID '%s'. Escalating and exiting.", clusterID)
123
-
returnpdClient.EscalateIncidentWithNote("CAD was unable to find the incident cluster in OCM. An alert for a non-existing cluster is unexpected. Please investigate manually.")
116
+
iferr!=nil {
117
+
ifstrings.Contains(err.Error(), "no cluster found") {
118
+
logging.Warnf("No cluster found with ID '%s'. Escalating and exiting.", clusterID)
119
+
returnpdClient.EscalateIncidentWithNote("CAD was unable to find the incident cluster in OCM. An alert for a non-existing cluster is unexpected. Please investigate manually.")
Copy file name to clipboardExpand all lines: pkg/investigations/machinehealthcheckunterminatedshortcircuitsre/machinehealthcheckunterminatedshortcircuitsre.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ func (i *Investigation) teardown() error {
0 commit comments