all repos — searchix @ 0ae74e5f6af61819e8f954960287ea14ec447834

Search engine for NixOS, nix-darwin, home-manager and NUR users

refactor: pass options struct to fetcher.New

Alan Pearce
commit

0ae74e5f6af61819e8f954960287ea14ec447834

parent

4f1db3ca3ae4d7a522834aca55cd619bb4798f5f

2 files changed, 11 insertions(+), 5 deletions(-)

changed files
M internal/fetcher/main.gointernal/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.gointernal/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")) }