From dde69dde61e57fa929596294f6b4e8f798f5598e Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 2 Jul 2026 22:59:40 +0900 Subject: [PATCH] internal/pkg: rename inputs method Inputs is more correct than dependencies in the current terminology. Signed-off-by: Ophestra --- internal/pkg/archive.go | 4 ++-- internal/pkg/compress.go | 4 ++-- internal/pkg/exec.go | 6 +++--- internal/pkg/file.go | 4 ++-- internal/pkg/ir.go | 4 ++-- internal/pkg/net.go | 4 ++-- internal/pkg/pkg.go | 34 ++++++++++++++++++---------------- internal/pkg/pkg_test.go | 22 +++++++++++----------- internal/pkg/tar.go | 4 ++-- internal/rosa/busybox.go | 4 ++-- internal/rosa/etc.go | 4 ++-- 11 files changed, 48 insertions(+), 46 deletions(-) diff --git a/internal/pkg/archive.go b/internal/pkg/archive.go index a58221e2..ea4017d9 100644 --- a/internal/pkg/archive.go +++ b/internal/pkg/archive.go @@ -303,8 +303,8 @@ func init() { }) } -// Dependencies returns a slice containing the backing file. -func (a archiveArtifact) Dependencies() []Artifact { +// Inputs returns a slice containing the backing file. +func (a archiveArtifact) Inputs() []Artifact { return []Artifact{a.f} } diff --git a/internal/pkg/compress.go b/internal/pkg/compress.go index 838cd98a..50303419 100644 --- a/internal/pkg/compress.go +++ b/internal/pkg/compress.go @@ -66,8 +66,8 @@ func init() { }) } -// Dependencies returns a slice containing the backing file. -func (a *decompressArtifact) Dependencies() []Artifact { +// Inputs returns a slice containing the backing file. +func (a *decompressArtifact) Inputs() []Artifact { return []Artifact{a.f} } diff --git a/internal/pkg/exec.go b/internal/pkg/exec.go index 4dd9fc26..3623c927 100644 --- a/internal/pkg/exec.go +++ b/internal/pkg/exec.go @@ -407,9 +407,9 @@ func init() { 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]. -func (a *execArtifact) Dependencies() []Artifact { +func (a *execArtifact) Inputs() []Artifact { artifacts := make([][]Artifact, 0, len(a.paths)) for _, p := range a.paths { artifacts = append(artifacts, p.A) @@ -617,7 +617,7 @@ func (c *Cache) EnterExec( return ErrNotExec } - deps := Collect(a.Dependencies()) + deps := Collect(a.Inputs()) if _, _, err = c.Cure(&deps); err == nil { return errors.New("unreachable") } else if !IsCollected(err) { diff --git a/internal/pkg/file.go b/internal/pkg/file.go index 18b85b82..1b6b02f7 100644 --- a/internal/pkg/file.go +++ b/internal/pkg/file.go @@ -63,8 +63,8 @@ func init() { }) } -// Dependencies returns a nil slice. -func (*fileArtifact) Dependencies() []Artifact { return nil } +// Inputs returns a nil slice. +func (*fileArtifact) Inputs() []Artifact { return nil } // IsExclusive returns false: Cure returns a prepopulated buffer. func (*fileArtifact) IsExclusive() bool { return false } diff --git a/internal/pkg/ir.go b/internal/pkg/ir.go index 95bdddcb..35fe76e7 100644 --- a/internal/pkg/ir.go +++ b/internal/pkg/ir.go @@ -241,7 +241,7 @@ func (ic *irCache) encode( a Artifact, inputs map[Artifact]cureRes, ) (err error) { - deps := a.Dependencies() + deps := a.Inputs() idents := make([]*extIdent, len(deps)) if inputs == nil { for i, d := range deps { @@ -330,7 +330,7 @@ func (ic *irCache) encodeAll( return } - for _, d := range a.Dependencies() { + for _, d := range a.Inputs() { if err = ic.encodeAll(w, d, encoded); err != nil { return } diff --git a/internal/pkg/net.go b/internal/pkg/net.go index 1f37a92d..412dd2a7 100644 --- a/internal/pkg/net.go +++ b/internal/pkg/net.go @@ -54,8 +54,8 @@ func init() { }) } -// Dependencies returns a nil slice. -func (*httpArtifact) Dependencies() []Artifact { return nil } +// Inputs returns a nil slice. +func (*httpArtifact) Inputs() []Artifact { return nil } // IsExclusive returns false: Cure returns as soon as a response is received. func (*httpArtifact) IsExclusive() bool { return false } diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go index 6bf34b2a..d3816f08 100644 --- a/internal/pkg/pkg.go +++ b/internal/pkg/pkg.go @@ -330,8 +330,8 @@ func (c *common) Open(a Artifact) (r io.ReadCloser, err error) { type FContext struct { TContext - // Cured top-level dependencies looked up by Pathname. - deps map[Artifact]cureRes + // Cured top-level inputs looked up by Pathname. + inputs map[Artifact]cureRes } // linkSubstitute links status for substitute if populated. @@ -373,7 +373,7 @@ func (f *FContext) GetArtifact(a Artifact) ( pathname *check.Absolute, checksum unique.Handle[Checksum], ) { - if res, ok := f.deps[a]; ok { + if res, ok := f.inputs[a]; ok { return res.pathname, res.checksum } panic(InvalidLookupError(f.cache.Ident(a).Value())) @@ -405,13 +405,13 @@ type Artifact interface { // Result must remain identical across multiple invocations. Params(ctx *IContext) - // Dependencies returns a slice of [Artifact] that the current instance - // depends on to produce its contents. + // Inputs returns a slice of [Artifact] the current instance has access to + // while producing its output. // // Callers must not modify the retuned slice. // // Result must remain identical across multiple invocations. - Dependencies() []Artifact + Inputs() []Artifact // IsExclusive returns whether the [Artifact] is exclusive. Exclusive // artifacts might not run in parallel with each other, and are still @@ -2180,15 +2180,15 @@ func (c *Cache) cure(a Artifact, curesExempt bool) ( break case FloodArtifact: - deps := a.Dependencies() - f := FContext{t, make(map[Artifact]cureRes, len(deps))} + inputs := a.Inputs() + f := FContext{t, make(map[Artifact]cureRes, len(inputs))} var wg sync.WaitGroup - wg.Add(len(deps)) - res := make([]cureRes, len(deps)) - errs := make(DependencyCureError, 0, len(deps)) + wg.Add(len(inputs)) + res := make([]cureRes, len(inputs)) + errs := make(DependencyCureError, 0, len(inputs)) var errsMu sync.Mutex - for i, d := range deps { + for i, d := range inputs { pending := pendingArtifactDep{d, &res[i], &errs, &errsMu, &wg} go pending.cure(c) } @@ -2199,11 +2199,11 @@ func (c *Cache) cure(a Artifact, curesExempt bool) ( return } for i, p := range res { - f.deps[deps[i]] = p + f.inputs[inputs[i]] = p } sh := sha512.New384() - err = c.encode(sh, a, f.deps) + err = c.encode(sh, a, f.inputs) if err != nil { return } @@ -2697,6 +2697,8 @@ func IsCollected(err error) bool { return errors.As(err, new(Collected)) } // [pkg.Artifact]. It returns [Collected]. type Collect []Artifact +var _ Artifact = new(Collect) + // Cure returns [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. func (*Collect) Params(*IContext) {} -// Dependencies returns [Collect] as is. -func (c *Collect) Dependencies() []Artifact { return *c } +// Inputs returns [Collect] as is. +func (c *Collect) Inputs() []Artifact { return *c } // IsExclusive returns false: Cure is a noop. func (*Collect) IsExclusive() bool { return false } diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go index d4e9e855..01cd2617 100644 --- a/internal/pkg/pkg_test.go +++ b/internal/pkg/pkg_test.go @@ -140,11 +140,11 @@ type stubArtifact struct { cure func(t *pkg.TContext) error } -func (a *stubArtifact) Kind() pkg.Kind { return a.kind } -func (a *stubArtifact) Params(ctx *pkg.IContext) { ctx.Write(a.params) } -func (a *stubArtifact) Dependencies() []pkg.Artifact { return a.deps } -func (a *stubArtifact) Cure(t *pkg.TContext) error { return a.cure(t) } -func (*stubArtifact) IsExclusive() bool { return false } +func (a *stubArtifact) Kind() pkg.Kind { return a.kind } +func (a *stubArtifact) Params(ctx *pkg.IContext) { ctx.Write(a.params) } +func (a *stubArtifact) Inputs() []pkg.Artifact { return a.deps } +func (a *stubArtifact) Cure(t *pkg.TContext) error { return a.cure(t) } +func (*stubArtifact) IsExclusive() bool { return false } // A stubArtifactF implements [FloodArtifact] with hardcoded behaviour. type stubArtifactF struct { @@ -156,11 +156,11 @@ type stubArtifactF struct { cure func(f *pkg.FContext) error } -func (a *stubArtifactF) Kind() pkg.Kind { return a.kind } -func (a *stubArtifactF) Params(ctx *pkg.IContext) { ctx.Write(a.params) } -func (a *stubArtifactF) Dependencies() []pkg.Artifact { return a.deps } -func (a *stubArtifactF) Cure(f *pkg.FContext) error { return a.cure(f) } -func (a *stubArtifactF) IsExclusive() bool { return a.excl } +func (a *stubArtifactF) Kind() pkg.Kind { return a.kind } +func (a *stubArtifactF) Params(ctx *pkg.IContext) { ctx.Write(a.params) } +func (a *stubArtifactF) Inputs() []pkg.Artifact { return a.deps } +func (a *stubArtifactF) Cure(f *pkg.FContext) error { return a.cure(f) } +func (a *stubArtifactF) IsExclusive() bool { return a.excl } // A stubFile implements [FileArtifact] with hardcoded behaviour. type stubFile struct { @@ -1883,7 +1883,7 @@ func (earlyFailureF) Kind() pkg.Kind { return pkg.KindExec } func (earlyFailureF) Params(*pkg.IContext) {} func (earlyFailureF) IsExclusive() bool { return false } -func (a earlyFailureF) Dependencies() []pkg.Artifact { +func (a earlyFailureF) Inputs() []pkg.Artifact { deps := make([]pkg.Artifact, a) for i := range deps { deps[i] = a - 1 diff --git a/internal/pkg/tar.go b/internal/pkg/tar.go index 9173a976..f1861edd 100644 --- a/internal/pkg/tar.go +++ b/internal/pkg/tar.go @@ -58,8 +58,8 @@ func init() { }) } -// Dependencies returns a slice containing the backing file. -func (a *tarArtifact) Dependencies() []Artifact { +// Inputs returns a slice containing the backing file. +func (a *tarArtifact) Inputs() []Artifact { return []Artifact{a.f} } diff --git a/internal/rosa/busybox.go b/internal/rosa/busybox.go index 923f25ef..ae900a04 100644 --- a/internal/rosa/busybox.go +++ b/internal/rosa/busybox.go @@ -26,8 +26,8 @@ func (a busyboxBin) Params(*pkg.IContext) {} // IsExclusive returns false: Cure performs a trivial filesystem write. func (busyboxBin) IsExclusive() bool { return false } -// Dependencies returns the underlying busybox [pkg.FileArtifact]. -func (a busyboxBin) Dependencies() []pkg.Artifact { +// Inputs returns the underlying busybox [pkg.FileArtifact]. +func (a busyboxBin) Inputs() []pkg.Artifact { return []pkg.Artifact{a.bin} } diff --git a/internal/rosa/etc.go b/internal/rosa/etc.go index ce43bf07..a69b3fa9 100644 --- a/internal/rosa/etc.go +++ b/internal/rosa/etc.go @@ -118,8 +118,8 @@ func init() { // IsExclusive returns false: Cure performs a few trivial filesystem writes. func (cureEtc) IsExclusive() bool { return false } -// Dependencies returns a slice containing the backing iana-etc release. -func (a cureEtc) Dependencies() []pkg.Artifact { +// Inputs returns a slice containing the backing iana-etc release. +func (a cureEtc) Inputs() []pkg.Artifact { if !a.minimal { return []pkg.Artifact{ianaEtc} }