internal/pkg: rename inputs method
Test / Create distribution (push) Successful in 1m2s
Test / Sandbox (push) Successful in 2m56s
Test / ShareFS (push) Successful in 4m2s
Test / Hakurei (push) Successful in 4m14s
Test / Sandbox (race detector) (push) Successful in 5m46s
Test / Hakurei (race detector) (push) Successful in 6m47s
Test / Flake checks (push) Successful in 1m12s

Inputs is more correct than dependencies in the current terminology.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-07-02 22:59:40 +09:00
parent 3ba6609444
commit 4ad1b75382
11 changed files with 38 additions and 36 deletions
+2 -2
View File
@@ -303,8 +303,8 @@ func init() {
}) })
} }
// Dependencies returns a slice containing the backing file. // Inputs returns a slice containing the backing file.
func (a archiveArtifact) Dependencies() []Artifact { func (a archiveArtifact) Inputs() []Artifact {
return []Artifact{a.f} return []Artifact{a.f}
} }
+2 -2
View File
@@ -66,8 +66,8 @@ func init() {
}) })
} }
// Dependencies returns a slice containing the backing file. // Inputs returns a slice containing the backing file.
func (a *decompressArtifact) Dependencies() []Artifact { func (a *decompressArtifact) Inputs() []Artifact {
return []Artifact{a.f} return []Artifact{a.f}
} }
+3 -3
View File
@@ -407,9 +407,9 @@ func init() {
func(r *IRReader) Artifact { return readExecArtifact(r, true) }) func(r *IRReader) Artifact { return readExecArtifact(r, true) })
} }
// Dependencies returns a slice of all artifacts collected from caller-supplied // Inputs returns a slice of all artifacts collected from caller-supplied
// [ExecPath]. // [ExecPath].
func (a *execArtifact) Dependencies() []Artifact { func (a *execArtifact) Inputs() []Artifact {
artifacts := make([][]Artifact, 0, len(a.paths)) artifacts := make([][]Artifact, 0, len(a.paths))
for _, p := range a.paths { for _, p := range a.paths {
artifacts = append(artifacts, p.A) artifacts = append(artifacts, p.A)
@@ -617,7 +617,7 @@ func (c *Cache) EnterExec(
return ErrNotExec return ErrNotExec
} }
deps := Collect(a.Dependencies()) deps := Collect(a.Inputs())
if _, _, err = c.Cure(&deps); err == nil { if _, _, err = c.Cure(&deps); err == nil {
return errors.New("unreachable") return errors.New("unreachable")
} else if !IsCollected(err) { } else if !IsCollected(err) {
+2 -2
View File
@@ -63,8 +63,8 @@ func init() {
}) })
} }
// Dependencies returns a nil slice. // Inputs returns a nil slice.
func (*fileArtifact) Dependencies() []Artifact { return nil } func (*fileArtifact) Inputs() []Artifact { return nil }
// IsExclusive returns false: Cure returns a prepopulated buffer. // IsExclusive returns false: Cure returns a prepopulated buffer.
func (*fileArtifact) IsExclusive() bool { return false } func (*fileArtifact) IsExclusive() bool { return false }
+2 -2
View File
@@ -241,7 +241,7 @@ func (ic *irCache) encode(
a Artifact, a Artifact,
inputs map[Artifact]cureRes, inputs map[Artifact]cureRes,
) (err error) { ) (err error) {
deps := a.Dependencies() deps := a.Inputs()
idents := make([]*extIdent, len(deps)) idents := make([]*extIdent, len(deps))
if inputs == nil { if inputs == nil {
for i, d := range deps { for i, d := range deps {
@@ -330,7 +330,7 @@ func (ic *irCache) encodeAll(
return return
} }
for _, d := range a.Dependencies() { for _, d := range a.Inputs() {
if err = ic.encodeAll(w, d, encoded); err != nil { if err = ic.encodeAll(w, d, encoded); err != nil {
return return
} }
+2 -2
View File
@@ -54,8 +54,8 @@ func init() {
}) })
} }
// Dependencies returns a nil slice. // Inputs returns a nil slice.
func (*httpArtifact) Dependencies() []Artifact { return nil } func (*httpArtifact) Inputs() []Artifact { return nil }
// IsExclusive returns false: Cure returns as soon as a response is received. // IsExclusive returns false: Cure returns as soon as a response is received.
func (*httpArtifact) IsExclusive() bool { return false } func (*httpArtifact) IsExclusive() bool { return false }
+8 -6
View File
@@ -405,13 +405,13 @@ type Artifact interface {
// Result must remain identical across multiple invocations. // Result must remain identical across multiple invocations.
Params(ctx *IContext) Params(ctx *IContext)
// Dependencies returns a slice of [Artifact] that the current instance // Inputs returns a slice of [Artifact] the current instance has access to
// depends on to produce its contents. // while producing its output.
// //
// Callers must not modify the retuned slice. // Callers must not modify the retuned slice.
// //
// Result must remain identical across multiple invocations. // Result must remain identical across multiple invocations.
Dependencies() []Artifact Inputs() []Artifact
// IsExclusive returns whether the [Artifact] is exclusive. Exclusive // IsExclusive returns whether the [Artifact] is exclusive. Exclusive
// artifacts might not run in parallel with each other, and are still // artifacts might not run in parallel with each other, and are still
@@ -2180,7 +2180,7 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
break break
case FloodArtifact: case FloodArtifact:
deps := a.Dependencies() deps := a.Inputs()
f := FContext{t, make(map[Artifact]cureRes, len(deps))} f := FContext{t, make(map[Artifact]cureRes, len(deps))}
var wg sync.WaitGroup var wg sync.WaitGroup
@@ -2697,6 +2697,8 @@ func IsCollected(err error) bool { return errors.As(err, new(Collected)) }
// [pkg.Artifact]. It returns [Collected]. // [pkg.Artifact]. It returns [Collected].
type Collect []Artifact type Collect []Artifact
var _ Artifact = new(Collect)
// Cure returns [Collected]. // Cure returns [Collected].
func (*Collect) Cure(*FContext) error { return Collected{} } func (*Collect) Cure(*FContext) error { return Collected{} }
@@ -2706,8 +2708,8 @@ func (*Collect) Kind() Kind { return kindCollection }
// Params is a noop: dependencies are already represented in the header. // Params is a noop: dependencies are already represented in the header.
func (*Collect) Params(*IContext) {} func (*Collect) Params(*IContext) {}
// Dependencies returns [Collect] as is. // Inputs returns [Collect] as is.
func (c *Collect) Dependencies() []Artifact { return *c } func (c *Collect) Inputs() []Artifact { return *c }
// IsExclusive returns false: Cure is a noop. // IsExclusive returns false: Cure is a noop.
func (*Collect) IsExclusive() bool { return false } func (*Collect) IsExclusive() bool { return false }
+11 -11
View File
@@ -140,11 +140,11 @@ type stubArtifact struct {
cure func(t *pkg.TContext) error cure func(t *pkg.TContext) error
} }
func (a *stubArtifact) Kind() pkg.Kind { return a.kind } func (a *stubArtifact) Kind() pkg.Kind { return a.kind }
func (a *stubArtifact) Params(ctx *pkg.IContext) { ctx.Write(a.params) } func (a *stubArtifact) Params(ctx *pkg.IContext) { ctx.Write(a.params) }
func (a *stubArtifact) Dependencies() []pkg.Artifact { return a.deps } func (a *stubArtifact) Inputs() []pkg.Artifact { return a.deps }
func (a *stubArtifact) Cure(t *pkg.TContext) error { return a.cure(t) } func (a *stubArtifact) Cure(t *pkg.TContext) error { return a.cure(t) }
func (*stubArtifact) IsExclusive() bool { return false } func (*stubArtifact) IsExclusive() bool { return false }
// A stubArtifactF implements [FloodArtifact] with hardcoded behaviour. // A stubArtifactF implements [FloodArtifact] with hardcoded behaviour.
type stubArtifactF struct { type stubArtifactF struct {
@@ -156,11 +156,11 @@ type stubArtifactF struct {
cure func(f *pkg.FContext) error cure func(f *pkg.FContext) error
} }
func (a *stubArtifactF) Kind() pkg.Kind { return a.kind } func (a *stubArtifactF) Kind() pkg.Kind { return a.kind }
func (a *stubArtifactF) Params(ctx *pkg.IContext) { ctx.Write(a.params) } func (a *stubArtifactF) Params(ctx *pkg.IContext) { ctx.Write(a.params) }
func (a *stubArtifactF) Dependencies() []pkg.Artifact { return a.deps } func (a *stubArtifactF) Inputs() []pkg.Artifact { return a.deps }
func (a *stubArtifactF) Cure(f *pkg.FContext) error { return a.cure(f) } func (a *stubArtifactF) Cure(f *pkg.FContext) error { return a.cure(f) }
func (a *stubArtifactF) IsExclusive() bool { return a.excl } func (a *stubArtifactF) IsExclusive() bool { return a.excl }
// A stubFile implements [FileArtifact] with hardcoded behaviour. // A stubFile implements [FileArtifact] with hardcoded behaviour.
type stubFile struct { type stubFile struct {
@@ -1883,7 +1883,7 @@ func (earlyFailureF) Kind() pkg.Kind { return pkg.KindExec }
func (earlyFailureF) Params(*pkg.IContext) {} func (earlyFailureF) Params(*pkg.IContext) {}
func (earlyFailureF) IsExclusive() bool { return false } func (earlyFailureF) IsExclusive() bool { return false }
func (a earlyFailureF) Dependencies() []pkg.Artifact { func (a earlyFailureF) Inputs() []pkg.Artifact {
deps := make([]pkg.Artifact, a) deps := make([]pkg.Artifact, a)
for i := range deps { for i := range deps {
deps[i] = a - 1 deps[i] = a - 1
+2 -2
View File
@@ -58,8 +58,8 @@ func init() {
}) })
} }
// Dependencies returns a slice containing the backing file. // Inputs returns a slice containing the backing file.
func (a *tarArtifact) Dependencies() []Artifact { func (a *tarArtifact) Inputs() []Artifact {
return []Artifact{a.f} return []Artifact{a.f}
} }
+2 -2
View File
@@ -26,8 +26,8 @@ func (a busyboxBin) Params(*pkg.IContext) {}
// IsExclusive returns false: Cure performs a trivial filesystem write. // IsExclusive returns false: Cure performs a trivial filesystem write.
func (busyboxBin) IsExclusive() bool { return false } func (busyboxBin) IsExclusive() bool { return false }
// Dependencies returns the underlying busybox [pkg.FileArtifact]. // Inputs returns the underlying busybox [pkg.FileArtifact].
func (a busyboxBin) Dependencies() []pkg.Artifact { func (a busyboxBin) Inputs() []pkg.Artifact {
return []pkg.Artifact{a.bin} return []pkg.Artifact{a.bin}
} }
+2 -2
View File
@@ -118,8 +118,8 @@ func init() {
// IsExclusive returns false: Cure performs a few trivial filesystem writes. // IsExclusive returns false: Cure performs a few trivial filesystem writes.
func (cureEtc) IsExclusive() bool { return false } func (cureEtc) IsExclusive() bool { return false }
// Dependencies returns a slice containing the backing iana-etc release. // Inputs returns a slice containing the backing iana-etc release.
func (a cureEtc) Dependencies() []pkg.Artifact { func (a cureEtc) Inputs() []pkg.Artifact {
if !a.minimal { if !a.minimal {
return []pkg.Artifact{ianaEtc} return []pkg.Artifact{ianaEtc}
} }