summaryrefslogtreecommitdiff
path: root/internal/resource/multi.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-07-09 00:14:33 +0300
committerPaul Buetow <paul@buetow.org>2026-07-09 00:14:33 +0300
commit756ae621bd97a8b776fefb15e5e7e2292f98ee45 (patch)
treeb454f958e6aef70bf7ca40dcbc106323cee2a42f /internal/resource/multi.go
parent3f8b79f2b1384e3abc2b1bb2fe913688c7ec251c (diff)
dependencies
Diffstat (limited to 'internal/resource/multi.go')
-rw-r--r--internal/resource/multi.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/resource/multi.go b/internal/resource/multi.go
index 1694814..3916287 100644
--- a/internal/resource/multi.go
+++ b/internal/resource/multi.go
@@ -5,6 +5,13 @@ import (
"strings"
)
+// Dependency is implemented by anything that can be depended upon. It returns
+// the flattened list of individual resource IDs, so that depending on a Multi
+// expands into a dependency on each of its members individually.
+type Dependency interface {
+ Dependencies() []string
+}
+
// Multi is a collection of resources that satisfies the api.Resource interface.
type Multi []Resource
@@ -28,6 +35,19 @@ func (m Multi) ID() string {
return strings.Join(ids, "+")
}
+// Dependencies flattens the Multi into the IDs of each of its members, so a
+// dependency on a Multi becomes an individual dependency on every resource it
+// contains.
+func (m Multi) Dependencies() []string {
+ ids := make([]string, 0, len(m))
+
+ for _, res := range m {
+ ids = append(ids, res.Dependencies()...)
+ }
+
+ return ids
+}
+
func (m Multi) Apply() error {
var errs []error