aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-03-26 14:10:35 +0900
committerOphestra <cat@gensokyo.uk>2026-03-26 14:11:10 +0900
commitaf038c89ffe01f4b07ab94030fa83baa8d5f83d9 (patch)
tree027ef910b73c58bf5e5d824d5859b8bbb41ca1eb /internal/pkg
parentd2f30173cd8d635e37623cf72b4867eb0e6ddf1d (diff)
internal/pkg: collection helper-artifact
This was moved from internal/rosa because it is considered generally useful. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg')
-rw-r--r--internal/pkg/pkg.go37
1 files changed, 36 insertions, 1 deletions
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go
index 995357e8..9a8dc9fd 100644
--- a/internal/pkg/pkg.go
+++ b/internal/pkg/pkg.go
@@ -366,7 +366,7 @@ type TrivialArtifact interface {
}
// KnownIdent is optionally implemented by [Artifact] and is used instead of
-// [Kind.Ident] when it is available.
+// [Cache.Ident] when it is available.
//
// This is very subtle to use correctly. The implementation must ensure that
// this value is globally unique, otherwise [Cache] can enter an inconsistent
@@ -440,6 +440,11 @@ const (
)
const (
+ // kindCollection is the kind of [Collect]. It never cures successfully.
+ kindCollection Kind = KindCustomOffset - 1 - iota
+)
+
+const (
// fileLock is the file name appended to Cache.base for guaranteeing
// exclusive access to the cache directory.
fileLock = "lock"
@@ -1890,3 +1895,33 @@ func open(
return &c, nil
}
+
+// Collected is returned by [Collect.Cure] to indicate a successful collection.
+type Collected struct{}
+
+// Error returns a constant string to satisfy error, but should never be seen
+// by the user.
+func (Collected) Error() string { return "artifacts successfully collected" }
+
+// IsCollected returns whether the underlying error contains that of the result
+// of curing a [Collect] helper.
+func IsCollected(err error) bool { return errors.As(err, new(Collected)) }
+
+// Collect implements [pkg.FloodArtifact] to concurrently cure multiple
+// [pkg.Artifact]. It returns [Collected].
+type Collect []Artifact
+
+// Cure returns [Collected].
+func (*Collect) Cure(*FContext) error { return Collected{} }
+
+// Kind returns the hardcoded [pkg.Kind] value.
+func (*Collect) Kind() Kind { return kindCollection }
+
+// Params is a noop: dependencies are already represented in the header.
+func (*Collect) Params(*IContext) {}
+
+// Dependencies returns [Collect] as is.
+func (c *Collect) Dependencies() []Artifact { return *c }
+
+// IsExclusive returns false: Cure is a noop.
+func (*Collect) IsExclusive() bool { return false }