From 91c3594dee2f1689501997d395af7019df8bebe2 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 12 Jan 2026 03:53:19 +0900 Subject: internal/pkg: append user-facing name in messages This makes verbose messages much more useful. Signed-off-by: Ophestra --- internal/pkg/tar.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'internal/pkg/tar.go') diff --git a/internal/pkg/tar.go b/internal/pkg/tar.go index 624eafe2..0aa8e3bf 100644 --- a/internal/pkg/tar.go +++ b/internal/pkg/tar.go @@ -6,6 +6,7 @@ import ( "compress/gzip" "encoding/binary" "errors" + "fmt" "io" "io/fs" "net/http" @@ -32,11 +33,29 @@ type tarArtifact struct { compression uint64 } +// tarArtifactNamed embeds tarArtifact for a [fmt.Stringer] tarball. +type tarArtifactNamed struct { + tarArtifact + // Copied from tarArtifact.f. + name string +} + +var _ fmt.Stringer = new(tarArtifactNamed) + +// String returns the name of the underlying [Artifact] suffixed with unpack. +func (a *tarArtifactNamed) String() string { return a.name + "-unpack" } + // NewTar returns a new [Artifact] backed by the supplied [Artifact] and // compression method. The source [Artifact] must be compatible with // [TContext.Open]. func NewTar(a Artifact, compression uint64) Artifact { - return &tarArtifact{a, compression} + ta := tarArtifact{a, compression} + if s, ok := a.(fmt.Stringer); ok { + if name := s.String(); name != "" { + return &tarArtifactNamed{ta, name} + } + } + return &ta } // NewHTTPGetTar is abbreviation for NewHTTPGet passed to NewTar. -- cgit v1.3.1