diff options
author | Alan Pearce | 2024-05-20 23:55:40 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-20 23:55:40 +0200 |
commit | b77a24f9f75378ffe97be83cf4dfd7f1683b9a7e (patch) | |
tree | 5e5efa81a76b8e3349c522729b98bb0d106f3bce /internal/fetcher/nixpkgs-channel.go | |
parent | c821da1cf55864852bcd8f337dd7acd0cc02f0b9 (diff) | |
download | searchix-b77a24f9f75378ffe97be83cf4dfd7f1683b9a7e.tar.lz searchix-b77a24f9f75378ffe97be83cf4dfd7f1683b9a7e.tar.zst searchix-b77a24f9f75378ffe97be83cf4dfd7f1683b9a7e.zip |
fix: make fetcher check on creation that it supports Source.Importer
Diffstat (limited to 'internal/fetcher/nixpkgs-channel.go')
-rw-r--r-- | internal/fetcher/nixpkgs-channel.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/fetcher/nixpkgs-channel.go b/internal/fetcher/nixpkgs-channel.go index 32aaac3..033b577 100644 --- a/internal/fetcher/nixpkgs-channel.go +++ b/internal/fetcher/nixpkgs-channel.go @@ -2,6 +2,7 @@ package fetcher import ( "context" + "fmt" "log/slog" "net/url" "path" @@ -23,6 +24,23 @@ func makeChannelURL(channel string, subPath string) (string, error) { return url, errors.WithMessagef(err, "error creating URL") } +func NewNixpkgsChannelFetcher( + source *config.Source, + dataPath string, + logger *slog.Logger, +) (*NixpkgsChannelFetcher, error) { + switch source.Importer { + case config.Options, config.Packages: + return &NixpkgsChannelFetcher{ + DataPath: dataPath, + Source: source, + Logger: logger, + }, nil + default: + return nil, fmt.Errorf("unsupported importer type %s", source.Importer) + } +} + const ( revisionFilename = "git-revision" optionsFilename = "options.json.br" |