Skip to content

Commit f426d63

Browse files
committed
docs(readme): Update instructions for using ResourceBuilder
Explain how to use the ResourceBuilder in a new investigation, including requesting resources and the automatic dependency handling. Co-authored-by: Aider <using Gemini>
1 parent 735f4d5 commit f426d63

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,20 @@ As PagerDuty itself does not provide finer granularity for webhooks than service
6868
To add a new alert investigation:
6969

7070
- run `make bootstrap-investigation` to generate boilerplate code in `pkg/investigations` (This creates the corresponding folder & .go file, and also appends the investigation to the `availableInvestigations` interface in `registry.go`.).
71-
- investigation.Resources contain initialized clients for the clusters aws environment, ocm and more. See [Integrations](#integrations)
71+
- The `Run` method of your investigation receives a `ResourceBuilder`. Use its `With...` methods to request the resources your investigation needs, then call `Build()` to get a `Resources` struct containing them. The builder automatically handles dependencies between resources (e.g., requesting an AWS client will also initialize the cluster object). For example:
72+
```go
73+
func (c *Investigation) Run(rb investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
74+
result := investigation.InvestigationResult{}
75+
// Request an AWS client. This will also ensure the Cluster resource is built.
76+
r, err := rb.WithAwsClient().Build()
77+
if err != nil {
78+
return result, err
79+
}
80+
// Now you can use r.AwsClient, r.Cluster, r.PdClient, etc.
81+
// ...
82+
}
83+
```
84+
- The returned `Resources` struct contains initialized clients and cluster objects. See [Integrations](#integrations) for a full list of available resources.
7285
- Add test objects or scripts used to recreate the alert symptoms to the `pkg/investigations/$INVESTIGATION_NAME/testing/` directory for future use. Be sure to clearly document the testing procedure under the `Testing` section of the investigation-specific README.md file
7386

7487
### Graduating an investigation

0 commit comments

Comments
 (0)