diff options
Diffstat (limited to 'internal/pkg/file.go')
| -rw-r--r-- | internal/pkg/file.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/pkg/file.go b/internal/pkg/file.go index 4558eb40..03197c59 100644 --- a/internal/pkg/file.go +++ b/internal/pkg/file.go @@ -1,9 +1,11 @@ package pkg import ( + "bytes" "context" "crypto/sha512" "fmt" + "io" ) // A fileArtifact is an [Artifact] that cures into data known ahead of time. @@ -24,10 +26,10 @@ var _ KnownChecksum = new(fileArtifactNamed) // String returns the caller-supplied reporting name. func (a *fileArtifactNamed) String() string { return a.name } -// NewFile returns a [File] that cures into a caller-supplied byte slice. +// NewFile returns a [FileArtifact] that cures into a caller-supplied byte slice. // // Caller must not modify data after NewFile returns. -func NewFile(name string, data []byte) File { +func NewFile(name string, data []byte) FileArtifact { f := fileArtifact(data) if name != "" { return &fileArtifactNamed{f, name} @@ -52,4 +54,6 @@ func (a *fileArtifact) Checksum() Checksum { } // Cure returns the caller-supplied data. -func (a *fileArtifact) Cure(context.Context) ([]byte, error) { return *a, nil } +func (a *fileArtifact) Cure(context.Context) (io.ReadCloser, error) { + return io.NopCloser(bytes.NewReader(*a)), nil +} |
