diff options
Diffstat (limited to 'internal/pkg/exec.go')
| -rw-r--r-- | internal/pkg/exec.go | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/internal/pkg/exec.go b/internal/pkg/exec.go index 8d27d07d..f8131855 100644 --- a/internal/pkg/exec.go +++ b/internal/pkg/exec.go @@ -2,7 +2,6 @@ package pkg import ( "bufio" - "bytes" "context" "errors" "fmt" @@ -101,8 +100,9 @@ func (a *execNetArtifact) Checksum() Checksum { return a.checksum } func (a *execNetArtifact) Kind() Kind { return KindExecNet } // Params is [Checksum] concatenated with [KindExec] params. -func (a *execNetArtifact) Params() []byte { - return slices.Concat(a.checksum[:], a.execArtifact.Params()) +func (a *execNetArtifact) Params(ctx *IContext) { + ctx.GetHash().Write(a.checksum[:]) + a.execArtifact.Params(ctx) } // Cure cures the [Artifact] in the container described by the caller. The @@ -165,40 +165,40 @@ func NewExec( // Kind returns the hardcoded [Kind] constant. func (a *execArtifact) Kind() Kind { return KindExec } -// Params returns paths, executable pathname and args concatenated together. -func (a *execArtifact) Params() []byte { - var buf bytes.Buffer +// Params writes paths, executable pathname and args. +func (a *execArtifact) Params(ctx *IContext) { + h := ctx.GetHash() + + _0, _1 := []byte{0}, []byte{1} for _, p := range a.paths { if p.W { - buf.WriteByte(1) + h.Write(_1) } else { - buf.WriteByte(0) + h.Write(_0) } if p.P != nil { - buf.WriteString(p.P.String()) + h.Write([]byte(p.P.String())) } else { - buf.WriteString("invalid P\x00") + h.Write([]byte("invalid P\x00")) } - buf.WriteByte(0) + h.Write(_0) for _, d := range p.A { - id := Ident(d) - buf.Write(id[:]) + ctx.WriteIdent(d) } - buf.WriteByte(0) + h.Write(_0) } - buf.WriteByte(0) - buf.WriteString(a.dir.String()) - buf.WriteByte(0) + h.Write(_0) + h.Write([]byte(a.dir.String())) + h.Write(_0) for _, e := range a.env { - buf.WriteString(e) + h.Write([]byte(e)) } - buf.WriteByte(0) - buf.WriteString(a.path.String()) - buf.WriteByte(0) + h.Write(_0) + h.Write([]byte(a.path.String())) + h.Write(_0) for _, arg := range a.args { - buf.WriteString(arg) + h.Write([]byte(arg)) } - return buf.Bytes() } // Dependencies returns a slice of all artifacts collected from caller-supplied |
