Skip to content

Commit

Permalink
remove need to read from disk to get template
Browse files Browse the repository at this point in the history
  • Loading branch information
bthaile committed Sep 28, 2023
1 parent 4932623 commit 64e11a5
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions flixkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"io/fs"
"log"
"net/http"
"os"
)
type Generator interface {
Generate(flix *FlowInteractionTemplate, templateLocation string, isLocal bool) (string, error)
Expand All @@ -21,17 +20,6 @@ type FlixService interface {
GetFlixByID(ctx context.Context, templateID string) (*FlowInteractionTemplate, error)
}

// OsFileReader is a real implementation that calls os.ReadFile.
type OsFileReader struct{}

func (o OsFileReader) ReadFile(filename string) ([]byte, error) {
return os.ReadFile(filename)
}

func (o OsFileReader) Open(filename string) (fs.File, error) {
return os.Open(filename)
}

type flixServiceImpl struct {
config *Config
}
Expand All @@ -46,10 +34,6 @@ func NewFlixService(config *Config) FlixService {
config.FlixServerURL = "https://flix.flow.com/v1/templates"
}

if config.FileReader == nil {
config.FileReader = OsFileReader{}
}

return &flixServiceImpl{
config: config,
}
Expand Down Expand Up @@ -127,11 +111,3 @@ func FetchFlixWithContext(ctx context.Context, url string) (string, error) {

return string(body), nil
}

func FetchFlixWithContextFromFile(ctx context.Context, reader fs.ReadFileFS, url string) (string, error) {
body, err := reader.ReadFile(url)
if err != nil {
log.Fatalf("Failed to read file: %v", err)
}
return string(body), nil
}

0 comments on commit 64e11a5

Please sign in to comment.