From 0fbe7bc5295a98194918207a69f7ac34e5ecbad3 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 18 Mar 2021 16:42:16 -0700 Subject: [PATCH] make readme method return an io.Reader --- workspace.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/workspace.go b/workspace.go index 8623f88a4..822f42d20 100644 --- a/workspace.go +++ b/workspace.go @@ -4,7 +4,9 @@ import ( "context" "errors" "fmt" + "io" "net/url" + "strings" "time" ) @@ -124,11 +126,17 @@ type Workspace struct { // Readme will retrieve any readme file attached to the workspace. "" if none // exists. -func (w *Workspace) Readme(ctx context.Context) (string, error) { +func (w *Workspace) Readme(ctx context.Context) (io.Reader, error) { if w.readme == nil { - return "", nil + return nil, nil } - return w.readme(ctx) + + readme, err := w.readme(ctx) + if err != nil { + return nil, err + } + + return strings.NewReader(readme), nil } // VCSRepo contains the configuration of a VCS integration.