refactor: pass options struct to fetcher.New
2 files changed, 11 insertions(+), 5 deletions(-)
changed files
M internal/fetcher/main.go → internal/fetcher/main.go
@@ -10,6 +10,10 @@ "alin.ovh/x/log" "github.com/Southclaws/fault" ) +type Options struct { + Logger *log.Logger +} + type FetchedFiles struct { Revision io.ReadCloser Options io.ReadCloser@@ -22,15 +26,15 @@ } func New( source *config.Source, - logger *log.Logger, + opts *Options, ) (fetcher Fetcher, err error) { switch source.Fetcher { case config.ChannelNixpkgs: - fetcher, err = NewNixpkgsChannelFetcher(source, logger) + fetcher, err = NewNixpkgsChannelFetcher(source, opts.Logger) case config.Channel: - fetcher, err = NewChannelFetcher(source, logger) + fetcher, err = NewChannelFetcher(source, opts.Logger) case config.Download: - fetcher, err = NewDownloadFetcher(source, logger) + fetcher, err = NewDownloadFetcher(source, opts.Logger) default: err = fault.Newf("unsupported fetcher type %s", source.Fetcher.String()) }
M internal/importer/main.go → internal/importer/main.go
@@ -65,7 +65,9 @@ return func(source *config.Source) error { logger := imp.options.Logger.With("name", source.Key) logger.Debug("starting fetcher") - fetcher, err := fetcher.New(source, logger) + fetcher, err := fetcher.New(source, &fetcher.Options{ + Logger: logger, + }) if err != nil { return fault.Wrap(err, fmsg.With("error creating fetcher")) }