blob: 338280b9bfafe735cc8bca168cf62597c0b0a77b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# Agent Guidelines
## Resource Management
All public functions which start with `Have` should be responsible for registering the resource they create.
## Dependencies
Concrete resource types (e.g. `file.File`, `dir.Dir`, `link.Link`, `pkg.Package`)
embed `embed.DependsOn` to accumulate dependency IDs. The `DependsOn` option
records those IDs, and each `Present` function forwards them into
`resource.Register(..., x.DependsOn.IDs...)`. A `Multi` dependency is expanded
via `Dependencies()` so each member is depended upon individually, and
`repository.apply()` topologically sorts resources by their `dependsOn` set.
## Shared embeds
State common to all concrete resource types lives in the `embed` package and is
embedded rather than redeclared:
- `embed.DependsOn` — dependency IDs (`IDs` field) plus the `AddDependency` method.
- `embed.Absence` — the `Absent` field plus the `SetAbsent` method (implements
`opt.Absentable`).
When adding a field or capability shared by every resource type, prefer a new
embed type here instead of duplicating the field and its setter in each resource.
|